function initPanelButton() { const panelButtonText = document.getElementById('panelButtonText'); if (!panelButtonText) return; panelButtonText.textContent = 'VOTRE PANEL'; panelButtonText.style.display = 'inline-block'; panelButtonText.style.textAlign = 'center'; } window.toggleLoginModal = function() { const modal = document.getElementById('loginModal'); if (!modal) return; if (modal.classList.contains('modal-show')) { modal.classList.remove('modal-show'); setTimeout(() => { modal.style.display = 'none'; }, 300); } else { modal.style.display = 'block'; setTimeout(() => { modal.classList.add('modal-show'); }, 10); } }; window.togglePanelModal = function() { const modal = document.getElementById('panelModal'); if (!modal) return; if (modal.classList.contains('modal-show')) { modal.classList.remove('modal-show'); setTimeout(() => { modal.style.display = 'none'; }, 300); } else { const loginBox = document.getElementById('login-box'); const panelContent = document.getElementById('panel-content'); if (loginBox && panelContent) { panelContent.innerHTML = ''; const loginBoxClone = loginBox.cloneNode(true); loginBoxClone.style.display = 'block'; panelContent.appendChild(loginBoxClone); } modal.style.display = 'block'; setTimeout(() => { modal.classList.add('modal-show'); }, 10); } }; function initStickyMenu() { const header = document.querySelector('.header'); const headerOuter = document.querySelector('.header-outer'); if (!header || !headerOuter) return; const originalOffsetTop = headerOuter.offsetTop; function handleScroll() { if (window.pageYOffset > originalOffsetTop + 100) { headerOuter.style.position = 'fixed'; headerOuter.style.top = '0'; headerOuter.style.left = '0'; headerOuter.style.right = '0'; headerOuter.style.width = '100%'; headerOuter.style.zIndex = '99999'; headerOuter.style.backgroundColor = 'rgba(34, 34, 34, 0.98)'; headerOuter.style.backdropFilter = 'blur(10px)'; headerOuter.style.transition = 'all 0.3s ease'; headerOuter.style.boxShadow = '0 2px 15px rgba(0,0,0,0.5)'; headerOuter.style.borderBottom = '1px solid rgba(244, 134, 37, 0.3)'; header.style.position = 'relative'; header.style.zIndex = '99999'; header.style.backgroundColor = 'transparent'; document.body.style.paddingTop = (header.offsetHeight + 10) + 'px'; headerOuter.classList.add('is-sticky'); } else { headerOuter.style.position = 'static'; headerOuter.style.backgroundColor = ''; headerOuter.style.backdropFilter = ''; headerOuter.style.boxShadow = ''; headerOuter.style.borderBottom = ''; headerOuter.style.width = ''; header.style.backgroundColor = ''; document.body.style.paddingTop = '0'; headerOuter.classList.remove('is-sticky'); } } window.addEventListener('scroll', handleScroll); } function goToCustomYear() { const yearInput = document.getElementById('customYearInput'); const year = yearInput.value.trim(); if (year && year.length === 4 && year >= 1900 && year <= 2030) { const btn = document.querySelector('.year-go-btn'); const originalContent = btn.innerHTML; btn.innerHTML = ''; btn.style.background = 'linear-gradient(45deg, #666, #999)'; setTimeout(() => { window.location.href = `/xfsearch/date-de-sortie/${year}/`; }, 300); } else { const input = yearInput; input.style.borderColor = '#ff4444'; input.style.boxShadow = '0 0 8px rgba(255, 68, 68, 0.5)'; input.placeholder = 'Année invalide !'; input.style.animation = 'shake 0.5s ease-in-out'; setTimeout(() => { input.style.borderColor = 'rgba(244, 134, 37, 0.3)'; input.style.boxShadow = 'none'; input.placeholder = 'Ex: 1995'; input.style.animation = ''; }, 2000); } } const yearInput = document.getElementById('customYearInput'); if (yearInput) { yearInput.addEventListener('click', function(e) { e.stopPropagation(); }); yearInput.addEventListener('focus', function(e) { e.stopPropagation(); }); } function setActiveButton(buttonId) { var allButtons = document.querySelectorAll('.filter-option'); for (var i = 0; i < allButtons.length; i++) { allButtons[i].classList.remove('active'); allButtons[i].style.border = 'none'; allButtons[i].style.background = 'linear-gradient(145deg, #2c2c2c, #242424)'; allButtons[i].style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.3)'; } var activeButton = document.getElementById(buttonId); if (activeButton) { activeButton.classList.add('active'); activeButton.style.border = '2px solid #FF8C00'; activeButton.style.background = 'linear-gradient(145deg, #3a3a3a, #444444)'; activeButton.style.boxShadow = 'inset 0 2px 5px rgba(0, 0, 0, 0.3)'; } var filterType; if (buttonId === 'showFilms') { filterType = 'film'; } else if (buttonId === 'showSeries') { filterType = 'serie'; } else { filterType = 'all'; } filterContent(filterType); } function filterContent(type) { console.log("Filtrage par:", type); var films = document.querySelectorAll('.film-item'); var series = document.querySelectorAll('.serie-item'); if (type === 'film') { showElements(films); hideElements(series); } else if (type === 'serie') { hideElements(films); showElements(series); } else { showElements(films); showElements(series); } } function showElements(elements) { for (var i = 0; i < elements.length; i++) { elements[i].style.display = 'block'; } } function hideElements(elements) { for (var i = 0; i < elements.length; i++) { elements[i].style.display = 'none'; } } document.addEventListener('DOMContentLoaded', function() { initPanelButton(); initStickyMenu(); document.addEventListener('click', function(e) { if (e.target.id === 'buttonText' || e.target.id === 'loginButtonContainer' || e.target.closest('#loginButtonContainer')) { e.preventDefault(); e.stopPropagation(); toggleLoginModal(); return; } }); const menuItems = document.querySelectorAll('.nav-menu > li.submenu'); menuItems.forEach(item => { const link = item.querySelector('a'); const hiddenMenu = item.querySelector('.hidden-menu'); if (link && hiddenMenu) { link.addEventListener('click', function(e) { e.preventDefault(); e.stopPropagation(); menuItems.forEach(otherItem => { if (otherItem !== item) { const otherMenu = otherItem.querySelector('.hidden-menu'); if (otherMenu) { otherMenu.style.display = 'none'; } otherItem.classList.remove('active'); } }); if (hiddenMenu.style.display === 'block') { hiddenMenu.style.display = 'none'; item.classList.remove('active'); } else { hiddenMenu.style.display = 'block'; item.classList.add('active'); } }); } }); const yearInput = document.getElementById('customYearInput'); if (yearInput) { yearInput.addEventListener('keypress', function(e) { if (e.key === 'Enter') { goToCustomYear(); } }); yearInput.addEventListener('focus', function() { this.select(); }); yearInput.addEventListener('input', function(e) { const year = this.value; if (year.length === 4 && year >= 1900 && year <= 2030) { this.style.borderColor = '#4CAF50'; this.style.boxShadow = '0 0 8px rgba(76, 175, 80, 0.3)'; } else if (year.length > 0) { this.style.borderColor = '#ff9800'; this.style.boxShadow = '0 0 8px rgba(255, 152, 0, 0.3)'; } else { this.style.borderColor = 'rgba(244, 134, 37, 0.3)'; this.style.boxShadow = 'none'; } }); } setTimeout(function() { if (document.getElementById('showAll')) { setActiveButton('showAll'); } }, 100); var fiches = document.querySelectorAll(".short"); fiches.forEach(function(fiche) { var isSerie = false; var isFilm = false; var badges = fiche.querySelectorAll(".badge"); badges.forEach(function(badge) { var badgeText = badge.textContent.toLowerCase(); if (badgeText.includes("saison") || badgeText.match(/\d+/)) { isSerie = true; } if (badgeText.includes("film") || badgeText.includes("vostfr")) { isFilm = true; } }); var links = fiche.querySelectorAll("a"); links.forEach(function(link) { var href = link.getAttribute("href").toLowerCase(); if (href.includes("saison") || href.includes("episode")) { isSerie = true; } if (href.includes("film")) { isFilm = true; } }); if (isSerie) { fiche.classList.add("serie"); } else if (isFilm) { fiche.classList.add("film"); } }); document.addEventListener('click', function(e) { if (!e.target.closest('.nav-menu') && !e.target.closest('.button') && !e.target.closest('[onclick*="toggle"]') && !e.target.closest('.year-input') && !e.target.closest('.year-go-btn') && !e.target.closest('.year-custom-selector') && !e.target.closest('.menu-subsection') && !e.target.closest('#customYearInput')) { menuItems.forEach(item => { const hiddenMenu = item.querySelector('.hidden-menu'); if (hiddenMenu) { hiddenMenu.style.display = 'none'; } item.classList.remove('active'); }); } }); window.addEventListener('click', function(event) { const loginModal = document.getElementById('loginModal'); const panelModal = document.getElementById('panelModal'); if (loginModal && event.target === loginModal) { toggleLoginModal(); } if (panelModal && event.target === panelModal) { togglePanelModal(); } }); }); document.addEventListener('DOMContentLoaded', function() { const closeAdBtn = document.getElementById('close-ad'); if (closeAdBtn) { closeAdBtn.addEventListener('click', function() { document.getElementById('ad-banner').style.display = 'none'; }); } });