Molodetz blogrol volgens DPP-template
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
import { Http } from "./Http.js";
|
||||
import { Poller } from "./Poller.js";
|
||||
|
||||
export class PresenceManager {
|
||||
constructor() {
|
||||
this.online = new Set();
|
||||
this.poller = null;
|
||||
if (document.querySelector("[data-presence-uid]")) {
|
||||
this.poller = new Poller(() => this.refresh(), 20000, { immediate: false }).start();
|
||||
}
|
||||
}
|
||||
|
||||
async refresh() {
|
||||
const roster = await Http.getJson("/presence/roster");
|
||||
this.online = new Set(roster.online || []);
|
||||
this.render();
|
||||
}
|
||||
|
||||
render() {
|
||||
document.querySelectorAll("[data-presence-uid]").forEach((dot) => {
|
||||
dot.classList.toggle("online", this.online.has(dot.dataset.presenceUid));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user