diff options
Diffstat (limited to 'static/dashboard.js')
| -rw-r--r-- | static/dashboard.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/static/dashboard.js b/static/dashboard.js index 5dc8939..de8aaae 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -44,7 +44,7 @@ const pct = (v) => (v == null ? "—" : `${Math.round(v)}%`); const short = (m) => String(m ?? "").split("/").pop(); const uptime = (s) => { const d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600); - return d ? `${d}d ${h}h` : `${h}h`; + return d ? `${d}d ${h}h` : h ? `${h}h` : `${Math.floor(s / 60)}m`; }; export function push(list, v, n = HISTORY) { @@ -78,6 +78,7 @@ export function batteryGlyph(b) { // one that fits stays still. Only changed values are written, so the // animation is not restarted by every poll. function marquee(el) { + if (!el.offsetParent) return; // another tab is in front: nothing to measure for (const line of el.querySelectorAll(".what, .meta")) { const over = line.firstElementChild.offsetWidth - line.clientWidth; line.classList.toggle("marq", over > 0); @@ -91,9 +92,9 @@ function marquee(el) { const SKELETON = ` <svg class="dash-defs" width="0" height="0" aria-hidden="true"><defs> - <linearGradient id="hyline"><stop offset="0" style="stop-color:var(--udt-border-1)"/> + <linearGradient id="hyline" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="120" y2="0"><stop offset="0" style="stop-color:var(--udt-border-1)"/> <stop offset=".5" style="stop-color:var(--udt-border-2)"/><stop offset="1" style="stop-color:var(--udt-border-3)"/></linearGradient> - <linearGradient id="hyfill" x1="0" y1="0" x2="0" y2="1"> + <linearGradient id="hyfill" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="0" y2="100"> <stop offset="0" style="stop-color:var(--udt-border-2);stop-opacity:.45"/> <stop offset="1" style="stop-color:var(--udt-border-1);stop-opacity:.05"/></linearGradient> </defs></svg> @@ -245,11 +246,10 @@ export default { // ponytail: the K1C and OBS tabs poll the same API; two polls a second, one cache if it matters. poll(name, mod.interval ?? mod.default?.interval ?? 2, (st) => { el.hidden = !mod.busy(st); - if (!el.hidden) { - mod.slot(st, el); - marquee(el); - } + if (!el.hidden) mod.slot(st, el); row.hidden = !row.querySelector(".slot:not([hidden])"); + // a slot coming or going changes the others' widths + for (const s of row.querySelectorAll(".slot:not([hidden])")) marquee(s); }); }); } |
