1function updateHeader(nom, prenom) { 2 var compteLinkContainer = document.getElementById('header_compte'); 3 var compteLinkContainerMobile = document.getElementById('header_compte-mobile'); 4 var userLinkHTML = ''; 5 if(compteLinkContainer) { 6 var compteUtilisateurPath = compteLinkContainer.getAttribute('data-compte-utilisateur-path'); 7 var securityDeconnexionPath = compteLinkContainer.getAttribute('data-security-deconnexion-path'); 8 var securityConnexionPath = compteLinkContainer.getAttribute('data-security-connexion-path'); 9 if (nom != null || prenom != null) { 10 var personne = nom === "" && prenom === "" ? "Mon compte" : (prenom + " " + nom).trim(); 11 userLinkHTML += '<a href="' + compteUtilisateurPath + '" class="fr-nav__link fr-btn fr-icon-lock-line" title="Mon compte">' + personne + '</a>'; 12 userLinkHTML += '<a href="' + securityDeconnexionPath + '" class="fr-nav__link fr-btn fr-icon-lock-line" title="Se déconnecter - Vigicrues">Se déconnecter</a><br>'; 13 } else { 14 userLinkHTML += '<a href="' + securityConnexionPath + '" class="fr-nav__link fr-btn fr-icon-lock-line" title="Se connecter - Vigicrues">Se connecter</a>'; 15 } 16 17 compteLinkContainer.innerHTML = userLinkHTML; 18 } 19 if(compteLinkContainerMobile) { 20 var compteUtilisateurPath = compteLinkContainer.getAttribute('data-compte-utilisateur-path'); 21 var securityDeconnexionPath = compteLinkContainer.getAttribute('data-security-deconnexion-path'); 22 var securityConnexionPath = compteLinkContainer.getAttribute('data-security-connexion-path'); 23 var userLinkHTML = ''; 24 if (nom != null || prenom != null) { 25 var personne = nom === "" && prenom === "" ? "Mon compte" : (prenom + " " + nom).trim(); 26 userLinkHTML += '<a href="' + compteUtilisateurPath + '" class="fr-nav__link fr-btn fr-icon-lock-line" title="Mon compte">' + personne + '</a>'; 27 userLinkHTML += '<a href="' + securityDeconnexionPath + '" class="fr-nav__link fr-btn fr-icon-lock-line" title="Se déconnecter - Vigicrues">Se déconnecter</a><br>'; 28 } else { 29 userLinkHTML += '<a href="' + securityConnexionPath + '" class="fr-nav__link fr-btn fr-icon-lock-line" title="Se connecter - Vigicrues">Se connecter</a>'; 30 } 31 32 compteLinkContainerMobile.innerHTML = userLinkHTML; 33 } 34} 35 36$(document).ready(function() { 37 // Lecture des informations utilisateur directement depuis les attributs data du template 38 // Ãvite un appel API /username/ à chaque chargement de page 39 var compteLinkContainer = document.getElementById('header_compte'); 40 41 if (compteLinkContainer) { 42 var isLoggedIn = compteLinkContainer.getAttribute('data-user-logged-in') === 'true'; 43 44 if (isLoggedIn) { 45 var nom = compteLinkContainer.getAttribute('data-user-nom') || null; 46 var prenom = compteLinkContainer.getAttribute('data-user-prenom') || null; 47 // Convertir les chaînes vides en null pour cohérence avec updateHeader 48 if (nom === '') nom = null; 49 if (prenom === '') prenom = null; 50 updateHeader(nom, prenom); 51 } else { 52 updateHeader(null, null); 53 } 54 } 55});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.