hold current settings tab in webUI URL

This commit is contained in:
2026-02-28 16:41:15 -08:00
parent 7542eaf321
commit 09ac8b7fb0
3 changed files with 28 additions and 12 deletions

View File

@@ -113,14 +113,30 @@
<script src="/files/import.js"></script>
<script>
function switchToTab(tabName, updateUrl = true) {
document.querySelectorAll('.tab-button').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
document.querySelector(`.tab-button[data-tab="${tabName}"]`).classList.add('active');
document.getElementById(tabName).classList.add('active');
if (updateUrl) {
const url = new URL(window.location);
url.searchParams.set('tab', tabName);
history.pushState({}, '', url);
}
}
document.querySelectorAll('.tab-button').forEach(button => {
button.addEventListener('click', () => {
document.querySelectorAll('.tab-button').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
button.classList.add('active');
document.getElementById(button.dataset.tab).classList.add('active');
switchToTab(button.dataset.tab);
});
});
const urlParams = new URLSearchParams(window.location.search);
const tabParam = urlParams.get('tab');
if (tabParam) {
switchToTab(tabParam, false);
}
</script>
{{end}}