diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/app.js | 10 | ||||
| -rw-r--r-- | static/deck.css | 7 | ||||
| -rw-r--r-- | static/index.html | 2 |
3 files changed, 16 insertions, 3 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(() => {}); diff --git a/static/deck.css b/static/deck.css index 6311c75..471aa07 100644 --- a/static/deck.css +++ b/static/deck.css @@ -604,8 +604,13 @@ select { /* The tablet dimmed after [tablet] dim_after idle seconds (app.js): catches the waking touch so it presses nothing underneath. */ -#dimmer { position: fixed; inset: 0; z-index: 90; background: rgb(0 0 0 / .6); } +#dimmer { + position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; + align-items: center; justify-content: center; background: rgb(0 0 0 / .85); +} #dimmer[hidden] { display: none; } +.dim-time { font-size: 8rem; font-weight: 300; line-height: 1; color: var(--udt-text); font-variant-numeric: tabular-nums; } +.dim-date { font-size: 1.6rem; color: var(--udt-subtext0); } /* The PC asleep: over everything, and the wake lock is dropped (app.js). */ #asleep { diff --git a/static/index.html b/static/index.html index e446940..a8df407 100644 --- a/static/index.html +++ b/static/index.html @@ -39,7 +39,7 @@ <button id="reload" class="reload" aria-label="Reload the dashboard" title="Reload"><i class="nf"></i></button> </header> <div id="tab-body"></div> -<div id="dimmer" hidden></div> +<div id="dimmer" hidden><div class="dim-time"></div><div class="dim-date"></div></div> <div id="asleep" hidden> <div class="asleep-moon nf"></div> <div class="off-title" id="asleep-title"></div> |
