show in the UI if a player is disconnected
This commit is contained in:
parent
e41172ca57
commit
f406627042
3 changed files with 29 additions and 9 deletions
|
|
@ -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,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue