1(function (window, document) { 2 var COOKIE_NAME = 'gim_cookie_notice_closed'; 3 var COOKIE_LIFETIME_MINUTES = 15; 4 5 function bind(element, eventName, handler) { 6 if (!element) { 7 return; 8 } 9 10 if (element.addEventListener) { 11 element.addEventListener(eventName, handler, false); 12 } else if (element.attachEvent) { 13 element.attachEvent('on' + eventName, handler); 14 } 15 } 16 17 function hasClass(element, className) { 18 return new RegExp('(^|\\s)' + className + '(\\s|$)').test(element.className); 19 } 20 21 function addClass(element, className) { 22 if (!hasClass(element, className)) { 23 element.className = element.className ? element.className + ' ' + className : className; 24 } 25 } 26 27 function removeClass(element, className) { 28 element.className = element.className 29 .replace(new RegExp('(^|\\s)' + className + '(?=\\s|$)', 'g'), ' ') 30 .replace(/\s+/g, ' ') 31 .replace(/^\s+|\s+$/g, ''); 32 } 33 34 function escapeForRegExp(value) { 35 return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); 36 } 37 38 function getCookie(name) { 39 var matches = document.cookie.match( 40 new RegExp('(?:^|; )' + escapeForRegExp(name) + '=([^;]*)') 41 ); 42 43 return matches ? decodeURIComponent(matches[1]) : null; 44 } 45 46 function setCookie(name, value, minutes) { 47 var expiresDate = new Date(); 48 expiresDate.setTime(expiresDate.getTime() + minutes * 60 * 1000); 49 document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + expiresDate.toUTCString() + '; path=/; SameSite=Lax'; 50 } 51 52 function getCloseElements(notice) { 53 var elements = notice.getElementsByTagName('*'); 54 var result = []; 55 var i; 56 57 for (i = 0; i < elements.length; i++) { 58 if (elements[i].getAttribute('data-cookie-notice-close') !== null) { 59 result.push(elements[i]); 60 } 61 } 62 63 return result; 64 } 65 66 function init() { 67 var notice = document.getElementById('cookie-notice'); 68 var closeElements; 69 var i; 70 71 if (!notice || notice.getAttribute('data-cookie-notice-initialized') === 'Y') { 72 return; 73 } 74 75 notice.setAttribute('data-cookie-notice-initialized', 'Y'); 76 77 if (getCookie(COOKIE_NAME)) { 78 return; 79 } 80 81 notice.style.display = 'block'; 82 window.setTimeout(function () { 83 addClass(notice, 'cookie-notice--visible'); 84 notice.setAttribute('aria-hidden', 'false'); 85 }, 20); 86 87 closeElements = getCloseElements(notice); 88 89 for (i = 0; i < closeElements.length; i++) { 90 bind(closeElements[i], 'click', function (event) { 91 event = event || window.event; 92 93 if (event.preventDefault) { 94 event.preventDefault(); 95 } else { 96 event.returnValue = false; 97 } 98 99 setCookie(COOKIE_NAME, 'Y', COOKIE_LIFETIME_MINUTES); 100 removeClass(notice, 'cookie-notice--visible'); 101 notice.setAttribute('aria-hidden', 'true'); 102 103 window.setTimeout(function () { 104 notice.style.display = 'none'; 105 }, 260); 106 107 return false; 108 }); 109 } 110 } 111 112 if (document.readyState === 'complete' || document.readyState === 'interactive') { 113 window.setTimeout(init, 0); 114 } else { 115 bind(window, 'load', init); 116 bind(document, 'DOMContentLoaded', init); 117 } 118})(window, document);
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.