90]);
91
92function hideLoader() {
93 if (loader) {
94 loader.style.display = "none";
95 }
96}
97function showLoader() {
98 if (loader) {
99 loader.style.display = "flex";
101}
102
103function resetAll() {
104 // clean les user prefs
105 ResetUserPref();
108}
109// INTERNATIONAL POPUP
110function showUnauthorizedPopup() {
111 document.querySelectorAll("[availability]")[0].style.display = "block";
112 document.body.style.overflow = "hidden";
117}
118
119function instantTranslate_itl(lang) {
120 const instantTrads = document.querySelectorAll("[instant-trad]");
121 instantTrads.forEach(element => {
129 "languageTo": lang,
130 },
131 function(destTxt) {
132 console.log(destTxt[0]);
133 element.textContent = destTxt[0];
137}
138
139function ApplyCurrentLang() {
140 currentLang.forEach(element => {
141 element.textContent = Weglot.getCurrentLang();
143}
144
145function getElements() {
146 // 1) declaration des variable vitales
147 loader = document.getElementsByClassName("loader")[0];
194 changeCountries.forEach(element => {
195 element.addEventListener("click", () => {
196 ResetUserPref(); // Call the toto function on click
197 });
198 });
321 ChoosenTermsValue = document.querySelectorAll("[choosenTermsValue]")[0].innerText;
322
323 itlBtnStart.addEventListener("click", function() {
324 itlPopupTopBar.style.opacity = 1;
325 popupItlStep = 1;
328 });
329
330 itlPopupPrev.addEventListener("click", function() {
331 if (popupItlStep === 2) {
332 popupItlStep = 1;
361}
362
363function writeCountryPref() {
364 const countryCode = localStorage.userCountry;
365 const fullCountry = document.querySelectorAll("[itl-choice-country=" + countryCode + "]")[0].childNodes[1].innerText;
371 filterSpokenLangs(spokenL);
372}
373function writeProfile() {
374 const userProfile = localStorage.userProfile;
375 applyChosenProfile(userProfile);
376}
377
378function writeLang(l) {
379 document.querySelectorAll("[current-lang]")[0].textContent = l;
380}
381
382function setItlPopupInitLang() {
383 // Get the browser's language and extract the two-letter code
384 const browserLanguage = navigator.language || navigator.userLanguage;
393}
394
395function ApplyChosenCountry(c) {
396 ChoosenCountry.forEach(element => {
397 element.innerText = c;
401}
402
403function filterSpokenLangs(langs) {
404 console.log(langs);
405 console.log(spokenLangsOrder);
416}
417
418function filterAndOrderSpokenLangs(langs) {
419 console.log(spokenLangsOrder);
420 spokenLangsOrder.forEach(lang => {
436}
437
438function applyChosenLang(l) {
439 ChoosenLang.forEach(element => {
440 element.innerText = l;
443 CheckStep2.style.opacity = 1;
444}
445function applyChosenProfile(p) {
446 ChoosenProfile.forEach(element => {
447 element.innerText = p;
453}
454
455function applyChosenTerms(t) {
456 if (popupItlStep === 4) {
457 ChoosenTerms.forEach(element => {
467}
468
469function WatchFullCgvRead() {
470 if (Webflow.env("editor")) {
471 console.log("mut observer disabled");
472 } else {
473 // Créer un IntersectionObserver avec une fonction de callback qui authorize la validation
474 var observer = new IntersectionObserver(function(entries) {
475 // `entries` contient les éléments observés et leurs états d'intersection
476 entries.forEach(entry => {
497}
498
499function authorizeValidation() {
500 itlPopupValidate.classList.remove("disabled");
501 console.log("disabled remove");
502 itlPopupValidate.addEventListener("click", function() {
503 StorePopupChoices(UserCountry, UserLang, UserProfile);
504
519}
520
521function handleStepStyles() {
522 // Select all elements with the attribute itl-popup-step
523 const elements = document.querySelectorAll("[itl-popup-step]");
539// 2) declaration des fonction vitales
540
541function showItlPopup() {
542 setItlPopupInitLang();
543 popupItlStep = 0;
544 document.addEventListener("keydown", function(event) {
545 if (event.key === "Enter" && popupItlStep === 0) {
546 itlBtnStart.click();
560}
561
562function flyToStep(step) {
563 itlPopupContainer.scrollTo({
564 top: step.offsetTop - 120,
567}
568
569function BackToStep1() {
570 flyToStep(step1);
571 popupItlStep = 1;
576 step3.scrollTop = 0;
577}
578function BackToStep2() {
579 if (popupItlStep > 1) {
580 flyToStep(step2);
588}
589
590function BackToStep3() {
591 if (popupItlStep > 2) {
592 flyToStep(step3);
600}
601
602function scrollToEnd() {
603 step4.scrollTop = step4.scrollHeight;
604}
605
606function filterCgv() {
607 // Select all elements with the attributes itl-cgv-country and itl-cgv-lang
608 const elements = document.querySelectorAll("[itl-cgv-country][itl-cgv-lang]");
627}
628
629function StorePopupChoices(country, lang, profile) {
630 localStorage.setItem("userCountry", country);
631 localStorage.setItem("userLang", lang);
634}
635
636function ResetUserPref() {
637 localStorage.removeItem("userCountry");
638 localStorage.removeItem("userLang");
643}
644
645function scrollTop() {
646 window.scrollTo(0, 0);
647}
648
649function checkLocalStorage() {
650 getElements();
651 console.log("elementsGot");
669 getAuthorizedVehiclesByCountry(localStorage.userCountry);
670 LocalizeStaticPage();
671 // Check if env is "preprod" before running the function
672 if (env === "staging") {
673 console.log("Environment is preprod. Running LocaliseCMSdata...");
690}
691
692function calcDestinationSubFolder() {
693 if (localStorage.userLang === "fr") {
694 subfolder = "";
699
700// Definition des fonction vitales
701function findUrl(slug, country) {
702 // First, search in the specified country
703 const match = urlTable.find(entry => entry[country] === slug);
739}
740
741function AdaptStaticPage(slug) {
742 if (!slug) {
743 masterSlug = findMasterPage();
765}
766
767function findMasterPage() {
768 baseUrl = window.location.origin;
769
799
800// permet de find le best resource match Ă partir d'un type et d'un name
801function findResource(resourceType, resourceMasterName, country, lang) {
802 console.log(country + " " + lang);
803 const alternativeResources = externalResourceTable.filter(resource =>
846
847// dynamic checks
848function getAuthorizedVehiclesByCountry(countryCode) {
849 if (vehicleTable) {
850 // Find the authorized vehicle list for the given country code
860}
861
862function CheckVehicle_overlap(involved) {
863 // Split and normalize the involved string into an array (lowercase and trimmed)
864 const involvedArray = involved
880 }
881}
882function AdaptDynamicPage() {
883 const involvedVehicles = document.querySelectorAll("meta[involvedvehicles]")[0].getAttribute("involvedvehicles");
884 const b = document.querySelectorAll("meta[blacklist]")[0].getAttribute("blacklist");
910}
911// var cmsItems;
912function deleteOverLimitCms() {
913 // managing cms lists with limit indicated in attribute data-limit
914 const cmsLists = document.querySelectorAll("[data-limit]");
926}
927
928function LocaliseCMSdata() {
929 // Select all elements with the "vehicles" attribute
930 const elements = document.querySelectorAll("[vehicles]");
964}
965
966function checkWhitelist(w) {
967 const array = w
968 .split(",")
972}
973
974function checkBlacklist(b) {
975 const array = b
976 .split(",")
980}
981
982function AdaptSwipers() {
983 // Sélectionne tous les conteneurs Swiper sur la page
984 const swiperContainers = document.querySelectorAll(".swiper");
993}
994
995function AdaptGrids() {
996}
997
998function AdaptExternalResources() {
999 const elements = document.querySelectorAll("[externalresourcetype][externalresourcename]");
1000 // itere parmis les elements qui ont les attributes externalRessource
1022}
1023
1024function addhsform(target, formId, instance) {
1025 // console.log("add hsform");
1026 // console.log(instance+1);
1035 formId: formId,
1036 target: "[hs-externalresource='" + formId + "_" + instance + "']", // Directly reference the target div
1037 onFormSubmit: function(form) {
1038 // Show the success div block.
1039 // success();
1045 }
1046}
1047function addhsfile(div, url) {
1048 console.log("add hs file");
1049 div.href = url;
1050}
1051function addhscal(element, id) {
1052 console.log("add hscal");
1053 console.log(element);
1071}
1072/// hotfix du bug Hubspot calendar
1073function fix_hscal() {
1074 const badurl = document.querySelectorAll("[data-src]")[0].firstChild.src;
1075 const cleanurl = badurl.replace(/(parentPageUrl=[^&]+)&/, "$1?");
1079
1080// LAUNCH EXTERNAL RESSOURCES
1081async function LoadExternalResources() {
1082 try {
1083 const response = await fetch(apiBaseUrl + "/api:_aqWQ_f_/ListAllRessourcesExternes", fetchOptions);
1090}
1091
1092// Function to run vital and then the dependent function
1093async function LocalizeExternalResources() {
1094 await LoadExternalResources(); // Wait for vital to complete
1095 AdaptExternalResources(); // Run the dependent function
1096}
1097
1098// LAUNCH STATIC RESOURCES
1099async function LoadStaticTable() {
1100 try {
1101 const response = await fetch(apiBaseUrl + "/api:_aqWQ_f_/ListAllStaticPages", fetchOptions);
1107 }
1108}
1109// Function to run vital and then the dependent function
1110async function LocalizeStaticPage() {
1111 if (document.querySelectorAll("meta[involvedvehicles]").length !== 0) {
1112 // Run AdaptDynamicPage() ;
1146
1147// Fonction pour vérifier et masquer les sections vides
1148function checkSectionsToHide() {
1149 console.log("checking sections to hide");
1150 const sections = document.querySelectorAll("[data-collection-ref][ncf-display-type=\"conditionnal\"]");