1/* BM Cookies â liÅ¡ta a nastavenia súhlasu s cookies (zbranepresov.sk) 2 * Konfigurácia prichádza z hlaviÄky: window.BMC_CONF (extension/module/bm_cookies::head) 3 * Súhlas: cookie bm_consent = v{verzia}.{analytické}{marketingové}{médiá}.{id}.{Äas} 4 */ 5(function () { 6 'use strict'; 7 var C = window.BMC_CONF; 8 if (!C) { return; } 9 var NAME = 'bm_consent', OPT = ['analytics', 'marketing', 'media']; 10 var RE = /^v(\d+)\.([01])([01])([01])\.([a-f0-9]{16,32})\.(\d{9,11})$/; 11 var gtag = window.gtag || function () { (window.dataLayer = window.dataLayer || []).push(arguments); }; 12 var applied = { analytics: false, marketing: false, media: false }; 13 var gtagLoaded = false, bar = null, modal = null, lastFocus = null; 14 15 function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } 16 function read() { 17 var m = document.cookie.match(/(?:^|;\s*)bm_consent=([^;]+)/); 18 if (!m) { return null; } 19 var p = decodeURIComponent(m[1]).match(RE); 20 if (!p || +p[1] !== +C.v) { return null; } 21 return { analytics: p[2] === '1', marketing: p[3] === '1', media: p[4] === '1', id: p[5], ts: +p[6] }; 22 } 23 function rid() { 24 var a = new Uint8Array(16), cr = window.crypto || window.msCrypto; 25 if (cr && cr.getRandomValues) { cr.getRandomValues(a); } else { for (var i = 0; i < 16; i++) { a[i] = Math.floor(Math.random() * 256); } } 26 return Array.prototype.map.call(a, function (b) { return ('0' + b.toString(16)).slice(-2); }).join(''); 27 } 28 function bits(s) { return (s.analytics ? '1' : '0') + (s.marketing ? '1' : '0') + (s.media ? '1' : '0'); } 29 function write(s) { 30 var v = 'v' + C.v + '.' + bits(s) + '.' + s.id + '.' + Math.floor(Date.now() / 1000); 31 document.cookie = NAME + '=' + v + '; max-age=' + (C.days * 86400) + '; path=/; SameSite=Lax' + (location.protocol === 'https:' ? '; Secure' : ''); 32 } 33 var state = read(); 34 35 /* ---------- zmazanie cookies nástrojov po odvolanà súhlasu ---------- */ 36 var PAT = { 37 analytics: /^(_ga|_ga_.+|_gid|_gat.*|__utm.+|toplist.*)$/i, 38 marketing: /^(_gcl_.+|_gac_.+|_fbp|_fbc|IDE|test_cookie|_uetsid|_uetvid|fr)$/i 39 }; 40 function killCookie(n) { 41 var h = location.hostname.split('.'), doms = ['']; 42 for (var i = 0; i < h.length - 1; i++) { var d = h.slice(i).join('.'); doms.push(d, '.' + d); } 43 doms.forEach(function (d) { 44 document.cookie = n + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/' + (d ? '; domain=' + d : ''); 45 }); 46 } 47 function clearTrackers(cats) { 48 document.cookie.split(';').forEach(function (c) { 49 var n = c.split('=')[0].trim(); 50 cats.forEach(function (k) { if (PAT[k] && PAT[k].test(n)) { killCookie(n); } }); 51 }); 52 } 53 54 /* ---------- spustenie nástrojov podľa súhlasu ---------- */ 55 function load(src) { var e = document.createElement('script'); e.async = true; e.src = src; document.head.appendChild(e); } 56 function ensureGtag(id) { 57 if (gtagLoaded) { return; } 58 gtagLoaded = true; 59 load('https://www.googletagmanager.com/gtag/js?id=' + encodeURIComponent(id)); 60 gtag('js', new Date()); 61 } 62 function runTpl(cat) { 63 var t = document.getElementById('bmc-tpl-' + cat); 64 if (!t || !t.content) { return; } 65 Array.prototype.forEach.call(t.content.cloneNode(true).childNodes, function (n) { 66 if (n.nodeName === 'SCRIPT') { 67 var s = document.createElement('script'); 68 Array.prototype.forEach.call(n.attributes, function (a) { s.setAttribute(a.name, a.value); }); 69 s.text = n.text; 70 document.head.appendChild(s); 71 } else if (n.nodeType === 1) { 72 document.body.appendChild(n); 73 } 74 }); 75 } 76 function toplist() { 77 var box = document.querySelector('[data-bmc-toplist]'); 78 if (!box || !C.toplist || box.firstChild) { return; } 79 var img = new Image(80, 15); 80 img.alt = 'TOPlist'; img.border = 0; 81 img.src = 'https://toplist.sk/count.asp?id=' + encodeURIComponent(C.toplist) + '&logo=btn&t=' + encodeURIComponent(document.title) + '&wi=' + screen.width + '&he=' + screen.height + '&cd=' + screen.colorDepth; 82 box.appendChild(img); 83 } 84 function unblockMedia() { 85 Array.prototype.forEach.call(document.querySelectorAll('iframe[data-bmc-src]'), function (f) { 86 f.setAttribute('src', f.getAttribute('data-bmc-src')); 87 f.removeAttribute('data-bmc-src'); 88 var w = f.closest ? f.closest('[data-bmc-embed]') : null; 89 if (w) { w.classList.add('bmc-embed--on'); } 90 }); 91 } 92 function apply(s) { 93 gtag('consent', 'update', { 94 analytics_storage: s.analytics ? 'granted' : 'denied', 95 ad_storage: s.marketing ? 'granted' : 'denied', 96 ad_user_data: s.marketing ? 'granted' : 'denied', 97 ad_personalization: s.marketing ? 'granted' : 'denied' 98 }); 99 if (s.analytics && !applied.analytics) { 100 applied.analytics = true; 101 if (C.ga4) { ensureGtag(C.ga4); gtag('config', C.ga4); } 102 runTpl('analytics'); 103 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', toplist); } else { toplist(); } 104 } 105 if (s.marketing && !applied.marketing) { 106 applied.marketing = true; 107 if (C.ads) { ensureGtag(C.ads); gtag('config', C.ads); } 108 if (C.meta) { 109 /* Meta Pixel â Å¡tandardný kód */ 110 (function (f, b, e, v, n, t, x) { if (f.fbq) { return; } n = f.fbq = function () { if (n.callMethod) { n.callMethod.apply(n, arguments); } else { n.queue.push(arguments); } }; if (!f._fbq) { f._fbq = n; } n.push = n; n.loaded = true; n.version = '2.0'; n.queue = []; t = b.createElement(e); t.async = true; t.src = v; x = b.getElementsByTagName(e)[0]; x.parentNode.insertBefore(t, x); })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js'); 111 window.fbq('init', C.meta); 112 window.fbq('track', 'PageView'); 113 } 114 runTpl('marketing'); 115 } 116 if (s.media && !applied.media) { 117 applied.media = true; 118 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', unblockMedia); } else { unblockMedia(); } 119 } 120 } 121 if (state) { apply(state); } 122 123 /* ---------- záznam súhlasu na serveri ---------- */ 124 function log(s, action) { 125 if (!C.log) { return; } 126 try { 127 var fd = new FormData(); 128 fd.append('id', s.id); fd.append('c', bits(s)); fd.append('a', action); fd.append('u', location.pathname + location.search); 129 if (navigator.sendBeacon && navigator.sendBeacon(C.log, fd)) { return; } 130 fetch(C.log, { method: 'POST', body: fd, credentials: 'same-origin', keepalive: true }); 131 } catch (e) {} 132 } 133 134 /* ---------- uloženie voľby ---------- */ 135 function save(s, action) { 136 var prev = state; 137 s.id = (prev && prev.id) || rid(); 138 OPT.forEach(function (k) { if (!C.active[k]) { s[k] = false; } }); 139 var withdrawn = []; 140 if (prev) { OPT.forEach(function (k) { if (prev[k] && !s[k]) { withdrawn.push(k); } }); } 141 if (withdrawn.length) { action = 'withdraw'; } 142 write(s); 143 state = read() || s; 144 log(s, action); 145 closeModal(); hideBar(); 146 if (withdrawn.length) { 147 clearTrackers(withdrawn); 148 setTimeout(function () { location.reload(); }, 150); // zastaviÅ¥ už spustené skripty 149 return; 150 } 151 apply(s); 152 updateState(); 153 } 154 function all(v) { var s = {}; OPT.forEach(function (k) { s[k] = v && !!C.active[k]; }); return s; } 155 156 /* ---------- liÅ¡ta ---------- */ 157 function barText() { 158 if (C.text) { return esc(C.text); }
159 var ph = { analytics: BM_L.ck_ph_analytics, marketing: BM_L.ck_ph_marketing, media: BM_L.ck_ph_media }; 160 var n = OPT.filter(function (k) { return !!C.active[k]; }).map(function (k) { return ph[k]; }); 161 var list = n.length > 1 ? n.slice(0, -1).join(', ') + ' ' + BM_L.and + ' ' + n[n.length - 1] : n[0]; 162 return BM_L.ck_bar1 + ' ' + esc(list) + 163 BM_L.ck_bar2; 164 } 165 function showBar() { 166 if (bar) { bar.hidden = false; return; } 167 bar = document.createElement('div'); 168 bar.className = 'bmc'; 169 bar.id = 'bmc'; 170 bar.setAttribute('role', 'region'); 171 bar.setAttribute('aria-label', BM_L.ck_aria); 172 bar.innerHTML = '<div class="bmc__in"><div class="bmc__txt"><p class="bmc__t">' + esc(C.title) + '</p><p>' + barText() + 173 (C.policy ? ' <a href="' + esc(C.policy) + '">' + BM_L.ck_policy + '</a>' : '') + '</p></div>' + 174 '<div class="bmc__btns"><button type="button" class="bmc__b bmc__b--main" data-bmc-act="reject">' + BM_L.ck_reject + '</button>' + 175 '<button type="button" class="bmc__b bmc__b--line" data-bmc-act="settings">' + BM_L.ck_settings + '</button>' + 176 '<button type="button" class="bmc__b bmc__b--main" data-bmc-act="accept">' + BM_L.ck_accept + '</button></div></div>'; 177 document.body.appendChild(bar); 178 } 179 function hideBar() { if (bar) { bar.hidden = true; } } 180 181 /* ---------- nastavenia (modálne okno) ---------- */ 182 function openModal() { 183 lastFocus = document.activeElement; 184 var cur = state || all(false); 185 if (!modal) { 186 modal = document.createElement('div'); 187 modal.className = 'bmc-m'; 188 modal.id = 'bmc-m'; 189 document.body.appendChild(modal); 190 } 191 var rows = C.cats.map(function (c) { 192 var nec = c.id === 'necessary', on = nec || !!cur[c.id]; 193 return '<div class="bmc-m__cat"><label class="bmc-m__row"><span class="bmc-m__name">' + esc(c.name) + (nec ? ' <small>' + BM_L.ck_always + '</small>' : '') + '</span>' + 194 '<span class="bmc-sw"><input type="checkbox" data-bmc-cat="' + esc(c.id) + '"' + (on ? ' checked' : '') + (nec ? ' disabled' : '') + ' aria-label="' + esc(c.name) + '"><span class="bmc-sw__s" aria-hidden="true"></span></span></label>' + 195 '<p class="bmc-m__desc">' + esc(c.desc) + '</p></div>'; 196 }).join(''); 197 modal.innerHTML = '<div class="bmc-m__bg" data-bmc-act="close"></div><div class="bmc-m__box" role="dialog" aria-modal="true" aria-labelledby="bmc-m-t" tabindex="-1">' + 198 '<button type="button" class="bmc-m__x" data-bmc-act="close" aria-label="' + BM_L.close + '">Ã</button>' + 199 '<p class="bmc-m__t" id="bmc-m-t">' + BM_L.cookie_settings + '</p>' + 200 '<p class="bmc-m__intro">' + BM_L.ck_intro.replace('%s', Math.round(C.days / 30)) + 201 (C.policy ? ' ' + BM_L.ck_list_in + ' <a href="' + esc(C.policy) + '">' + BM_L.ck_policy_in + '</a>.' : '') + '</p>' + rows + 202 '<div class="bmc-m__btns"><button type="button" class="bmc__b bmc__b--main" data-bmc-act="reject">' + BM_L.ck_reject + '</button>' + 203 '<button type="button" class="bmc__b bmc__b--line" data-bmc-act="save">' + BM_L.ck_save + '</button>' + 204 '<button type="button" class="bmc__b bmc__b--main" data-bmc-act="accept">' + BM_L.ck_accept + '</button></div></div>'; 205 modal.hidden = false; 206 document.documentElement.classList.add('bmc-open'); 207 var box = modal.querySelector('.bmc-m__box'); 208 if (box) { box.focus(); } 209 } 210 function closeModal() { 211 if (!modal || modal.hidden) { return; } 212 modal.hidden = true; 213 document.documentElement.classList.remove('bmc-open'); 214 if (lastFocus && lastFocus.focus) { try { lastFocus.focus(); } catch (e) {} } 215 } 216 function fromModal() { 217 var s = all(false); 218 Array.prototype.forEach.call(modal.querySelectorAll('input[data-bmc-cat]'), function (i) { 219 var k = i.getAttribute('data-bmc-cat'); 220 if (k !== 'necessary') { s[k] = i.checked; } 221 }); 222 return s; 223 } 224 225 /* ---------- stav na stránke zásad ---------- */ 226 function updateState() { 227 Array.prototype.forEach.call(document.querySelectorAll('[data-bmc-state]'), function (el) { 228 if (!state) { el.textContent = BM_L.ck_none; return; } 229 var on = C.cats.filter(function (c) { return c.id === 'necessary' || state[c.id]; }).map(function (c) { return c.name.toLowerCase(); }); 230 var d = new Date(state.ts * 1000); 231 el.textContent = BM_L.ck_current + ' ' + on.join(', ') + '. ' + BM_L.ck_saved + ' ' + d.toLocaleDateString(BM_L.locale) + ' ' + d.toLocaleTimeString(BM_L.locale, { hour: '2-digit', minute: '2-digit' }) + ', ' + BM_L.ck_id + ' ' + state.id + '.'; 232 }); 233 } 234 235 /* ---------- udalosti ---------- */ 236 document.addEventListener('click', function (e) { 237 var t = e.target.closest ? e.target.closest('[data-bmc-act],[data-bmc-open],[data-bmc-media]') : null; 238 if (!t) { return; } 239 if (t.hasAttribute('data-bmc-open')) { e.preventDefault(); openModal(); return; } 240 if (t.hasAttribute('data-bmc-media')) { 241 e.preventDefault(); 242 var s = state ? { analytics: state.analytics, marketing: state.marketing, media: true }
242 : { analytics: false, marketing: false, media: true }; 243 save(s, 'media'); 244 return; 245 } 246 var a = t.getAttribute('data-bmc-act'); 247 if (a === 'accept') { save(all(true), 'accept_all'); } 248 else if (a === 'reject') { save(all(false), 'reject_all'); } 249 else if (a === 'settings') { openModal(); } 250 else if (a === 'save') { save(fromModal(), 'custom'); } 251 else if (a === 'close') { closeModal(); } 252 }); 253 document.addEventListener('keydown', function (e) { 254 if (e.key === 'Escape' && modal && !modal.hidden) { closeModal(); } 255 if (e.key === 'Tab' && modal && !modal.hidden) { 256 var f = modal.querySelectorAll('button, input:not([disabled]), a[href]'); 257 if (!f.length) { return; } 258 if (e.shiftKey && document.activeElement === f[0]) { e.preventDefault(); f[f.length - 1].focus(); } 259 else if (!e.shiftKey && document.activeElement === f[f.length - 1]) { e.preventDefault(); f[0].focus(); } 260 } 261 }); 262 263 window.bmCookies = { open: openModal, get: function () { return state; } }; 264 265 function init() { 266 var anyOpt = OPT.some(function (k) { return !!C.active[k]; }); 267 if (!state && anyOpt) { showBar(); } 268 updateState(); 269 } 270 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } 271})();
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.