point rouge carte node projet

This commit is contained in:
2025-11-24 15:16:07 +01:00
parent cfa90f9bcb
commit 3f2eb70271
2 changed files with 27 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ const isHomePage = document.querySelector('main#home') !== null;
const isLessitesPage = document.querySelector('div#lessites') !== null;
const isNodeTypeSitePage = document.body.classList.contains('node-type-site');
const isCandidaturePage = document.querySelector('main#pour_candidater') !== null;
const isNodeTypeProjetPage = document.body.classList.contains('node-type-projet');
// Identifier le cercle de la page courante pour node-type-site
let currentPageCircle = null;
@@ -26,6 +27,31 @@ if (isNodeTypeSitePage) {
}
}
// Identifier le cercle du SITE lié quand on est sur une page node-type-projet
if (isNodeTypeProjetPage && svgElement) {
// On récupère le lien vers le site lié dans le bloc "Site lié"
const linkedSiteLink = document.querySelector('.field_field_site_projet article.node-type-site a[href*="/sites/"]');
if (linkedSiteLink) {
// On normalise le chemin (sans domaine) de l'URL du site
const sitePath = new URL(linkedSiteLink.getAttribute('href'), window.location.origin).pathname;
// On cherche le cercle dont le data-url pointe vers le même site
const correspondingCircle = Array.from(svgElement.querySelectorAll('circle.site-link')).find(circle => {
const circleUrl = circle.getAttribute('data-url');
if (!circleUrl) return false;
const circlePath = new URL(circleUrl, window.location.origin).pathname;
return circlePath === sitePath;
});
if (correspondingCircle) {
currentPageCircle = correspondingCircle;
currentPageCircle.setAttribute('fill', 'red'); // Met en rouge le cercle du site lié
}
}
}
// Fonction pour afficher le popup
function showPopup(content) {