1(function () { 2 'use strict'; 3 4 var COOKIE = 'oh_consent'; 5 var VERSION = 2; 6 var MAX_AGE = 60 * 60 * 24 * 180; 7 8 var gaLoaded = false; 9 var banner = null; 10 var wired = false; 11 12 function getCookie(name) { 13 var m = document.cookie.match('(?:^|; )' + name + '=([^;]*)'); 14 return m ? decodeURIComponent(m[1]) : null; 15 } 16 17 function setCookie(name, value) { 18 var secure = location.protocol === 'https:' ? '; Secure' : ''; 19 document.cookie = name + '=' + encodeURIComponent(value) + 20 '; Max-Age=' + MAX_AGE + '; Path=/; SameSite=Lax' + secure; 21 } 22 23 function readConsent() { 24 var raw = getCookie(COOKIE); 25 if (!raw) return null; 26 try { 27 var c = JSON.parse(raw); 28 return (c && c.v === VERSION) ? c : null; 29 } catch (e) { 30 return null; 31 } 32 } 33 34 function saveConsent(fields) { 35 var c = readConsent() || { analytics: false, decided: false }; 36 var next = { 37 v: VERSION, 38 necessary: true, 39 analytics: fields.hasOwnProperty('analytics') ? !!fields.analytics : !!c.analytics, 40 decided: fields.hasOwnProperty('decided') ? !!fields.decided : !!c.decided, 41 ts: Math.floor(Date.now() / 1000) 42 }; 43 setCookie(COOKIE, JSON.stringify(next)); 44 return next; 45 } 46 47 function loadGA() { 48 if (gaLoaded || typeof window.ohLoadGA !== 'function') return; 49 gaLoaded = true; 50 window.ohLoadGA(); 51 } 52 53 function applyConsent(c) { 54 if (c && c.analytics) loadGA(); 55 } 56 57 function enableGA() { 58 if (window.ohGaId) window['ga-disable-' + window.ohGaId] = false; 59 } 60 61 function withdrawGA() { 62 if (window.ohGaId) window['ga-disable-' + window.ohGaId] = true; 63 var host = location.hostname; 64 var base = host.replace(/^www\./, ''); 65 var domains = ['', '; Domain=' + host, '; Domain=.' + base, '; Domain=' + base]; 66 document.cookie.split('; ').forEach(function (pair) { 67 var name = pair.split('=')[0]; 68 if (name && (name.indexOf('_ga') === 0 || name === '_gid' || name.indexOf('_gat') === 0)) { 69 domains.forEach(function (d) { 70 document.cookie = name + '=; Max-Age=0; Path=/' + d; 71 }); 72 } 73 }); 74 } 75 76 77 function getBanner() { 78 if (banner) return banner; 79 banner = document.querySelector('.oh-cc'); 80 if (!banner) return null; 81 if (!wired) { 82 wired = true; 83 banner.querySelector('#oh-cc-accept').addEventListener('click', function () { choose(true); }); 84 banner.querySelector('#oh-cc-reject').addEventListener('click', function () { choose(false); }); 85 banner.querySelector('#oh-cc-customize').addEventListener('click', function () { 86 if (this.getAttribute('data-mode') === 'save') { 87 choose(banner.querySelector('#oh-cc-analytics').checked); 88 } else { 89 openPrefs(); 90 } 91 }); 92 } 93 return banner; 94 } 95 96 function show() { 97 if (!getBanner()) return; 98 requestAnimationFrame(function () { banner.classList.add('oh-cc--show'); }); 99 } 100 101 function hide() { 102 if (banner) banner.classList.remove('oh-cc--show'); 103 } 104 105 function openPrefs() { 106 if (!getBanner()) return; 107 banner.querySelector('#oh-cc-prefs').hidden = false; 108 var customize = banner.querySelector('#oh-cc-customize'); 109 var saveLabel = customize.getAttribute('data-save-label'); 110 if (saveLabel) customize.textContent = saveLabel; 111 customize.setAttribute('data-mode', 'save'); 112 } 113 114 function choose(analytics) { 115 if (analytics) enableGA(); else withdrawGA(); 116 applyConsent(saveConsent({ analytics: analytics, decided: true })); 117 hide(); 118 } 119 120 window.ohCookieSettings = function () { 121 if (!getBanner()) return; 122 var c = readConsent(); 123 banner.querySelector('#oh-cc-analytics').checked = !!(c && c.analytics); 124 openPrefs(); 125 show(); 126 }; 127 128 function init() { 129 var c = readConsent(); 130 if (c) applyConsent(c); 131 if (!c || !c.decided) show(); 132 } 133 134 if (document.readyState === 'loading') { 135 document.addEventListener('DOMContentLoaded', init); 136 } else { 137 init(); 138 } 139})();
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.