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
|
|
@ -23,25 +23,32 @@ ul {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;*/
|
padding: 0;*/
|
||||||
}
|
}
|
||||||
li.me::after {
|
.player.inactive {
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
.player.inactive::after {
|
||||||
|
content: " (gone)";
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
.player.me::after {
|
||||||
content: " — that's you!";
|
content: " — that's you!";
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
li.buzzing {
|
.player.buzzing {
|
||||||
color: red;
|
color: red;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
li.buzzing.first::before {
|
.player.buzzing.first::before {
|
||||||
content: "🥇 ";
|
content: "🥇 ";
|
||||||
}
|
}
|
||||||
li.buzzing.too-late {
|
.player.buzzing.too-late {
|
||||||
color: black;
|
color: black;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
li.buzzing.too-late::before {
|
.player.buzzing.too-late::before {
|
||||||
content: "🥈 ";
|
content: "🥈 ";
|
||||||
}
|
}
|
||||||
#info {
|
#info {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
placeholder="Please put your name here ..."
|
placeholder="Please put your name here ..."
|
||||||
/></label>
|
/></label>
|
||||||
<h2>All Players</h2>
|
<h2>All Players</h2>
|
||||||
<ul>
|
<ul class="players">
|
||||||
<!-- players will be inserted here -->
|
<!-- players will be inserted here -->
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<template id="player">
|
<template id="player">
|
||||||
<li data-cid="client ID">player name</li>
|
<li class="player" data-cid="client ID">player name</li>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script type="module" src="./buzzer.js"></script>
|
<script type="module" src="./buzzer.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,17 @@ const on = (event, cb) => document.addEventListener(event, cb)
|
||||||
function node(type, { appendTo, cls, text, data, style, ...attrs } = {}) {
|
function node(type, { appendTo, cls, text, data, style, ...attrs } = {}) {
|
||||||
let elem = typeof type === "string" ? document.createElement(type) : type
|
let elem = typeof type === "string" ? document.createElement(type) : type
|
||||||
if (cls) {
|
if (cls) {
|
||||||
|
if (typeof cls === "string") {
|
||||||
elem.className = cls
|
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) {
|
if (text) {
|
||||||
elem.textContent = text
|
elem.textContent = text
|
||||||
|
|
@ -105,7 +115,10 @@ function redraw_clients(me, clients) {
|
||||||
text: c.name,
|
text: c.name,
|
||||||
data: { cid: c.id },
|
data: { cid: c.id },
|
||||||
appendTo: ul,
|
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