show in the UI if a player is disconnected

This commit is contained in:
ducklet 2021-01-31 00:56:30 +01:00
parent e41172ca57
commit f406627042
3 changed files with 29 additions and 9 deletions

View file

@ -22,7 +22,17 @@ const on = (event, cb) => document.addEventListener(event, cb)
function node(type, { appendTo, cls, text, data, style, ...attrs } = {}) {
let elem = typeof type === "string" ? document.createElement(type) : type
if (cls) {
elem.className = cls
if (typeof cls === "string") {
elem.className = cls
} else {
for (const [name, on] of Object.entries(cls)) {
if (on) {
elem.classList.add(name)
} else {
elem.classList.remove(name)
}
}
}
}
if (text) {
elem.textContent = text
@ -105,7 +115,10 @@ function redraw_clients(me, clients) {
text: c.name,
data: { cid: c.id },
appendTo: ul,
cls: c.id === me.id ? "me" : "",
cls: {
me: c.id === me.id,
inactive: !c.active,
},
})
}
}