1$(document).ready(function() { 2 const consent = getConsentCookie(); 3 4 if (!consent) { 5 $("#cookieComplianceModal").modal("show"); 6 } else { 7 // configureCookies(); 8 } 9}); 10 11$("#cookieComplianceModalConfigureBtn").on("click", function() { 12 $("#cookieConfigurationModal").modal("show"); 13 $("#cookieComplianceModal").css("z-index", 10); 14}); 15 16$("#cookieConfigurationModal").on("hide.bs.modal", function() { 17 $("#cookieComplianceModal").css("z-index", 1055); 18}); 19 20$("#cookieComplianceModalAcceptBtn").on("click", function() { 21 setConsentCookie({essentials: true, statistics: true, marketing: true}); 22 $("#cookieComplianceModal").modal("hide"); 23 24 configureCookies(); 25}); 26 27$("#cookieConfigurationModalSaveAllBtn").on("click", function() { 28 setConsentCookie({essentials: true, statistics: true, marketing: true}); 29 30 $("#cookieComplianceModal").modal("hide"); 31 $("#cookieConfigurationModal").modal("hide"); 32 33 configureCookies(); 34}); 35 36$("#cookieComplianceModalRejectNonEssentialCookies").on("click", function() { 37 setConsentCookie({essentials: true, statistics: false, marketing: false}); 38 39 $("#cookieComplianceModal").modal("hide"); 40 41 configureCookies(); 42}); 43 44$("#cookieConfigurationModalConfirmBtn").on("click", function() { 45 const stat = !!$("#cookieConfigurationModalStatistics").is(":checked"); 46 const mark = !!$("#cookieConfigurationModalMarketing").is(":checked"); 47 48 setConsentCookie({essentials: true, statistics: stat, marketing: mark}); 49 50 $("#cookieConfigurationModal").modal("hide"); 51 $("#cookieComplianceModal").modal("hide"); 52 53 configureCookies(); 54}); 55 56function setConsentCookie(preferences, days = 365) { 57 const json = JSON.stringify(preferences); 58 let date = new Date(); 59 date.setTime(date.getTime() + (days*24*60*60*1000)); 60 document.cookie = "cookie_consent=" + encodeURIComponent(json) + ";expires=" + date.toUTCString() + "; path=/"; 61} 62 63function getConsentCookie() { 64 const match = document.cookie.match('(^|;)\\s*cookie_consent\\s*=\\s*([^;]+)'); 65 return match ? JSON.parse(decodeURIComponent(match[2])) : null; 66} 67 68function configureCookies() { 69 let body = "action=configure_cookie&mode=ajax"; 70 71 let FIELDNAME = "s_id"; 72 let urlParams = new URLSearchParams(window.location.search); 73 if (urlParams.has(FIELDNAME)) { 74 body += "&s_id="+urlParams.get(FIELDNAME); 75 } 76 77 FIELDNAME = "optiid"; 78 urlParams = new URLSearchParams(window.location.search); 79 if (urlParams.has(FIELDNAME)) { 80 body += "&optiid="+urlParams.get(FIELDNAME); 81 } 82 83 FIELDNAME = "at_gd"; 84 urlParams = new URLSearchParams(window.location.search); 85 if (urlParams.has(FIELDNAME)) { 86 body += "&at_gd="+urlParams.get(FIELDNAME); 87 } 88 89 FIELDNAME = "awc"; 90 urlParams = new URLSearchParams(window.location.search); 91 if (urlParams.has(FIELDNAME)) { 92 body += "&awc="+urlParams.get(FIELDNAME); 93 } 94 95 96 body += "&WHSiteCookie=" + $("#WHSiteCookie").val(); 97 98 fetch("../include/cookie-management.inc.php", { 99 method: "post", headers: { "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, 100 body: body 101 }) 102 .then(function(response) { 103 if (response.ok) 104 return response.json(); 105 else 106 throw new Error("Couldn't configure cookies"); 107 }) 108 .then(function(json) { 109 if (json.status === "success") { 110 const marketing = json.scripts.marketing; 111 112 for (const index in marketing) { 113 const marketingData = marketing[index]; 114 115 if (Array.isArray(marketingData.text)) { 116 for (let i = 0; i < marketingData.text.length; i += 1) { 117 const data = marketingData.text[i]; 118 119 const marketingScript = document.createElement("script"); 120 121 if (marketingData.src !== "") { marketingScript.src = marketingData.src; } 122 marketingScript.text = data; 123 124 document.body.appendChild(marketingScript); 125 } 126 127 if (marketingData.noscript !== "") { 128 const marketingNoscript = document.createElement("noscript"); 129 130 marketingNoscript.innerHTML = marketingData.noscript 131 132 document.body.appendChild(marketingNoscript); 133 } 134 } else { 135 const marketingScript = document.createElement("script"); 136 137 if (marketingData.src !== "") { marketingScript.src = marketingData.src; } 138 marketingScript.text = marketingData.text; 139 140 document.body.appendChild(marketingScript); 141 } 142 } 143 144 const statistics = json.scripts.statistics; 145 const statisticsScript = document.createElement("script"); 146 147 statisticsScript.src = statistics.src; 148 statisticsScript.async = true; 149 document.head.appendChild(statisticsScript); 150 151 statisticsScript.onload = function() { 152 const inlineScript = document.createElement('script'); 153 inlineScript.textContent = statistics.text; 154 document.body.appendChild(inlineScript); 155 } 156 } 157 }) 158 .catch(function(err) { console.log(err); }); 159}
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.