diff --git a/pkg/service/handlers/web/js/script.js b/pkg/service/handlers/web/js/script.js index 02abeef..a945ecd 100644 --- a/pkg/service/handlers/web/js/script.js +++ b/pkg/service/handlers/web/js/script.js @@ -509,6 +509,7 @@ function openTab(evt, tabId) { if (evt) { evt.currentTarget.className += " active"; + history.pushState(null, '', '#' + tabId); } else { // Find the button that corresponds to the tabId and activate it for (let i = 0; i < tablinks.length; i++) { @@ -521,6 +522,13 @@ function openTab(evt, tabId) { } } +window.addEventListener('popstate', function() { + const tabId = window.location.hash.slice(1); + if (tabId && document.getElementById(tabId)) { + openTab(null, tabId); + } +}); + function getDeviceDisplayName(deviceId) { if (!deviceId) return "Unknown Device"; @@ -1555,6 +1563,11 @@ document.addEventListener("DOMContentLoaded", () => { triggerDiscovery(); fetchVersion(); + const hash = window.location.hash.slice(1); + if (hash && document.getElementById(hash)) { + openTab(null, hash); + } + const syncBtn = document.getElementById("sync-now-btn"); if (syncBtn) syncBtn.onclick = startSync; });