diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-12 09:39:08 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-12 09:39:08 +0100 |
| commit | 28a5a51c0a5e059a0389ddd1e75c6ecc91f6e38d (patch) | |
| tree | 40625e19b1a021e1694c52f23bd04609073704a0 /static/app.js | |
| parent | 512a2b4a2821a1edadf5530d060e3ae5468d75e8 (diff) | |
| download | deck-it-28a5a51c0a5e059a0389ddd1e75c6ecc91f6e38d.tar.gz deck-it-28a5a51c0a5e059a0389ddd1e75c6ecc91f6e38d.zip | |
feat(dashboard): show a clock and date on the dim cover
The cover that hides the dashboard while the tablet is dimmed was only a
dark area; it now shows the time and date in the tablet's locale, so the
dim tablet stays useful at a glance. The cover is darker (85%) so the
clock stands out from the dashboard behind it, and it ticks only while
shown.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/app.js')
| -rw-r--r-- | static/app.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/static/app.js b/static/app.js index cbc0f0a..d16bd80 100644 --- a/static/app.js +++ b/static/app.js @@ -280,9 +280,17 @@ const tablet = (action) => fetch(`/api/tablet/${action}`, { }).catch(() => {}); function touched() { clearTimeout(dimTimer); - if (dimAfter > 0) dimTimer = setTimeout(() => { dimmer.hidden = false; tablet("dim"); }, dimAfter * 1000); + if (dimAfter > 0) dimTimer = setTimeout(() => { dimmer.hidden = false; tick(); tablet("dim"); }, dimAfter * 1000); } dimmer.addEventListener("click", () => { dimmer.hidden = true; tablet("undim"); }); +// A clock on the cover, so the dim tablet still tells the time at a glance. +function tick() { + if (dimmer.hidden) return; + const now = new Date(); + dimmer.querySelector(".dim-time").textContent = now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); + dimmer.querySelector(".dim-date").textContent = now.toLocaleDateString([], { weekday: "long", day: "numeric", month: "long" }); +} +setInterval(tick, 1000); document.addEventListener("pointerdown", touched, true); // A fresh page is not dimmed, so a dim left by an earlier server goes too. fetch("/api/tablet").then((r) => r.json()).then((t) => { dimAfter = t.dim_after ?? 0; tablet("undim"); touched(); }).catch(() => {}); |
