1 2window.addEventListener('DOMContentLoaded', () => { 3 4 5 6 /*-------------------------------COOKIE NOTICE NEW----------------------------------*/ 7 8 if (document.querySelector('#cookie-consent') || document.querySelector('#c-preferences')) { 9 10 const CONSENT_COOKIE_KEY = 'exp_cookie_consent'; 11 12 const CONSENT_COOKIE_VALUE = { 13 14 accept_all: 'agree', 15 16 only_essential: 'only_essential', 17 18 } 19 20 const GTM_KEY = g_id; 21 22 const FB_PAGE_ID = fb_id; 23 24 const HOT_JAR_ID = hj_id; 25 26 const FB_CHAT_ID = fb_chat_id; 27 28 29 30 const cookieContainer = document.querySelector('#cookie-consent'); 31 const preferencesContainer = document.querySelector('#c-preferences'); 32 33 const ccBtn = document.querySelector('.cc-settings-btn'); 34 const date = new Date(); 35 const cookieExpirationDate = new Date(date.setMonth(date.getMonth()+12)); 36 37 const haveConsent = getCookieItem(CONSENT_COOKIE_KEY); 38 const cookiesCount = document.cookie.split("; ").length; 39 40 let statsInput = null; 41 42 if (preferencesContainer) { 43 statsInput = preferencesContainer.querySelector('input[name="gpdr-stats-cookies"]'); 44 45 if ( (haveConsent && haveConsent === CONSENT_COOKIE_VALUE.accept_all) ) { 46 statsInput.checked = true; 47 } 48 } 49 50 if(haveConsent === 'exp_cookie_consent') { 51 if(GTM_KEY){ 52 insertGTMScripts(GTM_KEY); 53 } 54 if(FB_PAGE_ID){ 55 insertFBScripts(FB_PAGE_ID); 56 } 57 if(HOT_JAR_ID){ 58 insertHotJarScripts(HOT_JAR_ID); 59 } 60 if(FB_CHAT_ID){ 61 insertFBChat(FB_CHAT_ID); 62 } 63 openCookieModal(cookieContainer); 64 } 65 66 if ( (haveConsent && haveConsent === CONSENT_COOKIE_VALUE.only_essential && cookiesCount > 1) ) { 67 deleteAllCookies(); 68 setCookieItem(CONSENT_COOKIE_KEY, CONSENT_COOKIE_VALUE.only_essential, cookieExpirationDate, '/'); 69 } 70 71 ccBtn.addEventListener('click', (e) => { 72 e.preventDefault(); 73 openCookieModal(cookieContainer); 74 }); 75 76 const acceptOnlyEssensial = document.querySelectorAll('.accept-require-cookies'); 77 78 acceptOnlyEssensial.forEach((button) => { 79 button.addEventListener('click', () => { 80 deleteAllCookies(); 81 setCookieItem(CONSENT_COOKIE_KEY, CONSENT_COOKIE_VALUE.only_essential, cookieExpirationDate, '/'); 82 if (GTM_KEY) { 83 insertGTMScripts(GTM_KEY); 84 } 85 if (FB_PAGE_ID) { 86 insertFBScripts(FB_PAGE_ID); 87 } 88 if (HOT_JAR_ID) { 89 insertHotJarScripts(HOT_JAR_ID); 90 } 91 if (FB_CHAT_ID) { 92 insertFBChat(FB_CHAT_ID); 93 } 94 closeCookieModal(cookieContainer); 95 location.reload(); 96 }); 97 }); 98 99 const acceptAllButtons = document.querySelectorAll('.accept-all-cookies'); 100 101 acceptAllButtons.forEach(el => { 102 el.addEventListener('click', () => { 103 deleteAllCookies(); 104 setCookieItem(CONSENT_COOKIE_KEY, CONSENT_COOKIE_VALUE.accept_all, cookieExpirationDate, '/'); 105 if(GTM_KEY){ 106 insertGTMScripts(GTM_KEY); 107 } 108 if(FB_PAGE_ID){ 109 insertFBScripts(FB_PAGE_ID); 110 } 111 if(HOT_JAR_ID){ 112 insertHotJarScripts(HOT_JAR_ID); 113 } 114 if(FB_CHAT_ID){ 115 insertFBChat(FB_CHAT_ID); 116 } 117 closeCookieModal(cookieContainer); 118 location.reload(); 119 }) 120 }) 121 122 let acceptSelectedButton = false; 123 124 if (preferencesContainer) { 125 acceptSelectedButton = preferencesContainer.querySelector('button.close-window'); 126 } 127 128 if (acceptSelectedButton) { 129 acceptSelectedButton.addEventListener('click', () => { 130 deleteAllCookies(); 131 if (statsInput.checked) { 132 setCookieItem(CONSENT_COOKIE_KEY, CONSENT_COOKIE_VALUE.accept_all, cookieExpirationDate, '/'); 133 if(GTM_KEY){ 134 insertGTMScripts(GTM_KEY); 135 } 136 if(FB_PAGE_ID){ 137 insertFBScripts(FB_PAGE_ID); 138 } 139 if(HOT_JAR_ID){ 140 insertHotJarScripts(HOT_JAR_ID); 141 } 142 if(FB_CHAT_ID){ 143 insertFBChat(FB_CHAT_ID); 144 } 145 } else {
146 setCookieItem(CONSENT_COOKIE_KEY, CONSENT_COOKIE_VALUE.only_essential, cookieExpirationDate, '/'); 147 } 148 closeCookieModal(cookieContainer); 149 location.reload(); 150 }) 151 } 152 153 if ((haveConsent && haveConsent === CONSENT_COOKIE_VALUE.accept_all)) { 154 if(GTM_KEY){ 155 insertGTMScripts(GTM_KEY); 156 } 157 if(FB_PAGE_ID){ 158 insertFBScripts(FB_PAGE_ID); 159 } 160 if(HOT_JAR_ID){ 161 insertHotJarScripts(HOT_JAR_ID); 162 } 163 if(FB_CHAT_ID){ 164 insertFBChat(FB_CHAT_ID); 165 } 166 } 167 168 if ((haveConsent && haveConsent === CONSENT_COOKIE_VALUE.accept_all) || 169 (haveConsent && haveConsent === CONSENT_COOKIE_VALUE.only_essential) 170 ) { 171 return; 172 } 173 174 openCookieModal(cookieContainer); 175 } 176 /*-------------------------------COOKIE NOTICE END----------------------------------*/ 177 178 179}); 180 181/*-------------------------------COOKIE NOTICE NEW----------------------------------*/ 182function openCookieModal(modal) { 183 modal.classList.add('open'); 184} 185 186function closeCookieModal(modal) { 187 modal.classList.remove('open'); 188} 189 190const getCookieItem = (key) => { 191 return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(key).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; 192} 193 194const setCookieItem = (sKey, sValue, vEnd, sPath, sDomain, bSecure) => { 195 if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; } 196 var sExpires = ""; 197 if (vEnd) { 198 switch (vEnd.constructor) { 199 case Number: 200 sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd; 201 break; 202 case String: 203 sExpires = "; expires=" + vEnd; 204 break; 205 case Date: 206 sExpires = "; expires=" + vEnd.toUTCString(); 207 break; 208 } 209 } 210 document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : ""); 211 return true; 212} 213 214const deleteAllCookies = () => { 215 const cookies = document.cookie.split("; "); 216 for (let i = 0; i < cookies.length; i++) { 217 const d = window.location.hostname.split("."); 218 while (d.length > 0) { 219 const cookieBase = encodeURIComponent(cookies[i].split(";")[0].split("=")[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain=' + d.join('.') + ' ;path='; 220 const p = location.pathname.split('/'); 221 document.cookie = cookieBase + '/'; 222 while (p.length > 0) { 223 document.cookie = cookieBase + p.join('/'); 224 p.pop(); 225 } 226 d.shift(); 227 } 228 } 229} 230 231const insertGTMScripts = (gtmTrackingId) => { 232 console.log('GTM working'); 233 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 234 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 235 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
236 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 237 })(window,document,'script','dataLayer',gtmTrackingId); 238 239 const markup = ` 240 <iframe src="https://www.googletagmanager.com/ns.html?id=${gtmTrackingId}" height="0" width="0" style="display:none;visibility:hidden"></iframe> 241 `; 242 243 let script = document.createElement('noscript'); 244 script.innerHTML = markup; 245 246 document.body.insertBefore(script, document.body.firstChild); 247 248} 249 250const insertFBScripts = (fbPageId) => { 251 console.log('FB working'); 252 !function(f,b,e,v,n,t,s) 253 {if(f.fbq)return;n=f.fbq=function(){n.callMethod? 254 n.callMethod.apply(n,arguments):n.queue.push(arguments)}; 255 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; 256 n.queue=[];t=b.createElement(e);t.async=!0; 257 t.src=v;s=b.getElementsByTagName(e)[0]; 258 s.parentNode.insertBefore(t,s)}(window,document,'script', 259 'https://connect.facebook.net/en_US/fbevents.js'); 260 261 fbq('init', fbPageId); 262 fbq('track', 'PageView'); 263 264 const markup = ` 265 <img height="1" width="1" src="https://www.facebook.com/tr?id=${fbPageId}&ev=PageView&noscript=1"/> 266 `; 267 268 let script = document.createElement('noscript'); 269 script.innerHTML = markup; 270 271 document.body.insertBefore(script, document.body.firstChild); 272 273} 274 275const insertHotJarScripts = (hotJarTrackingId) => { 276 console.log('HotJar working'); 277 (function(h,o,t,j,a,r){ 278 h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)}; 279 h._hjSettings={hjid:hotJarTrackingId,hjsv:6}; 280 a=o.getElementsByTagName('head')[0]; 281 r=o.createElement('script');r.async=1; 282 r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; 283 a.appendChild(r); 284 285 })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); 286 287} 288 289const insertFBChat = (fbChatId) => { 290 console.log('FB Chat working'); 291 let mainContainer = document.createElement('div'); 292 mainContainer.setAttribute('id', 'fb-root'); 293 294 let secondContainer = document.createElement('div'); 295 secondContainer.setAttribute('id', 'fb-customer-chat'); 296 secondContainer.setAttribute('class', 'fb-customerchat'); 297 298 secondContainer.setAttribute("page_id", fbChatId); 299 secondContainer.setAttribute("attribution", "biz_inbox"); 300 secondContainer.setAttribute("greeting_dialog_display", "hide"); 301 302 document.body.appendChild(mainContainer); 303 document.body.appendChild(secondContainer); 304 305 window.fbAsyncInit = function() { 306 FB.init({ 307 xfbml : true, 308 version : 'v15.0' 309 }); 310 }; 311 312 (function(d, s, id) { 313 var js, fjs = d.getElementsByTagName(s)[0]; 314 if (d.getElementById(id)) return; 315 js = d.createElement(s); js.id = id; 316 js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js'; 317 fjs.parentNode.insertBefore(js, fjs); 318 }(document, 'script', 'facebook-jssdk')); 319 320} 321/*-------------------------------COOKIE NOTICE END----------------------------------*/
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.