Add player list
This commit is contained in:
parent
6dd8d36f57
commit
ac1f03bec0
1 changed files with 19 additions and 1 deletions
|
@ -35,6 +35,7 @@ function checkMinecraftServerStatus() {
|
||||||
loading.style.display = "none";
|
loading.style.display = "none";
|
||||||
servers.style.display = "inherit";
|
servers.style.display = "inherit";
|
||||||
const newChildren = [];
|
const newChildren = [];
|
||||||
|
let pl = null;
|
||||||
for (let k of Object.keys(statuses)) {
|
for (let k of Object.keys(statuses)) {
|
||||||
const status = statuses[k]
|
const status = statuses[k]
|
||||||
const el = document.createElement("li")
|
const el = document.createElement("li")
|
||||||
|
@ -50,6 +51,23 @@ function checkMinecraftServerStatus() {
|
||||||
p.style.marginLeft = "0.5em";
|
p.style.marginLeft = "0.5em";
|
||||||
if (status.players) {
|
if (status.players) {
|
||||||
p.textContent = `(${status.players.online}/${status.players.max} players)`
|
p.textContent = `(${status.players.online}/${status.players.max} players)`
|
||||||
|
if (status.players.online > 0 && status.players.list) {
|
||||||
|
pl = document.createElement("details")
|
||||||
|
pl.style.marginTop = "0"
|
||||||
|
const pld = document.createElement("summary")
|
||||||
|
pld.textContent = "Players List"
|
||||||
|
pld.style.color = "var(--link-fg)"
|
||||||
|
pld.style.textDecoration = "underline"
|
||||||
|
const plist = document.createElement("ul")
|
||||||
|
pl.appendChild(pld)
|
||||||
|
pl.appendChild(plist)
|
||||||
|
el.appendChild(pl)
|
||||||
|
for (let p of status.players.list) {
|
||||||
|
const pi = document.createElement("li")
|
||||||
|
pi.textContent = p.name
|
||||||
|
plist.appendChild(pi)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
el.replaceChildren(
|
el.replaceChildren(
|
||||||
s,
|
s,
|
||||||
|
@ -57,8 +75,8 @@ function checkMinecraftServerStatus() {
|
||||||
c,
|
c,
|
||||||
p,
|
p,
|
||||||
)
|
)
|
||||||
|
if (pl != null) el.appendChild(pl)
|
||||||
newChildren.push(el)
|
newChildren.push(el)
|
||||||
|
|
||||||
}
|
}
|
||||||
servers.replaceChildren(...newChildren)
|
servers.replaceChildren(...newChildren)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue