step 9.4: done
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user