1document.addEventListener('DOMContentLoaded', function () { 2 const banner = document.getElementById('privacy-banner'); 3 const acceptBtn = document.querySelector('.privacy-accept'); 4 const closeBtn = document.querySelector('.privacy-decline'); 5 const openLinks = document.querySelectorAll('.privacy-open'); 6 const gpcEnabled = navigator.globalPrivacyControl === true; 7 const previousConsent = getCookie('cookie_consent'); 8 9 // Nothing to operate on if the banner markup isn't present on this page. 10 if (!banner) { 11 return; 12 } 13 14 function setCookie(name, value, days) { 15 let expires = ""; 16 if (days) { 17 const date = new Date(); 18 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 19 expires = "; expires=" + date.toUTCString(); 20 } 21 const secure = location.protocol === 'https:' ? '; Secure' : ''; 22 document.cookie = name + "=" + (value || "") + expires + "; path=/; SameSite=Lax" + secure; 23 } 24 25 function getCookie(name) { 26 const nameEQ = name + "="; 27 const ca = document.cookie.split(';'); 28 for (let i = 0; i < ca.length; i++) { 29 let c = ca[i]; 30 while (c.charAt(0) === ' ') c = c.substring(1, c.length); 31 if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); 32 } 33 return null; 34 } 35 36 // Check for auto-hide flag (set in template: window.appcardCookieAutoHide = true) 37 const autoHide = window.appcardCookieAutoHide === true; 38 39 if (!getCookie('cookie_consent')) { 40 if (gpcEnabled) { 41 setCookie('cookie_consent', 'declined', 365); 42 if (!autoHide) { 43 reloadCheck(); 44 } 45 } else if (!autoHide) { 46 banner.classList.add('visible'); 47 } 48 } 49 50 function hideBanner() { 51 banner.classList.remove('visible'); 52 setTimeout(() => { banner.style.display = 'none'; }, 400); 53 } 54 55 function showBanner() { 56 banner.style.display = 'block'; 57 banner.classList.add('visible'); 58 } 59 60 function reloadCheck() { 61 const newConsent = getCookie('cookie_consent'); 62 63 // for now don't reload if you accept with no prev 64 if (previousConsent === null) { 65 if (newConsent === 'declined') { 66 window.location.reload(); 67 } 68 return; 69 } 70 71 if (newConsent !== previousConsent) { 72 window.location.reload(); 73 } 74 } 75 76 if (acceptBtn) { 77 acceptBtn.addEventListener('click', function () { 78 setCookie('cookie_consent', 'accepted', 365); 79 hideBanner(); 80 if (!autoHide) { 81 reloadCheck(); 82 } 83 }); 84 } 85 86 if (closeBtn) { 87 closeBtn.addEventListener('click', function () { 88 setCookie('cookie_consent', 'declined', 365); 89 hideBanner(); 90 if (!autoHide) { 91 reloadCheck(); 92 } 93 }); 94 } 95 96 openLinks.forEach(link => { 97 link.addEventListener('click', function (e) { 98 e.preventDefault(); 99 showBanner(); 100 }); 101 }); 102});
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.