Files
storyforge/web/storyforge-web-v4/assets/app.js
2026-03-22 10:39:53 +08:00

25 lines
708 B
JavaScript

const navButtons = document.querySelectorAll("[data-screen-target]");
const screens = document.querySelectorAll("[data-screen]");
function activateScreen(id) {
navButtons.forEach((button) => {
const active = button.dataset.screenTarget === id;
button.classList.toggle("is-active", active);
});
screens.forEach((screen) => {
screen.classList.toggle("is-active", screen.dataset.screen === id);
});
}
navButtons.forEach((button) => {
button.addEventListener("click", () => {
const next = button.dataset.screenTarget;
activateScreen(next);
window.location.hash = next;
});
});
const initial = window.location.hash.replace("#", "") || "dashboard";
activateScreen(initial);