app.js 965 Bytes
// U-008: empty-shell client-side router. Hash-based (no History API / server
// catch-all needed) -- real page content is PH3 (U-022+), this just proves
// navigation swaps content without a page reload or any build step.

const routes = {
  "#/": () => "<h1>Dashboard</h1><p>placeholder -- real content is PH3 (v_dashboard, U-025)</p>",
  "#/tasks": () => "<h1>Tasks</h1><p>placeholder -- real content is PH3 (v_task_board, U-025)</p>",
  "#/settings": () => "<h1>Settings</h1><p>placeholder -- real content is PH3 (U-030)</p>",
};

function render() {
  const hash = window.location.hash || "#/";
  const view = routes[hash] || (() => "<h1>Not found</h1><p>" + hash + "</p>");
  document.getElementById("app").innerHTML = view();

  for (const a of document.querySelectorAll("#nav a")) {
    a.classList.toggle("active", a.getAttribute("href") === hash);
  }
}

window.addEventListener("hashchange", render);
window.addEventListener("DOMContentLoaded", render);