1var jonahCookieBanner = { 2 cookieName: 'jcmAcceptedCookies', 3 4 getCookie: function(cname) { 5 var name = cname + "="; 6 var ca = document.cookie.split(';'); 7 for(var i = 0; i < ca.length; i++) { 8 var c = ca[i]; 9 while (c.charAt(0) == ' ') { 10 c = c.substring(1); 11 } 12 if (c.indexOf(name) == 0) { 13 return c.substring(name.length, c.length); 14 } 15 } 16 return null; 17 }, 18 19 init: function() { 20 var cookieBanner = document.getElementById('jonah-cookie-banner'); 21 var cookieButtons = document.querySelectorAll('[data-cookie-action]'); 22 var cookieDecision = this.getCookie(this.cookieName); 23 24 // -- Allows reset of the cookieDecision, forcing banner to show. 25 if (cookieBanner.getAttribute('data-cookie-reset') == 1) { 26 cookieDecision = null; 27 } 28 29 // -- Ensure a decision has not been made, and the Cookie Banner is present in the DOM. 30 if (cookieDecision == null && cookieBanner) { 31 32 // -- Open banner from selected position. 33 switch (cookieBanner.dataset.position) { 34 case 'bottom': 35 cookieBanner.style.bottom = (cookieBanner.offsetHeight * -1) + 'px'; 36 37 setTimeout(function(){ 38 cookieBanner.classList.add('cookie-banner--show-from-bottom'); 39 }, 500); 40 break; 41 case 'top': 42 cookieBanner.style.top = (cookieBanner.offsetHeight * -1) + 'px'; 43 44 setTimeout(function(){ 45 cookieBanner.classList.add('cookie-banner--show-from-top'); 46 }, 500); 47 break; 48 } 49 50 if (cookieButtons.length) { 51 for (var i = 0; i < cookieButtons.length; i++) { 52 var el = cookieButtons[i]; 53 54 el.cookieBehavior = el.dataset.cookieAction; 55 el.removeAttribute('data-cookie-action'); 56 57 el.onclick = function(e) { 58 e.preventDefault(); 59 60 switch (this.cookieBehavior) { 61 case 'acceptance': 62 // -- Create Date object set to 12 months out. 63 var expire = new Date(); 64 expire.setFullYear(expire.getFullYear() + 1); 65 66 // -- Store acceptance decision as a cookie for 12 months. 67 document.cookie = jonahCookieBanner.cookieName + "=1;path=/; expires=" + expire.toGMTString() + '; SameSite=Strict; Secure'; 68 break; 69 } 70 71 // -- Remove Visibility Classes 72 cookieBanner.classList.remove('cookie-banner--show-from-bottom'); 73 cookieBanner.classList.remove('cookie-banner--show-from-top'); 74 75 // -- Remove Cookie Manager from DOM. 76 setTimeout(function(){ 77 cookieBanner.remove(); 78 }, 500); 79 }; 80 } 81 } 82 } else { 83 // -- Decision has already been made. Remove Cookie Manager from DOM. 84 cookieBanner.remove(); 85 } 86 } 87}; 88 89jonahCookieBanner.init();
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.