diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-11 10:01:11 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-11 10:01:11 +0100 |
| commit | 79d3be64f0a3e4552b08c80f1678649ccbff2a7c (patch) | |
| tree | 9f6532b6119a6a71dd08d108bd1527cec6b8ce41 /static/app.js | |
| parent | 978ec811803cdbeb10dc2e6924ab33aa2b84bec6 (diff) | |
| download | deck-it-79d3be64f0a3e4552b08c80f1678649ccbff2a7c.tar.gz deck-it-79d3be64f0a3e4552b08c80f1678649ccbff2a7c.zip | |
feat(windows): a new window brings the Windows tab forward
When a window id appears that the last poll did not list, the tablet
shows the Windows tab for [windows] peek seconds (default 8, 0 off) and
then goes back to the tab it was on. A touch on the page or a tab change
meanwhile keeps it there; another new window restarts the timer.
The hook is generic: a panel's peek(state) returns seconds, app.js does
the switching. The first poll only learns what is open, and an error
state keeps what it knew, so neither triggers it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/app.js')
| -rw-r--r-- | static/app.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/static/app.js b/static/app.js index 79010bf..a15c2de 100644 --- a/static/app.js +++ b/static/app.js @@ -65,6 +65,7 @@ function sortTabs() { } function showTab(name) { + keep(); for (const [n, tab] of Object.entries(tabs)) { tab.section.hidden = n !== name; tab.button.classList.toggle("active", n === name); @@ -74,6 +75,21 @@ function showTab(name) { } catch {} } +// A panel's peek(state) gives seconds when something new turned up: its tab +// comes forward that long, then the page goes back, unless touched first. +let peek = null; // {back, timer} while a tab is shown on its own +function peekTab(name, seconds) { + const now = Object.keys(tabs).find((n) => !tabs[n].section.hidden); + if (now === name && !peek) return; // already there by choice + const back = peek?.back ?? now; + showTab(name); + peek = { back, timer: setTimeout(() => showTab(back), seconds * 1000) }; +} +function keep() { + if (peek) clearTimeout(peek.timer); + peek = null; +} + const dashboard = ensureTab("Dashboard"); dashboard.section.hidden = false; dashboard.button.classList.add("active"); @@ -102,7 +118,11 @@ function mountTab(name, panel, section) { wrap.className = "tab-content"; section.append(wrap); panel.mount?.(wrap); - poll(name, panel.interval ?? 1, (st) => panel.update?.(st, wrap)); + poll(name, panel.interval ?? 1, (st) => { + panel.update?.(st, wrap); + const seconds = panel.peek?.(st); + if (seconds > 0) peekTab(panel.tab, seconds); + }); } // Modules with no panel file: dashboard.js draws them. @@ -151,6 +171,7 @@ function stepTab(dir) { let swipe = null; let swallowClick = false; tabBody.addEventListener("pointerdown", (e) => { + keep(); if (e.pointerType === "mouse" && e.buttons !== 1) return; if (e.target.closest("input, select, textarea")) { swipe = null; |
