feat(web): add hash-based tab navigation for back-button and reload support

This commit is contained in:
Marcin Mennemann
2026-05-18 22:21:28 +02:00
committed by Tobias Gesellchen
parent f1821d5995
commit b26c5627ee
+13
View File
@@ -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;
});