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="' + focu
321sName.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 paintInFrame(frame, host) { 643 var doc; 644 try { doc = frame.contentDocument; } catch (e) { return false; } 645 if (!doc || !doc.body) { return false; } 646 if (doc.querySelector('.redim-cc-iframe-overlay')) { return true; } 647 648 var i18n = cfg.i18n || {}; 649 650 var tight = frame.clientHeight > 0 && frame.clientHeight < 200; 651 652 try { 653 var lg = cfg.lang || document.documentElement.lang || ''; 654 if (lg) { doc.documentElement.lang = lg; } 655 doc.title = String(i18n.iframeTitle || 'Blocked content from %s').replace('%s', host || '?'); 656 } catch (e) {} 657 css(doc.documentElement, { 'height': '100%' }); 658 css(doc.body, { 'height': '100%', 'margin': '0' }); 659 660 var box = doc.createElement('div'); 661 box.className = 'redim-cc-iframe-overlay'; 662 css(box, { 663 'box-sizing': 'border-box', 'width': '100%', 'height': '100%', 664 'display': 'flex', 'flex-direction': 'column', 'align-items': 'center', 665 'justify-content': 'center', 'gap': tight ? '8px' : '12px', 666 'padding': tight ? '10px' : '16px', 'text-align': 'center', 667 'overflow': 'auto', 'background': 'rgba(96, 98, 103, 0.35)', 668 'font-family': IFRAME_FONT 669 }); 670 671 var note = doc.createElement('p'); 672 note.className = 'redim-cc-iframe-note'; 673 note.textContent = iframeNotice(i18n, host); 674 css(note, { 675 'margin': '0', 'max-width': '44em', 'font-size': tight ? '12px' : '14px', 676 'line-height': '1.45', 'color': '#1d232b', 'background': 'rgba(255, 255, 255, 0.85)', 677 'padding': tight ? '6px 8px' : '8px 12px', 'border-radius': '6px' 678 }); 679 680 var btn = doc.createElement('button'); 681 btn.type = 'button'; 682 btn.className = 'redim-cc-iframe-load'; 683 btn.textContent = i18n.iframeLoad || 'Load content'; 684 css(btn, { 685 'min-height': tight ? '32px' : '44px', 'padding': tight ? '6px 14px' : '10px 22px', 686 'border': '0', 'border-radius': '6px', 'background': '#008511', 'color': '#ffffff', 687 'font-family': 'inherit', 'font-size': tight ? '13px' : '15px', 'font-weight': '600', 688 'line-height': '1.2', 'cursor': 'pointer' 689 }); 690 691 var tint = function (color) { 692 return function () { btn.style.setProperty('background', color, 'important'); }; 693 }; 694 btn.addEventListener('mouseenter', tint('#006b0e')); 695 btn.addEventListener('mouseleave', tint('#008511')); 696 btn.addEventListener('focus', tint('#006b0e')); 697 btn.addEventListener('blur', tint('#008511')); 698 btn.addEventListener('click', function () { allowFrame(frame); }); 699 700 box.appendChild(note); 701 box.appendChild(btn); 702 doc.body.appendChild(box); 703 704 return true; 705 } 706 707 var frameNoteSeq = 0; 708 function overlayBeside(frame, host) { 709 var i18n = cfg.i18n || {};
710 var overlay = document.createElement('div'); 711 overlay.className = 'redim-cc-iframe-overlay'; 712 713 var note = document.createElement('p'); 714 note.className = 'redim-cc-iframe-note'; 715 note.id = 'redim-cc-frame-note-' + (++frameNoteSeq); 716 note.textContent = iframeNotice(i18n, host); 717 718 frame.setAttribute('tabindex', '-1'); 719 frame.setAttribute('aria-describedby', note.id); 720 721 var btn = document.createElement('button'); 722 btn.type = 'button'; 723 btn.className = 'redim-cc-iframe-load'; 724 btn.textContent = i18n.iframeLoad || 'Load content'; 725 726 var ro = null; 727 function sync() { 728 729 var box = frame.getBoundingClientRect(); 730 var base = overlay.offsetParent; 731 var x = box.left + (window.pageXOffset || 0); 732 var y = box.top + (window.pageYOffset || 0); 733 if (base) { 734 var baseBox = base.getBoundingClientRect(); 735 x = box.left - baseBox.left + base.scrollLeft; 736 y = box.top - baseBox.top + base.scrollTop; 737 } 738 overlay.style.setProperty('left', x + 'px', 'important'); 739 overlay.style.setProperty('top', y + 'px', 'important'); 740 overlay.style.setProperty('width', frame.offsetWidth + 'px', 'important'); 741 overlay.style.setProperty('height', frame.offsetHeight + 'px', 'important'); 742 } 743 744 btn.addEventListener('click', function () { 745 allowFrame(frame); 746 if (ro) { try { ro.disconnect(); } catch (e) {} } 747 window.removeEventListener('resize', sync); 748 if (overlay.parentNode) { overlay.parentNode.removeChild(overlay); } 749 }); 750 751 overlay.appendChild(note); 752 overlay.appendChild(btn); 753 754 frame.parentNode.insertBefore(overlay, frame); 755 756 sync(); 757 try { ro = new ResizeObserver(sync); ro.observe(frame); } catch (e) {} 758 window.addEventListener('resize', sync); 759 } 760 761 function shieldIframe(frame) { 762 if (frame.getAttribute('data-redim-cc-shielded')) { return; } 763 frame.setAttribute('data-redim-cc-shielded', '1'); 764 765 var host = ''; 766 try { host = new URL(frame.getAttribute('data-redim-cc-src'), location.href).hostname; } catch (e) {} 767 768 var sandbox = frame.getAttribute('sandbox'); 769 if (sandbox !== null && !/(^|\s)allow-same-origin(\s|$)/i.test(sandbox)) { 770 overlayBeside(frame, host); 771 return; 772 } 773 774 var paint = function () { 775 return frame.getAttribute('data-redim-cc-blocked') ? paintInFrame(frame, host) : true; 776 }; 777 frame.addEventListener('load', paint); 778 if (!paint()) { 779 window.setTimeout(function () { 780 if (frame.getAttribute('data-redim-cc-blocked') && !paint()) { 781 overlayBeside(frame, host); 782 } 783 }, 800); 784 } 785 } 786 787 function shieldIframes() { 788 if (!(cfg.iframe && cfg.iframe.enabled)) { return; }
789 $all('iframe[data-redim-cc-blocked]').forEach(shieldIframe); 790 791 try { 792 new MutationObserver(function () { 793 $all('iframe[data-redim-cc-blocked]').forEach(shieldIframe); 794 }).observe(document.body || document.documentElement, { childList: true, subtree: true }); 795 } catch (e) {} 796 } 797 798 function init() { 799 shieldIframes(); 800 wire(); 801 recordImpression(); 802 scan(function (data) { 803 fillCookies(data); 804 if (window.reDimCCAllowed) { 805 detectedNames().forEach(function (n) { 806 if (!window.reDimCCAllowed(n)) { 807 deleteCookie(n); 808 809 try { localStorage.removeItem(n); } catch (e) {} 810 try { sessionStorage.removeItem(n); } catch (e) {} 811 } 812 }); 813 } 814 }); 815 } 816 817 if (document.readyState === 'loading') { 818 document.addEventListener('DOMContentLoaded', init); 819 } else { 820 init(); 821 } 822})();
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.