From b26c5627eefc8893ce0b9430dc80e25891fee3b4 Mon Sep 17 00:00:00 2001 From: Marcin Mennemann Date: Sun, 17 May 2026 22:33:16 +0200 Subject: [PATCH] feat(web): add hash-based tab navigation for back-button and reload support --- pkg/service/handlers/web/js/script.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; });