Add expandable rows to dashboard tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 15:32:16 +01:00
1 parent e9758499ff
commit 536aee1f31
4 files changed
+88 -3

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
(() => {
const storageKey = "flypaper.expanded";
const load = () => {
try {
return new Set(JSON.parse(sessionStorage.getItem(storageKey) ?? "[]"));
} catch {
return new Set();
}
};
const save = keys => {
try {
sessionStorage.setItem(storageKey, JSON.stringify([...keys]));
} catch {
}
};
const stored = load();
const expanded = new Set();
for (const row of document.querySelectorAll("tr[data-expand]")) {
const key = row.dataset.expand;
const apply = open => {
row.classList.toggle("open", open);
row.setAttribute("aria-expanded", String(open));
open ? expanded.add(key) : expanded.delete(key);
};
const toggle = () => {
apply(!row.classList.contains("open"));
save(expanded);
};
apply(stored.has(key));
row.addEventListener("click", () => {
if (!window.getSelection()?.isCollapsed) {
return;
}
toggle();
});
row.addEventListener("keydown", event => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
toggle();
}
});
}
save(expanded);
})();