mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-24 14:47:23 +00:00
feat(web): add hash-based tab navigation for back-button and reload support
This commit is contained in:
committed by
Tobias Gesellchen
parent
f1821d5995
commit
b26c5627ee
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user