step 9.4: done

This commit is contained in:
bepis
2026-10-21 10:35:29 +11:00
parent cf725b40a2
commit 0b89b8f685
5 changed files with 141 additions and 47 deletions
+30
View File
@@ -21,6 +21,36 @@ function switchTab(tab) {
document.getElementById('inventory-tab').style.display = tab === 'inventory' ? '' : 'none';
}
/**
* Sync mobile bottom nav active state with desktop tabs.
*/
function syncMobileNav() {
const mobileNav = document.querySelector('.mobile-bottom-nav');
if (!mobileNav) return;
mobileNav.querySelectorAll('.tab').forEach((t) => {
const isActive = t.dataset.tab === currentTab;
t.classList.toggle('active', isActive);
t.setAttribute('aria-selected', isActive);
});
}
/**
* Attach mobile bottom-nav click handlers.
*/
function initMobileNav() {
const mobileNav = document.querySelector('.mobile-bottom-nav');
if (!mobileNav) return;
mobileNav.querySelectorAll('.tab').forEach((btn) => {
btn.addEventListener('click', () => {
switchTab(btn.dataset.tab);
});
});
}
document.addEventListener('DOMContentLoaded', () => {
initMobileNav();
});
/**
* Refresh energy state from the server at a fixed interval.
* Keeps client-side countdown in sync with the authoritative server.