aboutsummaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/app.js23
-rw-r--r--static/modules/windows.js10
2 files changed, 32 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;
diff --git a/static/modules/windows.js b/static/modules/windows.js
index 7e2a184..d9f388e 100644
--- a/static/modules/windows.js
+++ b/static/modules/windows.js
@@ -165,6 +165,16 @@ export default {
</div>`;
},
+ // A window that was not there on the last poll brings the tab forward for
+ // [windows] peek seconds.
+ peek(st) {
+ if (!st.windows) return false;
+ const ids = new Set(st.windows.map((w) => w.id));
+ const fresh = this._ids != null && [...ids].some((id) => !this._ids.has(id));
+ this._ids = ids;
+ return fresh ? st.peek ?? 8 : 0;
+ },
+
update(st, el) {
// Polled every second: rebuilding unchanged rows reloads every icon
// through its fallbacks, which flickers, so only a change re-renders.