diff --git a/public/strategie-script.js b/public/strategie-script.js index af0f340..736f6d6 100644 --- a/public/strategie-script.js +++ b/public/strategie-script.js @@ -1,32 +1,10 @@ // Script pour la gestion des pages de stratégie (function() { - // VÉRIFICATION IMMÉDIATE DE /team AVANT TOUT (s'exécute en premier) - (function checkTeamRouteFirst() { - if (typeof window === 'undefined') return; - function normalizePath(pathname) { - if (!pathname) return '/'; - const cleaned = pathname.replace(/\/+$/, ''); - return cleaned === '' ? '/' : cleaned; - } - const path = normalizePath(window.location.pathname); - if (path === '/team' || path === '/team/') { - console.log('🔍 Route /team détectée IMMÉDIATEMENT, redirection vers /team.html...'); - // Rediriger immédiatement vers /team.html - if (document.body) { - document.body.innerHTML = '
'; - window.history.pushState({page: 'team'}, 'Équipe & Technologies', '/team'); - } else { - const checkBody = setInterval(() => { - if (document.body) { - clearInterval(checkBody); - document.body.innerHTML = ''; - window.history.pushState({page: 'team'}, 'Équipe & Technologies', '/team'); - } - }, 10); - setTimeout(() => clearInterval(checkBody), 5000); - } - } - })(); + // PROTECTION : Ne pas s'exécuter sur les pages Next.js (qui ont déjà leur propre gestion) + if (document.querySelector('[data-reactroot]') || window.__NEXT_DATA__) { + console.log('🚫 Script stratégie désactivé sur page Next.js'); + return; + } // Protection contre Fast Refresh : ignorer les tentatives de hot-reload // Intercepter et ignorer les requêtes webpack hot-update pour éviter les rechargements en boucle @@ -832,13 +810,13 @@ Interface de pilotage pour les responsables sécurité des PME. function handleRoute() { const path = normalizePath(window.location.pathname); const hash = window.location.hash; - - // Détection simple + + // Détection simple - SANS /team car Next.js gère cette route if (hash === '#strategie' || path === '/strategie') showPage('strategie'); else if (hash === '#business' || path === '/business') showPage('business'); else if (hash === '#dataviz' || path === '/dataviz') showPage('dataviz'); else if (hash === '#dataviz-details' || path === '/dataviz-details') showPage('dataviz-details'); - else if (path === '/team' || path === '/team/') showTeamPage(); + // /team est maintenant géré par Next.js, pas par ce script } // Vérifier la route /team IMMÉDIATEMENT au chargement du script (avant Next.js) @@ -855,26 +833,10 @@ Interface de pilotage pour les responsables sécurité des PME. } })(); - function showTeamPage() { - // Sauvegarder le contenu original - if (!window.originalBodyContent) { - window.originalBodyContent = document.body.innerHTML; - } - - // Remplacer complètement le body par l'iframe team.html - document.body.innerHTML = ` - - `; - - // Mettre à jour l'URL sans recharger la page - window.history.pushState({page: 'team'}, 'Équipe & Technologies', '/team'); - } + // FONCTION DÉSACTIVÉE: showTeamPage() - Next.js gère maintenant la page /team + // function showTeamPage() { + // // Cette fonction n'est plus nécessaire car Next.js charge directement l'iframe + // } function showPage(pageId) { if (!pagesContent[pageId]) return; @@ -975,11 +937,12 @@ Interface de pilotage pour les responsables sécurité des PME. window.addEventListener('popstate', function(event) { if (event.state && event.state.page) { - if (event.state.page === 'team') { - showTeamPage(); - } else { + // DÉSACTIVÉ: Gestion du popstate pour /team - Next.js gère cette route + // if (event.state.page === 'team') { + // showTeamPage(); + // } else { showPage(event.state.page); - } + // } } else if (window.originalBodyContent) { document.body.innerHTML = window.originalBodyContent; // Réinitialiser le flag pour permettre la réinitialisation @@ -997,47 +960,8 @@ Interface de pilotage pour les responsables sécurité des PME. } window.__strategieScriptLoaded = true; - // Vérifier la route /team IMMÉDIATEMENT au chargement (avant tout le reste) - (function checkTeamRouteImmediately() { - function normalizePath(pathname) { - if (!pathname) return '/'; - const cleaned = pathname.replace(/\/+$/, ''); - return cleaned === '' ? '/' : cleaned; - } - const path = normalizePath(window.location.pathname); - if (path === '/team' || path === '/team/') { - console.log('🔍 Route /team détectée immédiatement, affichage...'); - // Attendre que le body soit disponible - if (document.body) { - showTeamPage(); - } else { - const checkBody = setInterval(() => { - if (document.body) { - clearInterval(checkBody); - showTeamPage(); - } - }, 10); - // Timeout de sécurité - setTimeout(() => clearInterval(checkBody), 5000); - } - } - })(); - - // Intercepter les clics sur les liens /team AVANT que Next.js ne les gère - document.addEventListener('click', function(e) { - const link = e.target.closest('a'); - if (link) { - const href = link.getAttribute('href') || link.href; - if (href && (href.includes('/team') || href === '/team' || href === '/team/' || href === '/team.html')) { - e.preventDefault(); - e.stopPropagation(); - e.stopImmediatePropagation(); - console.log('🛑 Clic sur lien /team intercepté, affichage de la page équipe...'); - showTeamPage(); - return false; - } - } - }, true); // Capture phase pour intercepter avant Next.js + // DÉSACTIVÉ: Interception des clics /team - Next.js gère maintenant cette navigation + // Plus besoin d'intercepter les clics car Next.js route vers /team correctement // Éviter de modifier document.documentElement qui peut déclencher des rechargements Fast Refresh // Utiliser MutationObserver pour détecter quand le header est ajouté