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
+8 -12
View File
@@ -228,9 +228,6 @@ function switchTab(tabName) {
} else if (tabType === 'providers' && tabName === 'providers') {
// Static providers tab
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-', '')) {
btn.classList.add('active');
} else if (tabType === 'series' && btn.getAttribute('data-provider') === tabName.replace('series-', '')) {
@@ -245,18 +242,19 @@ function switchTab(tabName) {
loadHomeContent();
}
}
}
// Handle URL hash on page load
if (window.location.hash) {
const hash = window.location.hash.substring(1);
if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') {
switchTab(hash);
}
// Handle URL hash on page load
if (window.location.hash) {
const hash = window.location.hash.substring(1);
if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') {
switchTab(hash);
}
}
// Listen for hash changes
window.addEventListener('hashchange', () => {
window.addEventListener('hashchange', function() {
if (window.location.hash) {
const hash = window.location.hash.substring(1);
if (hash === 'watchlist' || hash === 'anime' || hash === 'series' || hash === 'providers') {
@@ -264,5 +262,3 @@ window.addEventListener('hashchange', () => {
}
}
});
}
}