fix: add URL hash handling for tab navigation

This commit is contained in:
root
2026-02-27 09:10:26 +00:00
parent 7eef8aaff1
commit e3135c99cb
+9 -13
View File
@@ -228,9 +228,6 @@ function switchTab(tabName) {
} else if (tabType === 'providers' && tabName === 'providers') { } else if (tabType === 'providers' && tabName === 'providers') {
// Static providers tab // Static providers tab
btn.classList.add('active'); btn.classList.add('active');
} else if (tabType === 'watchlist' && tabName === 'watchlist') {
// Static watchlist tab
btn.classList.add('active');
} else if (tabType === 'anime' && btn.getAttribute('data-provider') === tabName.replace('anime-', '')) { } else if (tabType === 'anime' && btn.getAttribute('data-provider') === tabName.replace('anime-', '')) {
btn.classList.add('active'); btn.classList.add('active');
} else if (tabType === 'series' && btn.getAttribute('data-provider') === tabName.replace('series-', '')) { } else if (tabType === 'series' && btn.getAttribute('data-provider') === tabName.replace('series-', '')) {
@@ -245,24 +242,23 @@ function switchTab(tabName) {
loadHomeContent(); loadHomeContent();
} }
} }
}
// Handle URL hash on page load
if (window.location.hash) { // Handle URL hash on page load
const hash = window.location.hash.substring(1); if (window.location.hash) {
if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') { const hash = window.location.hash.substring(1);
switchTab(hash); if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') {
} switchTab(hash);
} }
} }
// Listen for hash changes // Listen for hash changes
window.addEventListener('hashchange', () => { window.addEventListener('hashchange', function() {
if (window.location.hash) { if (window.location.hash) {
const hash = window.location.hash.substring(1); const hash = window.location.hash.substring(1);
if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') { if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') {
switchTab(hash); switchTab(hash);
} }
} }
}); });
}
}