1 2(function () { 3 'use strict'; 4 5 var cfg = window.reDimCC || {}; 6 7 var ccHost = document.getElementById('redim-cc-host'); 8 var ccRoot = (ccHost && ccHost.shadowRoot) ? ccHost.shadowRoot : document; 9 var banner = ccRoot.getElementById('redim-cookiehint-bottom') 10 || ccRoot.getElementById('redim-cookiehint-top') 11 || ccRoot.getElementById('redim-cookiehint-modal'); 12 13 function activeEl() { 14 var ae = document.activeElement; 15 while (ae && ae.shadowRoot && ae.shadowRoot.activeElement) { ae = ae.shadowRoot.activeElement; } 16 return ae; 17 } 18 19 try { 20 if (/[?&]cookiehint=/.test(location.search) && history.replaceState) { 21 var kept = location.search.slice(1).split('&').filter(function (p) { 22 return p !== '' && p.split('=')[0] !== 'cookiehint'; 23 }); 24 history.replaceState(null, document.title, location.pathname + (kept.length ? '?' + kept.join('&') : '') + location.hash); 25 } 26 } catch (e) {} 27 28 try { 29 if (location.hash === '#redim-cc-saved' && history.replaceState) { 30 history.replaceState(null, document.title, location.pathname + location.search); 31 announce((cfg.i18n || {}).saved || 'Selection saved'); 32 var savedBadge = document.querySelector('button.redim-cc-reopen'); 33 if (savedBadge) { try { savedBadge.focus(); } catch (e) {} } 34 } 35 } catch (e) {} 36 37 var catCfg = {}; 38 (cfg.categories || []).forEach(function (c) { catCfg[c.key] = c; }); 39 40 var touchedCats = {}; 41 42 function $all(sel, root) { 43 return Array.prototype.slice.call((root || document).querySelectorAll(sel)); 44 } 45 function escHtml(s) { 46 var d = document.createElement('div'); 47 d.textContent = (s == null ? '' : String(s)); 48 return d.innerHTML; 49 } 50 51 function cookiePaths() { 52 var out = ['/']; 53 try { 54 var segs = location.pathname.split('/'), acc = ''; 55 for (var i = 0; i < segs.length; i++) { 56 if (!segs[i]) { continue; } 57 acc += '/' + segs[i]; 58 out.push(acc); 59 out.push(acc + '/'); 60 } 61 } catch (e) {} 62 return out; 63 } 64 function deleteCookie(name) { 65 66 var domains = ['']; 67 try { 68 var parts = location.hostname.split('.'); 69 for (var i = 0; i < parts.length - 1; i++) { domains.push('; domain=.' + parts.slice(i).join('.')); } 70 } catch (e) {} 71 cookiePaths().forEach(function (p) { 72 domains.forEach(function (d) { 73 document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=' + p + d; 74 }); 75 }); 76 } 77 function escAttr(s) { return escHtml(s).replace(/"/g, '"'); } 78 79 var pendingAnnounce = ''; 80 function announce(msg) { 81 var live = document.getElementById('redim-cc-live'); 82 if (!live || !msg) { return; } 83 live.textContent = ''; 84 window.setTimeout(function () { live.textContent = msg; }, 60); 85 } 86 87 var inerted = []; 88 function inertBackground() { 89 if (!banner || !('inert' in HTMLElement.prototype)) { return; } 90 var node = banner; 91 92 var root = banner.getRootNode ? banner.getRootNode() : document; 93 if (root && root.host) { node = root.host; } 94 while (node && node !== document.body && node.parentNode) { 95 var siblings = node.parentNode.children; 96 for (var i = 0; i < siblings.length; i++) { 97 var sib = siblings[i]; 98 if (sib === node || sib.inert || sib.hasAttribute('data-redim-cc-keep') 99 || (sib.classList && sib.classList.contains('redim-cc-reopen'))) { continue; } 100 sib.inert = true; 101 inerted.push(sib); 102 } 103 node = node.parentNode; 104 } 105 } 106 function releaseBackground() { 107 for (var i = 0; i < inerted.length; i++) { inerted[i].inert = false; } 108 inerted = []; 109 } 110 111 function setCookie(name, value, days, secure, sameSite) { 112 var s = name + '=' + encodeURIComponent(value) + '; path=/'; 113 if (days > 0) { 114 var d = new Date(); 115 d.setTime(d.getTime() + days * 864e5); 116 s += '; expires=' + d.toUTCString(); 117 } 118 var ss = (sameSite || 'lax'); 119 ss = ss.charAt(0).toUpperCase() + ss.slice(1); 120 s += '; SameSite=' + ss; 121 if (secure || (sameSite || '').toLowerCase() === 'none') { s += '; Secure'; } 122 document.cookie = s; 123 } 124 125 var OWNKEY = 'reDimCCOwn'; 126 127 var SHOWNKEY = 'reDimCCShown'; 128 function isInternal(n) { return n === OWNKEY || n === SHOWNKEY; } 129 130 function detectedEntries() { 131 var types = {}; 132 try { 133 document.cookie.split(';').forEach(function (c) { 134 var n = c.split('=')[0].trim(); 135 if (n && !types[n]) { types[n] = 'cookie'; } 136 }); 137 } catch (e) {} 138 try { for (var i = 0; i < localStorage.length; i++) { var lk = localStorage.key(i); if (lk && !isInternal(lk) && !types[lk]) { types[lk] = 'local'; } } } catch (e) {} 139 try { for (var j = 0; j < sessionStorage.length; j++) { var sk = sessionStorage.key(j); if (sk && !isInternal(sk) && !types[sk]) { types[sk] = 'session'; } } } catch (e) {} 140 141 try {
142 (window.reDimCCSwept || []).forEach(function (n) { 143 if (n && !isInternal(n) && !types[n]) { types[n] = (window.reDimCCSweptTypes || {})[n] || 'cookie'; } 144 }); 145 } catch (e) {} 146 147 try { 148 var ownT = window.reDimCCOwnTypes || {}; 149 for (var ok in ownT) { if (ok && !isInternal(ok) && !types[ok]) { types[ok] = ownT[ok]; } } 150 } catch (e) {} 151 return types; 152 } 153 function detectedNames() { return Object.keys(detectedEntries()); } 154 155 function collectOwn(cb) { 156 var own = {}; 157 try { 158 var t = window.reDimCCOwnTypes || {}; 159 for (var k in t) { if (k && !isInternal(k)) { own[k] = 1; } } 160 } catch (e) {} 161 var done = function () { cb(Object.keys(own)); }; 162 try { 163 if (window.cookieStore && window.cookieStore.getAll) { 164 window.cookieStore.getAll().then(function (list) { 165 try { 166 (list || []).forEach(function (c) { 167 if (c && c.name && !isInternal(c.name) && (c.domain === null || c.domain === location.hostname)) { own[c.name] = 1; } 168 }); 169 } catch (e) {} 170 done(); 171 }, done); 172 return; 173 } 174 } catch (e) {} 175 done(); 176 } 177 178 function blockedScripts() { 179 var out = []; 180 try { 181 $all('script[data-redim-cc-script]').forEach(function (el) { 182 var src = el.getAttribute('data-redim-cc-src'); 183 if (src && out.indexOf(src) === -1) { out.push(src); } 184 }); 185 } catch (e) {} 186 return out; 187 } 188 189 function scan(cb) { 190 if (!cfg.ajaxUrl) { cb(null); return; } 191 var entries = detectedEntries(); 192 collectOwn(function (own) { 193 try { 194 var xhr = new XMLHttpRequest(); 195 xhr.open('POST', cfg.ajaxUrl, true); 196 xhr.setRequestHeader('Content-Type', 'application/json'); 197 xhr.onreadystatechange = function () { 198 if (xhr.readyState !== 4) { return; } 199 var data = null; 200 try { 201 var res = JSON.parse(xhr.responseText); 202 data = (res && typeof res.data !== 'undefined') ? res.data : res; 203 if (Array.isArray(data)) { data = data[0]; } 204 } catch (e) {} 205 cb(data); 206 }; 207 xhr.send(JSON.stringify({ names: Object.keys(entries), types: entries, own: own, blocked: blockedScripts() })); 208 } catch (e) { cb(null); } 209 }); 210 } 211 212 function categoryToggles() { return $all('.redim-cc-cat-toggle', banner); } 213 214 function setCatCount(catKey, n) { 215 var el = banner && banner.querySelector('.redim-cc-cat-count[data-cat="' + catKey + '"]'); 216 if (el) { el.textContent = ' (' + n + ')'; } 217 } 218 219 function sessionCookieEntries() { 220 var list = cfg.sessionCookies || (cfg.sessionCookie ? [cfg.sessionCookie] : []); 221 var out = []; 222 list.forEach(function (s) { 223 if (!s || !s.name || s.show === false) { return; } 224 out.push({ 225 name: s.name, 226 service: s.service || '', 227 paren: true, 228 locked: true, 229 forceOn: true, 230 category: s.category || 'essential' 231 }); 232 }); 233 return out; 234 } 235 236 function fillCookies(data) { 237 238 if (!banner) { return; } 239 data = data || {}; 240 var cats = data.categories || {}; 241 242 sessionCookieEntries().reverse().forEach(function (sess) { 243 var ek = sess.category; 244 if (!cats[ek]) { cats[ek] = { cookies: [] }; } 245 if (!cats[ek].cookies.some(function (c) { return c && c.name === sess.name; })) { 246 cats[ek].cookies.unshift(sess); 247 } 248 }); 249 250 var filledCats = 0, totalCookies = 0;
251 Object.keys(cats).forEach(function (catKey) { 252 var list = banner.querySelector('.redim-cc-cookies[data-cat="' + catKey + '"]'); 253 var catDiv = banner.querySelector('.redim-cc-cat[data-cat="' + catKey + '"]'); 254 if (!list) { return; } 255 var cookies = (cats[catKey].cookies || []).slice(0, 200); 256 setCatCount(catKey, cookies.length); 257 if (cookies.length && catDiv) { catDiv.removeAttribute('hidden'); } 258 if (cookies.length) { filledCats++; totalCookies += cookies.length; } 259 260 var locked = !!(catCfg[catKey] && catCfg[catKey].locked); 261 var catToggle = banner.querySelector('.redim-cc-cat-toggle[data-cat="' + catKey + '"]'); 262 263 var focusName = null; 264 try { 265 var af = activeEl(); 266 if (af && list.contains(af) && af.getAttribute) { focusName = af.getAttribute('data-name'); } 267 } catch (e) {} 268 list.innerHTML = ''; 269 cookies.forEach(function (ck, idx) { 270 var rowLocked = locked || ck.locked; 271 272 var allowed; 273 if (!rowLocked && catToggle && touchedCats[catKey]) { 274 allowed = catToggle.checked; 275 } else { 276 allowed = (window.reDimCCAllowed ? window.reDimCCAllowed(ck.name) : false) || ck.forceOn; 277 } 278 if (ck.pending && !rowLocked) { 279 280 allowed = allowed && !!(catToggle && catToggle.checked); 281 } 282 var svc = ck.service 283 ? (ck.paren ? ' (' + escHtml(ck.service) + ')' : ' · ' + escHtml(ck.service)) 284 : ''; 285 286 var i18n = cfg.i18n || {}; 287 288 var pending = ck.pending 289 ? '<span class="redim-cc-cookie-pending">' + escHtml(i18n.pending || 'Not loaded yet') + '</span>' 290 : ''; 291 var meta = []; 292 if (ck.provider) { meta.push(escHtml(i18n.provider || 'Provider') + ': ' + escHtml(ck.provider)); } 293 if (ck.duration) { meta.push(escHtml(i18n.duration || 'Duration') + ': ' + escHtml(ck.duration)); } 294 var row = document.createElement('div'); 295 row.className = 'redim-cc-cookie'; 296 297 var rowId = 'redim-cc-ck-' + escAttr(catKey) + '-' + idx; 298 var rowName = String(i18n.allowCookie || 'Allow %s').replace('%s', ck.name); 299 var describedby = []; 300 if (rowLocked) { describedby.push(rowId + '-always'); } 301 if (ck.description) { describedby.push(rowId + '-desc'); } 302 if (meta.length) { describedby.push(rowId + '-meta'); } 303 row.innerHTML = 304 '<label class="redim-cc-switch redim-cc-switch-sm">' 305 + '<input type="checkbox" class="redim-cc-cookie-toggle" data-name="' + escAttr(ck.name) + '" data-cat="' + escAttr(catKey) + '"' 306 + ' aria-label="' + escAttr(rowName) + '"' 307 + (describedby.length ? ' aria-describedby="' + describedby.join(' ') + '"' : '') 308 + (allowed ? ' checked' : '') + (rowLocked ? ' aria-disabled="true"' : '') + ' />' 309 + '<span class="redim-cc-slider"></span>' 310 + '<span class="redim-cc-sr-only">' + escHtml(rowName) + '</span></label>' 311 + '<span class="redim-cc-cookie-name"><code>' + escHtml(ck.name) + '</code>' + svc + pending 312 + (rowLocked ? ' <span class="redim-cc-always-on" id="' + rowId + '-always">' + escHtml(i18n.alwaysOn || 'Always on') + '</span>' : '') 313 + '</span>' 314 + (ck.description ? '<span class="redim-cc-cookie-desc" id="' + rowId + '-desc">' + escHtml(ck.description) + '</span>' : '') 315 + (meta.length ? '<span class="redim-cc-cookie-meta" id="' + rowId + '-meta">' + meta.join(' · ') + '</span>' : ''); 316 list.appendChild(row);
317 }); 318 319 if (focusName !== null) { 320 try { 321 var refocus = list.querySelector('.redim-cc-cookie-toggle[data-name="' + focusName.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"]'); 322 if (refocus) { refocus.focus(); } 323 } catch (e) {} 324 } 325 }); 326 327 var i18nA = cfg.i18n || {}; 328 var scanMsg = String(i18nA.scanDone || 'Cookie scan finished: %1$s entries in %2$s categories') 329 .replace('%1$s', String(totalCookies)).replace('%2$s', String(filledCats)); 330 var detA = banner.querySelector('.redim-cc-details'); 331 if (detA && !detA.hasAttribute('hidden')) { announce(scanMsg); } else { pendingAnnounce = scanMsg; } 332 } 333 334 function gather() { 335 var accepted = []; 336 categoryToggles().forEach(function (box) { if (box.checked) { accepted.push(box.getAttribute('data-cat')); } }); 337 338 var overrides = {}; 339 $all('.redim-cc-cookie-toggle', banner).forEach(function (box) { 340 var catBox = banner.querySelector('.redim-cc-cat-toggle[data-cat="' + box.getAttribute('data-cat') + '"]'); 341 var catChecked = catBox ? catBox.checked : false; 342 if (box.checked !== catChecked) { overrides[box.getAttribute('data-name')] = box.checked; } 343 }); 344 return { c: accepted, o: overrides }; 345 } 346 347 function recordImpression() { 348 if (!banner || !cfg.statistics || !cfg.ajaxUrl) { return; } 349 350 var once = cfg.impressions !== 'pageview'; 351 if (once) { try { if (window.sessionStorage && sessionStorage.getItem(SHOWNKEY)) { return; } } catch (e) {} } 352 try { 353 var payload = JSON.stringify({ action: 'impression' }); 354 if (navigator.sendBeacon) { 355 navigator.sendBeacon(cfg.ajaxUrl, new Blob([payload], { type: 'application/json' })); 356 } else { 357 var xhr = new XMLHttpRequest(); 358 xhr.open('POST', cfg.ajaxUrl, true); 359 xhr.setRequestHeader('Content-Type', 'application/json'); 360 xhr.send(payload); 361 } 362 } catch (e) { return; } 363 if (once) { try { sessionStorage.setItem(SHOWNKEY, '1'); } catch (e) {} } 364 } 365 366 function recordDecision(prefs, done) { 367 if (!cfg.statistics || !cfg.ajaxUrl) { if (done) { done(); } return; } 368 try { 369 var payload = JSON.stringify({ action: 'record', categories: (prefs && prefs.c) ? prefs.c : [] }); 370 if (navigator.sendBeacon) { 371 navigator.sendBeacon(cfg.ajaxUrl, new Blob([payload], { type: 'application/json' })); 372 if (done) { done(); } 373 } else { 374 var xhr = new XMLHttpRequest(); 375 xhr.open('POST', cfg.ajaxUrl, true); 376 xhr.setRequestHeader('Content-Type', 'application/json'); 377 378 xhr.onloadend = function () { if (done) { done(); } }; 379 xhr.send(payload); 380 } 381 } catch (e) { if (done) { done(); } } 382 } 383 384 function pushConsentUpdate(accepted) { 385 var cm = cfg.consentMode || {}; 386 if (!cm.enabled) { return; } 387 try { 388 var map = {}; 389 (cfg.categories || []).forEach(function (cat) { 390 var granted = cat.locked || accepted.indexOf(cat.key) !== -1; 391 (cat.gtag || []).forEach(function (type) { 392 if (granted) { map[type] = 'granted'; } 393 else if (!(type in map)) { map[type] = 'denied'; } 394 }); 395 }); 396 window.dataLayer = window.dataLayer || []; 397 window.gtag = window.gtag || function () { dataLayer.push(arguments); }; 398 window.gtag('consent', 'update', map); 399 if (cm.adsRedaction) { window.gtag('set', 'ads_data_redaction', map.ad_storage !== 'granted'); } 400 window.dataLayer.push({ event: 'cookie_consent_update', cookie_consent: map }); 401 } catch (e) {} 402 } 403 404 function save(prefs) { 405 406 if (!navigator.cookieEnabled) { 407 announce((cfg.i18n || {}).noCookies || 'Cookies are disabled in this browser - the selection cannot be saved'); 408 if (banner) { 409 if (banner.contains(activeEl())) { 410 try { activeEl().blur(); } catch (e) {} 411 } 412 banner.setAttribute('hidden', ''); 413 }
414 releaseBackground(); 415 return; 416 } 417 var c = cfg.cookie || {}; 418 setCookie('reDimCookieConsent', JSON.stringify(prefs), c.days || 0, c.secure, c.sameSite); 419 setCookie('reDimCookieHint', '1', c.days || 0, c.secure, c.sameSite); 420 pushConsentUpdate((prefs && prefs.c) || []); 421 422 try { 423 if (history.replaceState) { 424 history.replaceState(null, document.title, location.pathname + location.search + '#redim-cc-saved'); 425 } 426 } catch (e) {} 427 announce((cfg.i18n || {}).saving || 'Saving your selection, the page is reloading'); 428 recordDecision(prefs, function () { window.location.reload(); }); 429 } 430 431 function wire() { 432 if (!banner) { return; } 433 434 var reopen = document.querySelector('button.redim-cc-reopen'); 435 var isModal = banner.id === 'redim-cookiehint-modal'; 436 437 function focusables() { 438 439 return $all('button, [href], input, select, textarea, iframe, summary, audio[controls], video[controls], [tabindex]', banner).filter(function (el) { 440 return !el.disabled && el.tabIndex >= 0 && el.getClientRects().length > 0 441 && getComputedStyle(el).visibility !== 'hidden'; 442 }); 443 } 444 445 function focusEl(el) { 446 if (!el) { return false; } 447 try { el.focus(); } catch (e) {} 448 return activeEl() === el; 449 } 450 function focusFirst() { 451 var f = focusables(); 452 for (var i = 0; i < f.length; i++) { 453 if (focusEl(f[i])) { return true; } 454 } 455 return false; 456 } 457 458 function focusDialog() { 459 if (!focusEl(banner)) { focusFirst(); } 460 } 461 function openBanner() { 462 banner.removeAttribute('hidden'); 463 if (reopen) { reopen.setAttribute('hidden', ''); } 464 if (isModal) { inertBackground(); } 465 var det = banner.querySelector('.redim-cc-details'); 466 var btn = banner.querySelector('.redim-cc-toggle-details'); 467 if (det && btn && det.hasAttribute('hidden')) { btn.click(); } 468 focusDialog(); 469 } 470 function closeBanner() { 471 releaseBackground(); 472 if (reopen) { reopen.removeAttribute('hidden'); } 473 474 if (banner.contains(activeEl())) { 475 if (!focusEl(reopen)) { try { activeEl().blur(); } catch (e) {} } 476 } 477 banner.setAttribute('hidden', ''); 478 if (reopen) { focusEl(reopen); } 479 } 480 481 if (!banner.hasAttribute('aria-labelledby') && !banner.hasAttribute('aria-label')) { 482 var headline = banner.querySelector('.redim-cc-head .redim-cc-headline'); 483 banner.setAttribute('aria-label', headline ? headline.textContent.trim() : ((cfg.i18n || {}).bannerLabel || 'Cookie notice')); 484 } 485 if (!banner.hasAttribute('role')) { 486 if (isModal) { 487 banner.setAttribute('role', 'dialog'); 488 banner.setAttribute('aria-modal', 'true'); 489 } else { 490 491 banner.setAttribute('role', 'region'); 492 } 493 } 494 if (reopen) { reopen.addEventListener('click', openBanner); } 495 if (isModal && !banner.hasAttribute('hidden')) { inertBackground(); focusDialog(); } 496 497 document.addEventListener('keydown', function (e) { 498 if (banner.hasAttribute('hidden')) { return; } 499 if (e.key === 'Escape') { 500 501 var det = banner.querySelector('.redim-cc-details'); 502 var btn = banner.querySelector('.redim-cc-toggle-details'); 503 if (det && btn && !det.hasAttribute('hidden')) { 504 e.preventDefault(); 505 btn.click(); 506 if (!focusEl(btn)) { window.setTimeout(function () { focusEl(btn); }, 320); } 507 return; 508 } 509 if (reopen) { e.preventDefault(); closeBanner(); } 510 return; 511 } 512 if (e.key !== 'Tab' || !isModal) { return; } 513 var f = focusables(); 514 if (!f.length) { return; } 515 var first = f[0], last = f[f.length - 1]; 516 517 if (!banner.contains(activeEl())) { 518 if (focusEl(e.shiftKey ? last : first)) { e.preventDefault(); } 519 return; 520 } 521 if (e.shiftKey && activeEl() === first) { 522 if (focusEl(last)) { e.preventDefault(); } 523 } else if (!e.shiftKey && activeEl() === last) { 524 if (focusEl(first)) { e.preventDefault(); } 525 } 526 }); 527
528 $all('.redim-cc-cat-count', banner).forEach(function (el) { el.textContent = ' (0)'; }); 529 530 var detailsBtn = banner.querySelector('.redim-cc-toggle-details'); 531 var details = banner.querySelector('.redim-cc-details'); 532 if (detailsBtn && details) { 533 detailsBtn.addEventListener('click', function () { 534 var willOpen = details.hasAttribute('hidden'); 535 if (willOpen) { details.removeAttribute('hidden'); } else { details.setAttribute('hidden', ''); } 536 detailsBtn.setAttribute('aria-expanded', willOpen ? 'true' : 'false'); 537 detailsBtn.classList.toggle('redim-cc-is-open', willOpen); 538 539 if (willOpen && pendingAnnounce) { announce(pendingAnnounce); pendingAnnounce = ''; } 540 }); 541 } 542 543 function lockedInputOf(target) { 544 var lbl = target && target.closest ? target.closest('.redim-cc-switch') : null; 545 var inp = lbl ? lbl.querySelector('input') : null; 546 return inp && inp.getAttribute('aria-disabled') === 'true' ? inp : null; 547 } 548 banner.addEventListener('click', function (e) { 549 if (lockedInputOf(e.target)) { e.preventDefault(); } 550 }); 551 banner.addEventListener('keydown', function (e) { 552 if ((e.key === ' ' || e.key === 'Enter') && lockedInputOf(e.target)) { e.preventDefault(); } 553 }); 554 banner.addEventListener('change', function (e) { 555 var t = e.target; 556 if (t && t.getAttribute && t.getAttribute('aria-disabled') === 'true') { t.checked = true; } 557 }); 558
559 categoryToggles().forEach(function (box) { 560 box.addEventListener('change', function () { 561 if (box.getAttribute('aria-disabled') === 'true') { return; } 562 var catKey = box.getAttribute('data-cat'); 563 touchedCats[catKey] = true; 564 $all('.redim-cc-cookie-toggle[data-cat="' + catKey + '"]', banner).forEach(function (cb) { 565 if (cb.getAttribute('aria-disabled') !== 'true') { cb.checked = box.checked; } 566 }); 567 }); 568 }); 569 570 $all('.redim-cc-cat-head', banner).forEach(function (head) { 571 var btn = head.querySelector('.redim-cc-detail-toggle'); 572 if (!btn) { return; } 573 var list = banner.querySelector('.redim-cc-cookies[data-cat="' + btn.getAttribute('data-cat') + '"]'); 574 if (!list) { return; } 575 head.addEventListener('click', function (e) { 576 if (e.target.closest('.redim-cc-switch')) { return; } 577 var hidden = list.hasAttribute('hidden'); 578 if (hidden) { list.removeAttribute('hidden'); } else { list.setAttribute('hidden', ''); } 579 btn.setAttribute('aria-expanded', hidden ? 'true' : 'false'); 580 }); 581 }); 582 583 var acceptAll = banner.querySelector('.redim-cc-accept-all'); 584 if (acceptAll) { 585 acceptAll.addEventListener('click', function () { 586 var all = [];
587 categoryToggles().forEach(function (b) { b.checked = true; all.push(b.getAttribute('data-cat')); }); 588 save({ c: all, o: {} }); 589 }); 590 } 591 592 var rejectAll = banner.querySelector('.redim-cc-reject'); 593 if (rejectAll) { 594 rejectAll.addEventListener('click', function () { 595 596 var msg = (cfg.i18n || {}).reallyReject; 597 if (msg && !window.confirm(msg)) { return; } 598 var keep = []; 599 categoryToggles().forEach(function (b) { 600 if (b.getAttribute('aria-disabled') === 'true') { b.checked = true; keep.push(b.getAttribute('data-cat')); } else { b.checked = false; } 601 }); 602 save({ c: keep, o: {} }); 603 }); 604 } 605 606 var saveBtn = banner.querySelector('.redim-cc-save'); 607 if (saveBtn) { saveBtn.addEventListener('click', function () { save(gather()); }); } 608 } 609 610 function allowFrame(frame) { 611 var src = frame.getAttribute('data-redim-cc-src'); 612 frame.setAttribute('data-redim-cc-allowed', '1'); 613 frame.removeAttribute('data-redim-cc-blocked'); 614 frame.removeAttribute('data-redim-cc-shielded'); 615 frame.removeAttribute('aria-describedby'); 616 if (src) { frame.setAttribute('src', src); } 617 618 frame.setAttribute('tabindex', '-1'); 619 try { frame.focus(); } catch (e) {} 620 var restoreTab = function () { 621 frame.removeAttribute('tabindex'); 622 frame.removeEventListener('load', restoreTab); 623 }; 624 frame.addEventListener('load', restoreTab); 625 announce((cfg.i18n || {}).frameLoading || 'Content is loading'); 626 } 627 628 function css(el, decls) { 629 for (var prop in decls) { 630 if (Object.prototype.hasOwnProperty.call(decls, prop)) { 631 el.style.setProperty(prop, decls[prop], 'important'); 632 } 633 } 634 } 635 636 var IFRAME_FONT = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif'; 637 638 function iframeNotice(i18n, host) { 639 return String(i18n.iframeNotice || 'This content is provided by %s.').replace('%s', host || '?'); 640 } 641 642 function buttonColors() { 643 var bg = '', fg = ''; 644 try { 645 var cs = window.getComputedStyle(document.documentElement); 646 bg = String(cs.getPropertyValue('--redim-cc-btn-bg') || '').trim(); 647 fg = String(cs.getPropertyValue('--redim-cc-btn-fg') || '').trim(); 648 } catch (e) {} 649 return { bg: bg || '#008511', fg: fg || '#ffffff' }; 650 } 651 652 function paintInFrame(frame, host) { 653 var doc; 654 try { doc = frame.contentDocument; } catch (e) { return false; } 655 if (!doc || !doc.body) { return false; } 656 if (doc.querySelector('.redim-cc-iframe-overlay')) { return true; } 657 658 var i18n = cfg.i18n || {}; 659 660 var tight = frame.clientHeight > 0 && frame.clientHeight < 200; 661 662 try { 663 var lg = cfg.lang || document.documentElement.lang || ''; 664 if (lg) { doc.documentElement.lang = lg; } 665 doc.title = String(i18n.iframeTitle || 'Blocked content from %s').replace('%s', host || '?'); 666 } catch (e) {} 667 css(doc.documentElement, { 'height': '100%' }); 668 css(doc.body, { 'height': '100%', 'margin': '0' }); 669 670 var box = doc.createElement('div'); 671 box.className = 'redim-cc-iframe-overlay'; 672 css(box, { 673 'box-sizing': 'border-box', 'width': '100%', 'height': '100%', 674 'display': 'flex', 'flex-direction': 'column', 'align-items': 'center', 675 'justify-content': 'center', 'gap': tight ? '8px' : '12px', 676 'padding': tight ? '10px' : '16px', 'text-align': 'center', 677 'overflow': 'auto', 'background': 'rgba(96, 98, 103, 0.35)', 678 'font-family': IFRAME_FONT 679 }); 680 681 var note = doc.createElement('p'); 682 note.className = 'redim-cc-iframe-note'; 683 note.textContent = iframeNotice(i18n, host); 684 css(note, { 685 'margin': '0', 'max-width': '44em', 'font-size': tight ? '12px' : '14px', 686 'line-height': '1.45', 'color': '#1d232b', 'background': 'rgba(255, 255, 255, 0.85)', 687 'padding': tight ? '6px 8px' : '8px 12px', 'border-radius': '6px' 688 }); 689 690 var btn = doc.createElement('button'); 691 btn.type = 'button'; 692 btn.className = 'redim-cc-iframe-load'; 693 btn.textContent = i18n.iframeLoad || 'Load content'; 694 var colors = buttonColors(); 695 css(btn, { 696 'min-height': tight ? '32px' : '44px', 'padding': tight ? '6px 14px' : '10px 22px', 697 'border': '0', 'border-radius': '6px', 'background': colors.bg, 'color': colors.fg, 698 'font-family': 'inherit', 'font-size': tight ? '13px' : '15px', 'font-weight': '600', 699 'line-height': '1.2', 'cursor': 'pointer' 700 }); 701 702 var hovered = false, focused = false; 703 var ring = function () { 704 if (hovered || focused) { 705 btn.style.setProperty('box-shadow', 'inset 0 0 0 2px currentColor', 'important'); 706 } else { 707 btn.style.removeProperty('box-shadow'); 708 } 709 }; 710 btn.addEventListener('mouseenter', function () { hovered = true; ring(); }); 711 btn.addEventListener('mouseleave', function () { hovered = false; ring(); }); 712 btn.addEventListener('focus', function () { focused = true; ring(); }); 713 btn.addEventListener('blur', function () { focused = false; ring(); }); 714 btn.addEventListener('click', function () { allowFrame(frame); }); 715 716 box.appendChild(note); 717 box.appendChild(btn); 718 doc.body.appendChild(box); 719 720 return true; 721 } 722 723 var frameNoteSeq = 0; 724 function overlayBeside(frame, host) { 725 var i18n = cfg.i18n || {};
726 var overlay = document.createElement('div'); 727 overlay.className = 'redim-cc-iframe-overlay'; 728 729 var note = document.createElement('p'); 730 note.className = 'redim-cc-iframe-note'; 731 note.id = 'redim-cc-frame-note-' + (++frameNoteSeq); 732 note.textContent = iframeNotice(i18n, host); 733 734 frame.setAttribute('tabindex', '-1'); 735 frame.setAttribute('aria-describedby', note.id); 736 737 var btn = document.createElement('button'); 738 btn.type = 'button'; 739 btn.className = 'redim-cc-iframe-load'; 740 btn.textContent = i18n.iframeLoad || 'Load content'; 741 742 var ro = null; 743 function sync() { 744 745 var box = frame.getBoundingClientRect(); 746 var base = overlay.offsetParent; 747 var x = box.left + (window.pageXOffset || 0); 748 var y = box.top + (window.pageYOffset || 0); 749 if (base) { 750 var baseBox = base.getBoundingClientRect(); 751 x = box.left - baseBox.left + base.scrollLeft; 752 y = box.top - baseBox.top + base.scrollTop; 753 } 754 overlay.style.setProperty('left', x + 'px', 'important'); 755 overlay.style.setProperty('top', y + 'px', 'important'); 756 overlay.style.setProperty('width', frame.offsetWidth + 'px', 'important'); 757 overlay.style.setProperty('height', frame.offsetHeight + 'px', 'important'); 758 } 759 760 btn.addEventListener('click', function () { 761 allowFrame(frame); 762 if (ro) { try { ro.disconnect(); } catch (e) {} } 763 window.removeEventListener('resize', sync); 764 if (overlay.parentNode) { overlay.parentNode.removeChild(overlay); } 765 }); 766 767 overlay.appendChild(note); 768 overlay.appendChild(btn); 769 770 frame.parentNode.insertBefore(overlay, frame); 771 772 sync(); 773 try { ro = new ResizeObserver(sync); ro.observe(frame); } catch (e) {} 774 window.addEventListener('resize', sync); 775 } 776 777 function shieldIframe(frame) { 778 if (frame.getAttribute('data-redim-cc-shielded')) { return; } 779 frame.setAttribute('data-redim-cc-shielded', '1'); 780 781 var host = ''; 782 try { host = new URL(frame.getAttribute('data-redim-cc-src'), location.href).hostname; } catch (e) {} 783 784 var sandbox = frame.getAttribute('sandbox'); 785 if (sandbox !== null && !/(^|\s)allow-same-origin(\s|$)/i.test(sandbox)) { 786 overlayBeside(frame, host); 787 return; 788 } 789 790 var paint = function () { 791 return frame.getAttribute('data-redim-cc-blocked') ? paintInFrame(frame, host) : true; 792 }; 793 frame.addEventListener('load', paint); 794 if (!paint()) { 795 window.setTimeout(function () { 796 if (frame.getAttribute('data-redim-cc-blocked') && !paint()) { 797 overlayBeside(frame, host); 798 } 799 }, 800); 800 } 801 } 802 803 function shieldIframes() { 804 if (!(cfg.iframe && cfg.iframe.enabled)) { return; }
805 $all('iframe[data-redim-cc-blocked]').forEach(shieldIframe); 806 807 try { 808 new MutationObserver(function () { 809 $all('iframe[data-redim-cc-blocked]').forEach(shieldIframe); 810 }).observe(document.body || document.documentElement, { childList: true, subtree: true }); 811 } catch (e) {} 812 } 813 814 function init() { 815 shieldIframes(); 816 wire(); 817 recordImpression(); 818 scan(function (data) { 819 fillCookies(data); 820 if (window.reDimCCAllowed) { 821 detectedNames().forEach(function (n) { 822 if (!window.reDimCCAllowed(n)) { 823 deleteCookie(n); 824 825 try { localStorage.removeItem(n); } catch (e) {} 826 try { sessionStorage.removeItem(n); } catch (e) {} 827 } 828 }); 829 } 830 }); 831 } 832 833 if (document.readyState === 'loading') { 834 document.addEventListener('DOMContentLoaded', init); 835 } else { 836 init(); 837 } 838})();
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.