aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 20:13:57 +0100
committertv <tv@krebsco.de>2026-10-31 20:13:57 +0100
commit3d69f9af28bd14006fd599fa72e7b4cba801e672 (patch)
treecfbdad27c3f9a051a33796bde7841232a4b8fe24 /src/api
parent6f03f74266314f1642b757047da5ab88b34714a4 (diff)
dashboard: don't recreate tooltip on change
Diffstat (limited to 'src/api')
-rw-r--r--src/api/dashboard/dashboard.html17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html
index 73b7d30..8ea06e5 100644
--- a/src/api/dashboard/dashboard.html
+++ b/src/api/dashboard/dashboard.html
@@ -508,10 +508,25 @@ function upright(attrs) {
function text(node, content) {
if (node.textContent !== content) node.textContent = content;
}
+// A tooltip whose text changes under the pointer goes and comes back (the ages in it
+// change on every render): its new text waits until the pointer leaves.
+const tooltipsDue = new WeakMap();
function tooltip(node, content) {
let title = node.firstElementChild;
if (!title) node.append(title = svg("title"));
- text(title, content);
+ if (title.textContent === content || !title.textContent || !node.matches(":hover")) {
+ tooltipsDue.delete(node);
+ text(title, content);
+ return;
+ }
+ if (!tooltipsDue.has(node)) {
+ node.addEventListener("mouseleave", () => {
+ const due = tooltipsDue.get(node);
+ tooltipsDue.delete(node);
+ if (due !== undefined) text(title, due);
+ }, { once: true });
+ }
+ tooltipsDue.set(node, content);
}
// `root` showing `children`, in order: the others go, and only what is out of place
// moves.