1function propagateCampaignTrackingOnBookingUrl() { 2 console.debug("propagateCampaignTrackingOnBookingUrl is running..."); 3 try { 4 // Récup cookie CmpCnv⦠-> idFilm / idTracking 5 let idFilm = null, idTracking = null; 6 const cookies = decodeURIComponent(document.cookie).split(";").map(s => s.trim()); 7 const cmpCookie = cookies.find(ck => ck.startsWith("CmpCnv")); 8 if (cmpCookie) { 9 const [key, val] = cmpCookie.split("="); 10 idFilm = key.substring(7); // après "CmpCnv_" 11 idTracking = (val || "").split("#")[0]; 12 } 13 14 const linksReservation = Array.from( 15 document.getElementsByClassName("Erakys_select_seance") 16 ).filter(l => 17 l.getAttribute("data-action") === "reservation" && 18 l.getAttribute("data-tracked") !== "true" 19 ); 20 21 linksReservation.forEach(l => { 22 // === EXCEPTIONS === 23 if (l.classList.contains("no-cmp") || l.hasAttribute("data-no-cmp")) { 24 l.setAttribute("data-tracked", "true"); 25 return; // ne rien toucher pour ce lien 26 } 27 28 // Utilise URL pour manipuler proprement la query 29 const url = new URL(l.getAttribute("href"), window.location.href); 30 31 // Si un cmp existe déjà , ne rien ajouter 32 if (url.searchParams.has("cmp")) { 33 l.setAttribute("data-tracked", "true"); 34 return; 35 } 36 37 // Ajout conditionnel du cmp 38 if (idFilm && idTracking && l.getAttribute("data-film") === idFilm) { 39 url.searchParams.set("cmp", idTracking); 40 } else { 41 url.searchParams.set("cmp", "other"); 42 } 43 44 l.setAttribute("href", url.toString()); 45 l.setAttribute("data-tracked", "true"); 46 }); 47 } catch (e) { 48 console.error("Impossible to propagate tracking on booking link", e); 49 } 50} 51 52 53// To put in js more global, because it can be used for several cases 54function whenDomIsReady(callback) { 55 // in case the document is already rendered 56 if (document.readyState != "loading") callback(); 57 // modern browsers 58 else if (document.addEventListener) document.addEventListener("DOMContentLoaded", callback); 59 // IE <= 8 60 else 61 document.attachEvent("onreadystatechange", function () { 62 if (document.readyState == "complete") callback(); 63 }); 64} 65 66whenDomIsReady(function () { 67 propagateCampaignTrackingOnBookingUrl(); 68 $(document).on("ajaxComplete", function () { 69 propagateCampaignTrackingOnBookingUrl(); 70 }); 71});
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.