18 lines
631 B
JavaScript
18 lines
631 B
JavaScript
// Command Center SPA Router
|
|
const sections = document.querySelectorAll('.panel');
|
|
const links = document.querySelectorAll('.nav-links a');
|
|
|
|
function navigate(hash) {
|
|
const target = hash.replace('#', '') || 'agents';
|
|
sections.forEach(s => s.hidden = s.id !== target);
|
|
links.forEach(l => l.classList.toggle('active', l.getAttribute('href') === '#' + target));
|
|
}
|
|
|
|
links.forEach(l => l.addEventListener('click', e => {
|
|
e.preventDefault();
|
|
window.location.hash = l.getAttribute('href');
|
|
}));
|
|
|
|
window.addEventListener('hashchange', () => navigate(window.location.hash));
|
|
navigate(window.location.hash || '#agents');
|