Correction : Interception des clics sur le lien stratégie pour éviter le 404
- Le script intercepte maintenant tous les clics sur les liens vers /business/strategie - La page est créée dynamiquement sans navigation (pas de 404) - Gestion du bouton retour du navigateur - Le lien dans le footer utilise maintenant un hash pour éviter la navigation
This commit is contained in:
70
custom.js
70
custom.js
@@ -2,20 +2,41 @@
|
|||||||
(function() {
|
(function() {
|
||||||
function initStrategyLinks() {
|
function initStrategyLinks() {
|
||||||
addStrategyLinkToFooter();
|
addStrategyLinkToFooter();
|
||||||
|
interceptStrategyLinks();
|
||||||
handleStrategyRoute();
|
handleStrategyRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleStrategyRoute() {
|
function handleStrategyRoute() {
|
||||||
if (window.location.pathname === '/business/strategie' || window.location.pathname === '/business/strategie.html') {
|
// Vérifier si on est sur la route stratégie au chargement initial
|
||||||
|
if (window.location.pathname === '/business/strategie' || window.location.pathname === '/business/strategie.html' || window.location.hash === '#strategie') {
|
||||||
createStrategyPage();
|
createStrategyPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Intercepter tous les clics sur les liens vers la stratégie
|
||||||
|
function interceptStrategyLinks() {
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
const link = e.target.closest('a');
|
||||||
|
if (link && (link.href.includes('/business/strategie') || link.getAttribute('href') === '/business/strategie' || link.id === 'strategie-link')) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
createStrategyPage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
function createStrategyPage() {
|
function createStrategyPage() {
|
||||||
|
// Sauvegarder le contenu original
|
||||||
|
if (!window.originalBodyContent) {
|
||||||
|
window.originalBodyContent = document.body.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer la page stratégie
|
||||||
document.body.innerHTML = `
|
document.body.innerHTML = `
|
||||||
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; background: #f5f5f5;">
|
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; background: #f5f5f5; min-height: 100vh;">
|
||||||
<div style="background: white; padding: 40px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
|
<div style="background: white; padding: 40px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
|
||||||
<a href="/business/" style="display: inline-block; margin-bottom: 20px; color: #2ecc71; text-decoration: none; font-weight: bold;">← Retour au Radar</a>
|
<a href="#" id="back-to-radar" style="display: inline-block; margin-bottom: 20px; color: #2ecc71; text-decoration: none; font-weight: bold; cursor: pointer;">← Retour au Radar</a>
|
||||||
<h1 style="color: #1a4d3a; border-bottom: 3px solid #2ecc71; padding-bottom: 10px;">Stratégie d'Évolution Technique - Laplank</h1>
|
<h1 style="color: #1a4d3a; border-bottom: 3px solid #2ecc71; padding-bottom: 10px;">Stratégie d'Évolution Technique - Laplank</h1>
|
||||||
<p><strong>Date de mise à jour</strong> : 02/12/2025</p>
|
<p><strong>Date de mise à jour</strong> : 02/12/2025</p>
|
||||||
<p>La stratégie complète est disponible dans le dépôt Git :</p>
|
<p>La stratégie complète est disponible dans le dépôt Git :</p>
|
||||||
@@ -23,25 +44,65 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
// Ajouter le gestionnaire de retour
|
||||||
|
const backLink = document.getElementById('back-to-radar');
|
||||||
|
if (backLink) {
|
||||||
|
backLink.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (window.originalBodyContent) {
|
||||||
|
document.body.innerHTML = window.originalBodyContent;
|
||||||
|
// Réinitialiser les liens après restauration
|
||||||
|
setTimeout(initStrategyLinks, 100);
|
||||||
|
} else {
|
||||||
|
window.location.href = '/business/';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mettre à jour l'URL sans recharger la page
|
||||||
|
window.history.pushState({page: 'strategie'}, 'Stratégie', '/business/strategie');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addStrategyLinkToFooter() {
|
function addStrategyLinkToFooter() {
|
||||||
const footer = document.querySelector('footer') || document.querySelector('.footer') || document.querySelector('[class*="footer"]');
|
const footer = document.querySelector('footer') || document.querySelector('.footer') || document.querySelector('[class*="footer"]');
|
||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
|
// Vérifier si le lien n'existe pas déjà
|
||||||
|
if (footer.querySelector('#strategie-link') || footer.querySelector('a[href*="strategie"]')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const strategyLink = document.createElement('a');
|
const strategyLink = document.createElement('a');
|
||||||
strategyLink.href = '/business/strategie';
|
strategyLink.id = 'strategie-link';
|
||||||
|
strategyLink.href = '#strategie';
|
||||||
strategyLink.textContent = '📋 Voir la Stratégie';
|
strategyLink.textContent = '📋 Voir la Stratégie';
|
||||||
strategyLink.style.marginLeft = '10px';
|
strategyLink.style.marginLeft = '10px';
|
||||||
strategyLink.style.color = '#2ecc71';
|
strategyLink.style.color = '#2ecc71';
|
||||||
strategyLink.style.textDecoration = 'none';
|
strategyLink.style.textDecoration = 'none';
|
||||||
strategyLink.style.fontWeight = 'bold';
|
strategyLink.style.fontWeight = 'bold';
|
||||||
strategyLink.style.display = 'inline-block';
|
strategyLink.style.display = 'inline-block';
|
||||||
|
strategyLink.style.cursor = 'pointer';
|
||||||
|
|
||||||
|
// Intercepter le clic
|
||||||
|
strategyLink.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
createStrategyPage();
|
||||||
|
});
|
||||||
|
|
||||||
footer.appendChild(strategyLink);
|
footer.appendChild(strategyLink);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(addStrategyLinkToFooter, 1000);
|
setTimeout(addStrategyLinkToFooter, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gérer le bouton retour du navigateur
|
||||||
|
window.addEventListener('popstate', function(event) {
|
||||||
|
if (window.originalBodyContent && !event.state) {
|
||||||
|
document.body.innerHTML = window.originalBodyContent;
|
||||||
|
setTimeout(initStrategyLinks, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
document.addEventListener('DOMContentLoaded', initStrategyLinks);
|
document.addEventListener('DOMContentLoaded', initStrategyLinks);
|
||||||
@@ -49,4 +110,3 @@
|
|||||||
initStrategyLinks();
|
initStrategyLinks();
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
"quadrantOverview": "Vue d'ensemble des quadrants",
|
"quadrantOverview": "Vue d'ensemble des quadrants",
|
||||||
"zoomIn": "Zoomer",
|
"zoomIn": "Zoomer",
|
||||||
"filterByTag": "Filtrer par tag",
|
"filterByTag": "Filtrer par tag",
|
||||||
"footer": "Radar stratégique pour analyser les technologies de l'écosystème Laplank et définir une stratégie d'évolution technique alignée avec les objectifs business. <a href=\"/business/strategie\" id=\"strategie-link\" style=\"margin-left: 10px; color: #2ecc71; text-decoration: none; font-weight: bold;\">📋 Voir la Stratégie</a><script>(function(){function a(){const e=document.querySelector('footer')||document.querySelector('.footer');if(e){const t=document.createElement('a');t.href='/business/strategie',t.textContent='📋 Voir la Stratégie',t.style.marginLeft='10px',t.style.color='#2ecc71',t.style.textDecoration='none',t.style.fontWeight='bold',t.style.display='inline-block',e.appendChild(t)}else setTimeout(a,1e3)}if(window.location.pathname==='/business/strategie'||window.location.pathname==='/business/strategie.html'){document.body.innerHTML='<div style=\"font-family: -apple-system, BlinkMacSystemFont, \\'Segoe UI\\', Roboto, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; background: #f5f5f5;\"><div style=\"background: white; padding: 40px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);\"><a href=\"/business/\" style=\"display: inline-block; margin-bottom: 20px; color: #2ecc71; text-decoration: none; font-weight: bold;\">← Retour au Radar</a><h1 style=\"color: #1a4d3a; border-bottom: 3px solid #2ecc71; padding-bottom: 10px;\">Stratégie d\\'Évolution Technique - Laplank</h1><p><strong>Date de mise à jour</strong> : 02/12/2025</p><p>La stratégie complète est disponible dans le dépôt Git :</p><p><a href=\"https://git.open.us.org/AJR/TechradarDev/-/blob/dev-biz/docs/strategie-evolution-technique.md\" target=\"_blank\" style=\"color: #2ecc71; font-weight: bold;\">📋 Voir la stratégie sur GitLab</a></p></div></div>'}document.readyState==='loading'?document.addEventListener('DOMContentLoaded',a):a()})();</script>",
|
"footer": "Radar stratégique pour analyser les technologies de l'écosystème Laplank et définir une stratégie d'évolution technique alignée avec les objectifs business.",
|
||||||
"notUpdated": "Cet élément n'a pas été mis à jour dans les trois dernières versions du Radar.",
|
"notUpdated": "Cet élément n'a pas été mis à jour dans les trois dernières versions du Radar.",
|
||||||
"notFound": "404 - Page non trouvée",
|
"notFound": "404 - Page non trouvée",
|
||||||
"pageAbout": "Comment utiliser le Radar Business ?",
|
"pageAbout": "Comment utiliser le Radar Business ?",
|
||||||
|
|||||||
Reference in New Issue
Block a user