Ajout du script stratégie dans public/ pour chargement par le framework
- Script déplacé dans public/strategie-script.js - Config mise à jour pour charger ce fichier - Le script intercepte les clics pour éviter le 404
This commit is contained in:
89
public/strategie-script.js
Normal file
89
public/strategie-script.js
Normal file
@@ -0,0 +1,89 @@
|
||||
// Script pour la stratégie - version inline pour injection directe
|
||||
(function() {
|
||||
function initStrategyLinks() {
|
||||
addStrategyLinkToFooter();
|
||||
interceptStrategyLinks();
|
||||
handleStrategyRoute();
|
||||
}
|
||||
|
||||
function handleStrategyRoute() {
|
||||
if (window.location.pathname === '/business/strategie' || window.location.pathname === '/business/strategie.html' || window.location.hash === '#strategie') {
|
||||
createStrategyPage();
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
if (!window.originalBodyContent) {
|
||||
window.originalBodyContent = 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; min-height: 100vh;"><div style="background: white; padding: 40px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);"><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><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>';
|
||||
|
||||
const backLink = document.getElementById('back-to-radar');
|
||||
if (backLink) {
|
||||
backLink.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
if (window.originalBodyContent) {
|
||||
document.body.innerHTML = window.originalBodyContent;
|
||||
setTimeout(initStrategyLinks, 100);
|
||||
} else {
|
||||
window.location.href = '/business/';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.history.pushState({page: 'strategie'}, 'Stratégie', '/business/strategie');
|
||||
}
|
||||
|
||||
function addStrategyLinkToFooter() {
|
||||
const footer = document.querySelector('footer') || document.querySelector('.footer') || document.querySelector('[class*="footer"]');
|
||||
if (footer) {
|
||||
if (footer.querySelector('#strategie-link') || footer.querySelector('a[href*="strategie"]')) {
|
||||
return;
|
||||
}
|
||||
const strategyLink = document.createElement('a');
|
||||
strategyLink.id = 'strategie-link';
|
||||
strategyLink.href = '#strategie';
|
||||
strategyLink.textContent = '📋 Voir la Stratégie';
|
||||
strategyLink.style.marginLeft = '10px';
|
||||
strategyLink.style.color = '#2ecc71';
|
||||
strategyLink.style.textDecoration = 'none';
|
||||
strategyLink.style.fontWeight = 'bold';
|
||||
strategyLink.style.display = 'inline-block';
|
||||
strategyLink.style.cursor = 'pointer';
|
||||
strategyLink.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
createStrategyPage();
|
||||
});
|
||||
footer.appendChild(strategyLink);
|
||||
} else {
|
||||
setTimeout(addStrategyLinkToFooter, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('popstate', function(event) {
|
||||
if (window.originalBodyContent && !event.state) {
|
||||
document.body.innerHTML = window.originalBodyContent;
|
||||
setTimeout(initStrategyLinks, 100);
|
||||
}
|
||||
});
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initStrategyLinks);
|
||||
} else {
|
||||
initStrategyLinks();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"baseUrl": "",
|
||||
"editUrl": "https://git.open.us.org/syoul/TechradarDev/_edit/main/radar-business/{release}/{id}.md",
|
||||
"logoFile": "logo.svg",
|
||||
"jsFile": "strategie-link.js",
|
||||
"jsFile": "strategie-script.js",
|
||||
"toggles": {
|
||||
"showChart": true,
|
||||
"showTagFilter": true,
|
||||
|
||||
Reference in New Issue
Block a user