This commit is contained in:
traveler 2025-12-23 15:25:57 -06:00
parent 90c0752590
commit fb2883c8ff
2 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,38 @@
// custom.js
(function () {
const tabClasses = [
"tab-glance",
"tab-pncharris",
"tab-netgrimoire",
"tab-wasted-bandwidth",
];
function normalize(s) {
return (s || "")
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/(^-|-$)/g, "");
}
function applyTabClass() {
// Tabs commonly appear in the URL hash with Homepage tabs
// We'll derive the active tab from location.hash as best-effort.
const hash = (location.hash || "").replace(/^#/, "");
const slug = normalize(hash) || "glance";
document.body.classList.remove(...tabClasses);
if (slug.includes("pncharris")) document.body.classList.add("tab-pncharris");
else if (slug.includes("netgrimoire")) document.body.classList.add("tab-netgrimoire");
else if (slug.includes("wasted") || slug.includes("bandwidth"))
document.body.classList.add("tab-wasted-bandwidth");
else document.body.classList.add("tab-glance");
}
window.addEventListener("hashchange", applyTabClass);
window.addEventListener("load", applyTabClass);
// Initial run
applyTabClass();
})();