1(function () { 2 3 /** 4 * Loads a script only once by using a flag on the window object. 5 * Prevents duplicate loading if consent is triggered multiple times. 6 */ 7 function loadScriptOnce(url, flag) { 8 if (window[flag]) return; 9 10 window[flag] = true; 11 12 const script = document.createElement("script"); 13 script.src = url; 14 script.async = true; 15 16 script.onerror = function () { 17 console.error("Failed to load:", url); 18 window[flag] = false; 19 }; 20 21 document.head.appendChild(script); 22 } 23 24 /** 25 * Enables functional cookies and loads related functionality scripts. 26 * Typically used for embedded services like YouTube, maps, chat widgets etc. 27 */ 28 function enableFunctional() { 29 console.log("Functional cookies are ALLOWED"); 30 } 31 32 /** 33 * Disables functionality dependent on functional cookies. 34 * Normally used to stop initialization of optional features. 35 */ 36 function disableFunctional() { 37 console.log("Functional cookies are NOT allowed"); 38 } 39 40 /** 41 * Enables statistics cookies and initializes analytics tools. 42 * Example: Matomo analytics. 43 */ 44 function enableStatistics() { 45 console.log("Statistics cookies are ALLOWED"); 46 47 window._paq = window._paq || []; 48 window._paq.push(['forgetUserOptOut']); 49 50 loadScriptOnce("/js/itu/matomo2.js", "matomoLoaded"); 51 } 52 53 /** 54 * Disables statistics tracking. 55 * Used to opt the user out of analytics tracking. 56 */ 57 function disableStatistics() { 58 console.log("Statistics cookies are NOT allowed"); 59 60 window._paq = window._paq || []; 61 window._paq.push(['optUserOut']); 62 } 63 64 /** 65 * Enables marketing cookies and loads marketing / tracking scripts. 66 * Example: ad tracking pixels or marketing automation tools. 67 */ 68 function enableMarketing() { 69 console.log("Marketing cookies are ALLOWED"); 70 71 loadScriptOnce("/js/itu/metaPixel.js", "metaPixelLoaded"); 72 } 73 74 /** 75 * Disables marketing tracking if consent is not given. 76 */ 77 function disableMarketing() { 78 console.log("Marketing cookies are NOT allowed"); 79 } 80 81 /** 82 * Central consent handler that checks each cookie category 83 * and enables or disables features accordingly. 84 */ 85 function handleConsent(consents) { 86 87 // Functional cookies 88 if (consents.cookie_cat_functional === true) { 89 enableFunctional(); 90 } else { 91 disableFunctional(); 92 } 93 94 // Statistics cookies 95 if (consents.cookie_cat_statistic === true) { 96 enableStatistics(); 97 } else { 98 disableStatistics(); 99 } 100 101 // Marketing cookies 102 if (consents.cookie_cat_marketing === true) { 103 enableMarketing(); 104 } else { 105 disableMarketing(); 106 } 107 } 108 109 /** 110 * Listen for consent changes from the Cookie Information CMP. 111 * Triggered when a user updates their cookie preferences. 112 */ 113 window.addEventListener("CookieInformationConsentGiven", function (e) { 114 handleConsent(e.detail?.consents || {}); 115 }); 116 117 /** 118 * Check if consent already exists when the page loads. 119 * Ensures scripts are activated immediately if consent was previously given. 120 */ 121 if (window.CookieInformation?.consents) { 122 handleConsent(window.CookieInformation.consents); 123 } 124 125})();
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.