From 610eb2743071050968d2f18a2ff0f3157bca6499 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 16 Nov 2023 22:18:16 -0700 Subject: [PATCH] Scoreboard changes: * Consistent category colors * Only show server URL when enabled * HTML to display when there are no scores --- theme/config.json | 3 ++- theme/moth.mjs | 4 ++-- theme/scoreboard.css | 15 +++++++++++++++ theme/scoreboard.html | 5 ++--- theme/scoreboard.mjs | 12 +++++++++--- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/theme/config.json b/theme/config.json index 0b8cc52..ff6284c 100644 --- a/theme/config.json +++ b/theme/config.json @@ -1,11 +1,12 @@ { "TrackSolved": true, "Scoreboard": { - "DisplayServerURL": true, + "DisplayServerURLWhenEnabled": true, "ShowCategoryLeaders": true, "ReplayHistory": true, "ReplayFPS": 6, "ReplayDurationMS": 2000, + "NoScoresHtml": "

~ no scores ~

", "": "" }, "Messages": "", diff --git a/theme/moth.mjs b/theme/moth.mjs index 9351e3a..4bce873 100644 --- a/theme/moth.mjs +++ b/theme/moth.mjs @@ -367,8 +367,8 @@ class State { Devel: obj.Config.Devel, } - /** True if the server is in enabled state */ - this.Enabled = obj.Enabled + /** True if the server is in enabled state, or if we don't know */ + this.Enabled = obj.Enabled ?? true /** Map from Team ID to Team Name * @type {Object.} diff --git a/theme/scoreboard.css b/theme/scoreboard.css index c95fa65..f280271 100644 --- a/theme/scoreboard.css +++ b/theme/scoreboard.css @@ -18,6 +18,21 @@ text-decoration: underline; } +.no-scores { + display: flex; + justify-content: space-around; + align-items: center; + flex-wrap: wrap; + min-height: calc(100vh - 2em); +} +.no-scores.hidden { + display: none; +} +.no-scores img { + object-fit: cover; + max-height: 60vh; +} + /** Scoreboard */ #rankings { width: 100%; diff --git a/theme/scoreboard.html b/theme/scoreboard.html index 1e14424..c5dfa9d 100644 --- a/theme/scoreboard.html +++ b/theme/scoreboard.html @@ -5,12 +5,11 @@ - - - + +
diff --git a/theme/scoreboard.mjs b/theme/scoreboard.mjs index 492d2ac..9a17373 100644 --- a/theme/scoreboard.mjs +++ b/theme/scoreboard.mjs @@ -42,17 +42,18 @@ async function update() { console.warn("config.json has empty Scoreboard section") } + let state = await server.GetState() + for (let e of document.querySelectorAll(".location")) { e.textContent = common.BaseURL - e.classList.toggle("hidden", !ScoreboardConfig.DisplayServerURL) + e.classList.toggle("hidden", !(ScoreboardConfig.DisplayServerURLWhenEnabled && state.Enabled)) } - let state = await server.GetState() let rankingsElement = document.querySelector("#rankings") let logSize = state.PointsLog.length // Figure out the timing so that we can replay the scoreboard in about - // ReplayDurationMS, but no more than 24 frames per second. + // ReplayDurationMS. let frameModulo = 1 let delay = 0 while (delay < (common.Second / ReplayFPS)) { @@ -110,6 +111,11 @@ async function update() { } await sleep(delay) } + + for (let e of document.querySelectorAll(".no-scores")) { + e.innerHTML = ScoreboardConfig.NoScoresHtml + e.classList.toggle("hidden", frame > 0) + } } function init() {