diff --git a/content/minecraft-server-status.md b/content/minecraft-server-status.md index e445891..77930b3 100644 --- a/content/minecraft-server-status.md +++ b/content/minecraft-server-status.md @@ -35,6 +35,7 @@ function checkMinecraftServerStatus() { loading.style.display = "none"; servers.style.display = "inherit"; const newChildren = []; + let pl = null; for (let k of Object.keys(statuses)) { const status = statuses[k] const el = document.createElement("li") @@ -50,6 +51,23 @@ function checkMinecraftServerStatus() { p.style.marginLeft = "0.5em"; if (status.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( s, @@ -57,8 +75,8 @@ function checkMinecraftServerStatus() { c, p, ) + if (pl != null) el.appendChild(pl) newChildren.push(el) - } servers.replaceChildren(...newChildren) })