This commit is contained in:
traveler 2025-12-23 15:37:09 -06:00
parent fb2883c8ff
commit aeaab4780c
2 changed files with 14 additions and 27 deletions

View file

@ -1,6 +1,5 @@
/* custom.css */ /* custom.css */
/* Make background cover nicely */
body { body {
background-size: cover !important; background-size: cover !important;
background-position: center center !important; background-position: center center !important;
@ -13,7 +12,7 @@ body {
} }
body.tab-pncharris { body.tab-pncharris {
background-image: url("pncharris-bg.png") !important; background-image: url("/images/pncharris-bg.png") !important;
} }
body.tab-netgrimoire { body.tab-netgrimoire {
@ -21,6 +20,6 @@ body {
} }
body.tab-wasted-bandwidth { body.tab-wasted-bandwidth {
background-image: url("/images/bg-wasted.jpg") !important; background-image: url("/images/bg-wasted-bandwidth.jpg") !important;
} }

View file

@ -1,38 +1,26 @@
// custom.js // custom.js
(function () { (() => {
const tabClasses = [ const TAB_CLASS_PREFIX = "tab-";
"tab-glance", const knownTabs = new Set(["glance", "pncharris", "netgrimoire", "wasted-bandwidth"]);
"tab-pncharris",
"tab-netgrimoire",
"tab-wasted-bandwidth",
];
function normalize(s) { function clearTabClasses() {
return (s || "") document.body.classList.forEach((c) => {
.toLowerCase() if (c.startsWith(TAB_CLASS_PREFIX)) document.body.classList.remove(c);
.replace(/[^a-z0-9]+/g, "-") });
.replace(/(^-|-$)/g, "");
} }
function applyTabClass() { function applyTabClass() {
// Tabs commonly appear in the URL hash with Homepage tabs // Your URLs look like: https://homepage.netgrimoire.com/#pncharris
// We'll derive the active tab from location.hash as best-effort. const hash = (window.location.hash || "").replace(/^#/, "").trim().toLowerCase();
const hash = (location.hash || "").replace(/^#/, ""); const tab = knownTabs.has(hash) ? hash : "glance";
const slug = normalize(hash) || "glance";
document.body.classList.remove(...tabClasses); clearTabClasses();
document.body.classList.add(`${TAB_CLASS_PREFIX}${tab}`);
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("hashchange", applyTabClass);
window.addEventListener("load", applyTabClass); window.addEventListener("load", applyTabClass);
// Initial run
applyTabClass(); applyTabClass();
})(); })();