diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/app.js | 16 | ||||
| -rw-r--r-- | static/deck.css | 5 | ||||
| -rw-r--r-- | static/index.html | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/static/app.js b/static/app.js index 3e75a4b..b824667 100644 --- a/static/app.js +++ b/static/app.js @@ -270,6 +270,22 @@ setInterval(() => { if (asleep.hidden && Date.now() - lastAnswer > ASLEEP_AFTER) goodnight("The PC is not answering"); }, 2000); +// After [tablet] dim_after seconds with no touch the server lowers the +// tablet's backlight and a dark layer covers the page; the touch that lands +// on that layer only brings the brightness back. +const dimmer = document.getElementById("dimmer"); +let dimAfter = 0, dimTimer = null; +const tablet = (action) => fetch(`/api/tablet/${action}`, { + method: "POST", headers: { "Content-Type": "application/json" }, body: "{}", +}).catch(() => {}); +function touched() { + clearTimeout(dimTimer); + if (dimAfter > 0) dimTimer = setTimeout(() => { dimmer.hidden = false; tablet("dim"); }, dimAfter * 1000); +} +dimmer.addEventListener("click", () => { dimmer.hidden = true; tablet("undim"); }); +document.addEventListener("pointerdown", touched, true); +fetch("/api/tablet").then((r) => r.json()).then((t) => { dimAfter = t.dim_after ?? 0; touched(); }).catch(() => {}); + document.addEventListener("visibilitychange", () => { if (document.visibilityState === "visible") { lastAnswer = Math.max(lastAnswer, Date.now() - ASLEEP_AFTER + 5000); // a moment for the refresh below diff --git a/static/deck.css b/static/deck.css index a25ee46..6311c75 100644 --- a/static/deck.css +++ b/static/deck.css @@ -602,6 +602,11 @@ select { .assistant .as-op.bad { color: var(--udt-red); } .assistant .md, .assistant .as-q { user-select: text; } +/* 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[hidden] { display: none; } + /* The PC asleep: over everything, and the wake lock is dropped (app.js). */ #asleep { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; diff --git a/static/index.html b/static/index.html index bb27c19..e446940 100644 --- a/static/index.html +++ b/static/index.html @@ -39,6 +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="asleep" hidden> <div class="asleep-moon nf"></div> <div class="off-title" id="asleep-title"></div> |
