Files
Catalyst/js/app.js
josh d7d4bbc099
All checks were successful
Build / test (push) Successful in 9m28s
Build / release (push) Successful in 1s
Build / build (push) Successful in 18s
fixes version not showing up in web ui
2026-03-28 02:08:58 -04:00

46 lines
1.7 KiB
JavaScript

// ── Router ────────────────────────────────────────────────────────────────────
function navigate(page, vmid) {
document.querySelectorAll('.page').forEach(p => p.classList.remove('active'));
if (page === 'dashboard') {
document.getElementById('page-dashboard').classList.add('active');
history.pushState({ page: 'dashboard' }, '', '/');
renderDashboard();
} else if (page === 'instance') {
document.getElementById('page-detail').classList.add('active');
history.pushState({ page: 'instance', vmid }, '', `/instance/${vmid}`);
renderDetailPage(vmid);
}
}
function handleRoute() {
const m = window.location.pathname.match(/^\/instance\/(\d+)/);
if (m) {
document.getElementById('page-detail').classList.add('active');
renderDetailPage(parseInt(m[1], 10));
} else {
document.getElementById('page-dashboard').classList.add('active');
}
}
window.addEventListener('popstate', e => {
document.querySelectorAll('.page').forEach(p => p.classList.remove('active'));
if (e.state?.page === 'instance') {
document.getElementById('page-detail').classList.add('active');
renderDetailPage(e.state.vmid);
} else {
document.getElementById('page-dashboard').classList.add('active');
renderDashboard();
}
});
// ── Bootstrap ─────────────────────────────────────────────────────────────────
if (VERSION) document.getElementById('nav-version').textContent = `v${VERSION}`;
initDB().then(() => {
renderDashboard();
handleRoute();
});