diff --git a/static/css/style.css b/static/css/style.css index 1dd4524..dbb8290 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -172,7 +172,7 @@ } .tab-content { - display: none; + /* Managed by Alpine.js x-show */ } .tab-content.active { diff --git a/static/js/auth.js b/static/js/auth.js index 6f0342d..3e0a0db 100644 --- a/static/js/auth.js +++ b/static/js/auth.js @@ -91,14 +91,27 @@ async function checkAuth() { if (response.ok) { const data = await response.json(); - + + // Log for debugging + console.log('Auth check successful for:', data.user.username); + // Dispatch event for Alpine.js global state window.dispatchEvent(new CustomEvent('auth-success', { detail: { username: data.user.full_name || data.user.username } })); - + + // Set global auth state in case dispatch was too early + if (window.Alpine) { + const body = document.querySelector('body'); + if (body && body.__x) { + body.__x.$data.isAuthenticated = true; + body.__x.$data.username = data.user.full_name || data.user.username; + } + } + return true; - } else { + } + else { // Token invalid, remove it and redirect removeToken(); redirectToLogin(); diff --git a/static/js/main.js b/static/js/main.js index 14d8cef..7865802 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -195,63 +195,11 @@ async function handleDownloadProviderEpisode(providerId) { } /** - * Switch between tabs + * Switch between tabs (Modernized to Alpine.js) */ function switchTab(tabName) { - // Hide all tabs - document.querySelectorAll('.tab-content').forEach(tab => { - tab.classList.remove('active'); - }); - document.querySelectorAll('.tab').forEach(btn => { - btn.classList.remove('active'); - }); - - // Show selected tab - const tabElement = document.getElementById(`tab-${tabName}`); - if (tabElement) { - tabElement.classList.add('active'); - } - - // Find and activate the button - const buttons = document.querySelectorAll('.tab'); - buttons.forEach(btn => { - const tabType = btn.getAttribute('data-tab-type'); - - if (tabType === 'home' && tabName === 'home') { - btn.classList.add('active'); - } else if (tabType === 'anime' && tabName === 'anime') { - // Static anime tab - btn.classList.add('active'); - } else if (tabType === 'series' && tabName === 'series') { - // Static series tab - btn.classList.add('active'); - } else if (tabType === 'providers' && tabName === 'providers') { - // Static providers 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-', '')) { - btn.classList.add('active'); - } - }); - - // Load home content when switching to home tab - if (tabName === 'home') { - // Content is already loaded on init, but you can reload if needed - if (typeof loadHomeContent === 'function' && !document.getElementById('recommendationsList').hasChildNodes()) { - loadHomeContent(); - } - } - - // Load watchlist content when switching to watchlist tab - if (tabName === 'watchlist') { - if (typeof loadSchedulerStatus === 'function') { - loadSchedulerStatus(); - } - if (typeof displayWatchlist === 'function') { - displayWatchlist(); - } - } + console.log('Switching tab to:', tabName); + window.dispatchEvent(new CustomEvent('set-tab', { detail: { tab: tabName } })); } diff --git a/templates/base.html b/templates/base.html index 1ebfa6c..002cb85 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,7 +23,6 @@ - diff --git a/templates/components/header.html b/templates/components/header.html index 44d13ad..d2d6609 100644 --- a/templates/components/header.html +++ b/templates/components/header.html @@ -26,9 +26,8 @@
👋 Bienvenue! Connectez-vous pour télécharger des vidéos
- -