homepage/config/custom.js
traveler dca3d1963c df
2026-04-29 12:01:18 -05:00

26 lines
No EOL
916 B
JavaScript
Executable file

// custom.js
(() => {
const TAB_CLASS_PREFIX = "tab-";
const knownTabs = new Set(["glance", "netgrimoire", "codex", "watch", "ward", "vault", "shadow", "pncfish", "green", "pocket","wasted-bandwidth", "pncharris", "nucking-futz"]);
function clearTabClasses() {
document.body.classList.forEach((c) => {
if (c.startsWith(TAB_CLASS_PREFIX)) document.body.classList.remove(c);
});
}
function applyTabClass() {
// Your URLs look like: https://homepage.netgrimoire.com/#pncharris
const hash = (window.location.hash || "").replace(/^#/, "").trim().toLowerCase();
const tab = knownTabs.has(hash) ? hash : "glance";
clearTabClasses();
document.body.classList.add(`${TAB_CLASS_PREFIX}${tab}`);
}
window.addEventListener("hashchange", applyTabClass);
window.addEventListener("load", applyTabClass);
applyTabClass();
})();