aboutsummaryrefslogtreecommitdiffstats
path: root/static/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/app.js')
-rw-r--r--static/app.js10
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(() => {});