PageSourceSearch

https://nyadagbladet.se/wp-content/cache/min/1/wp-content/themes/a…/js/privacy-consent.js?ver=1790081270

js nyadagbladet.se collected 2026-09-24 18:44:20 UTC 8,772 bytes, 35 lines download raw bytes

1(function(){'use strict';var root=document.querySelector('[data-aeon-privacy-consent]');if(!root)return;var mode=root.getAttribute('data-mode');var cookieName=root.getAttribute('data-cookie-name');var legacyCookieName=root.getAttribute('data-legacy-cookie-name');var expiryDays=Number(root.getAttribute('data-expiry-days'))||180;var secureCookie=root.getAttribute('data-cookie-secure')==='true'||window.location.protocol==='https:';var showBanner=root.getAttribute('data-show-banner')==='true';var upgradeMatomoCookies=root.getAttribute('data-matomo-upgrade-cookies')==='true';var focusBeforeDialog=null;function readCookie(name){var prefix=name+'=';return document.cookie.split(';').map(function(part){return part.trim()}).reduce(function(value,part){return value||(part.indexOf(prefix)===0?decodeURIComponent(part.slice(prefix.length)):'')},'')}
2function setCookie(name,value,days){var maxAge=Math.max(1,days)*86400;document.cookie=name+'='+encodeURIComponent(value)+'; path=/; max-age='+maxAge+'; SameSite=Lax'+(secureCookie?'; Secure':'')}
3function consentState(){var current=readCookie(cookieName);if(current.indexOf('v2:')===0)return current.slice(3);return readCookie(legacyCookieName)}
4function visitorOptedOut(){return readCookie('aeon_matomo_opt_out')==='true'}
5function resetStoredStatisticsChoices(){queueMatomo(['forgetUserOptOut']);expireCookie('aeon_matomo_opt_out');expireCookie(cookieName);expireCookie(legacyCookieName)}
6function cookieDomains(){var hostname=window.location.hostname;return hostname?['',hostname,'.'+hostname]:['']}
7function cookiePaths(){var paths=['/'];if(window.location.pathname&&window.location.pathname!=='/')paths.push(window.location.pathname);return paths}
8function expireCookie(name){cookieDomains().forEach(function(domain){cookiePaths().forEach(function(path){var value=name+'=; path='+path+'; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax';if(domain)value+='; domain='+domain;if(secureCookie)value+='; Secure';document.cookie=value})})}
9function removeAnalyticsCookies(){document.cookie.split(';').forEach(function(part){var name=part.trim().split('=')[0];if(/^_pk_/i.test(name)||/^_ga(?:_|$)/i.test(name))expireCookie(name)})}
10function dispatch(name,detail){window.dispatchEvent(new CustomEvent(name,{detail:detail}))}
11function queueMatomo(command){window._paq=window._paq||[];window._paq.push(command)}
12function activateHeld(provider,transform){var activated=0;document.querySelectorAll('script[type="text/plain"][data-aeon-consent-provider="'+provider+'"]').forEach(function(held){if(held.getAttribute('data-aeon-activated')==='true')return;var script=document.createElement('script');Array.prototype.forEach.call(held.attributes,function(attribute){if(attribute.name!=='type'&&attribute.name.indexOf('data-aeon-')!==0){script.setAttribute(attribute.name,attribute.value)}});script.text=transform?transform(held.textContent):held.textContent;script.setAttribute('data-aeon-consent-provider',provider);script.setAttribute('data-aeon-activated','true');held.parentNode.replaceChild(script,held);activated+=1});if(activated)dispatch('aeon:privacy-provider-activated',{provider:provider,mode:mode,count:activated});return activated}
13function removeCookielessDirective(code){return code.replace(/\/\* AEON_MATOMO_DISABLE_COOKIES \*\/\s*_paq\s*\.\s*push\s*\(\s*\[\s*['"]disableCookies['"]\s*\]\s*\)\s*;?\s*/gi,'')}
14function matomoIsActive(){return!!document.querySelector('script[data-aeon-consent-provider="matomo"][data-aeon-activated="true"]')}
15function activateMatomo(stage){if(visitorOptedOut()){queueMatomo(['optUserOut']);removeAnalyticsCookies();return 0}
16return activateHeld('matomo',stage==='cookies'?removeCookielessDirective:null)}
17function activateGoogle(){window.dataLayer=window.dataLayer||[];window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};window.gtag('consent','update',{ad_storage:'granted',analytics_storage:'granted',ad_user_data:'granted',ad_personalization:'granted'});return activateHeld('google')}
18function revokeAndReload(status){queueMatomo(['optUserOut']);queueMatomo(['forgetConsentGiven']);queueMatomo(['disableCookies']);removeAnalyticsCookies();dispatch('aeon:privacy-consent-change',{status:status,mode:mode});dispatch('aeon:privacy-consent',{status:status,mode:mode});window.location.reload()}
19function applyState(choice){if(mode==='unconditional_matomo'){resetStoredStatisticsChoices();activateHeld('matomo');return}
20if(mode==='cookieless_no_banner'){removeAnalyticsCookies();activateMatomo('cookieless');return}
21if(mode==='cookieless_upgrade'){if(choice==='accepted'){activateMatomo(upgradeMatomoCookies?'cookies':'cookieless');activateGoogle()}else{removeAnalyticsCookies();activateMatomo('cookieless')}
22return}
23if((mode==='strict_opt_in'||mode==='external_cmp')&&choice==='accepted'){activateMatomo('cookies');activateGoogle()}}
24function closeDialog(restoreFocus){root.hidden=!0;var panel=root.querySelector('[role="dialog"]');if(panel)panel.setAttribute('aria-modal','false');if(restoreFocus&&focusBeforeDialog&&typeof focusBeforeDialog.focus==='function')focusBeforeDialog.focus()}
25function focusableIn(panel){return Array.prototype.filter.call(panel.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not
25([tabindex="-1"])'),function(element){return element.offsetParent!==null})}
26function openDialog(event){if(!showBanner)return;focusBeforeDialog=event&&event.currentTarget?event.currentTarget:document.activeElement;root.hidden=!1;var panel=root.querySelector('[role="dialog"]');if(panel){panel.setAttribute('aria-modal','true');var focusable=focusableIn(panel);if(focusable.length){focusable[0].focus()}else if(typeof panel.focus==='function'){panel.focus()}}}
27function publishChoice(choice){dispatch('aeon:privacy-consent-change',{status:choice,mode:mode});dispatch('aeon:privacy-consent',{status:choice,mode:mode})}
28function choose(choice,persist){var previous=consentState();if(persist!==!1)setCookie(cookieName,'v2:'+choice,expiryDays);if(choice==='rejected'&&(previous==='accepted'||matomoIsActive())){revokeAndReload(choice);return}
29if(choice==='accepted'&&mode==='cookieless_upgrade'&&matomoIsActive()&&upgradeMatomoCookies){publishChoice(choice);window.location.reload();return}
30if(choice==='rejected')removeAnalyticsCookies();applyState(choice);closeDialog(!0);publishChoice(choice)}
31root.addEventListener('click',function(event){var button=event.target.closest('[data-aeon-consent-choice]');if(button)choose(button.getAttribute('data-aeon-consent-choice'),!0)});root.addEventListener('keydown',function(event){if(root.hidden)return;if(event.key==='Escape'){closeDialog(!0);return}
32if(event.key!=='Tab')return;var panel=root.querySelector('[role="dialog"]');if(!panel)return;var focusable=focusableIn(panel);if(!focusable.length){event.preventDefault();if(typeof panel.focus==='function')panel.focus();return}
33var first=focusable[0];var last=focusable[focusable.length-1];if(event.shiftKey&&document.activeElement===first){event.preventDefault();last.focus()}else if(!event.shiftKey&&document.activeElement===last){event.preventDefault();first.focus()}});document.querySelectorAll('[data-aeon-consent-open]').forEach(function(button){button.addEventListener('click',openDialog)});document.querySelectorAll('[data-aeon-matomo-opt-out-toggle]').forEach(function(button){function render(optedOut){button.setAttribute('aria-pressed',optedOut?'true':'false');button.textContent=button.getAttribute(optedOut?'data-aeon-opt-in-label':'data-aeon-opt-out-label')}
34render(visitorOptedOut());queueMatomo([function(){if(this&&typeof this.isUserOptedOut==='function'&&this.isUserOptedOut()){setCookie('aeon_matomo_opt_out','true',expiryDays);render(!0)}}]);button.addEventListener('click',function(){var optedOut=button.getAttribute('aria-pressed')==='true';if(optedOut){queueMatomo(['forgetUserOptOut']);setCookie('aeon_matomo_opt_out','false',expiryDays)}else{queueMatomo(['optUserOut']);setCookie('aeon_matomo_opt_out','true',expiryDays);removeAnalyticsCookies()}
35render(!optedOut);dispatch('aeon:privacy-matomo-opt-out-change',{optedOut:!optedOut});window.location.reload()})});window.addEventListener('aeon:privacy-external-consent',function(event){var status=event.detail&&event.detail.status;if(status==='accepted'||status==='rejected')choose(status,!1)});window.AeonNewsPrivacyAnalytics={getStatus:consentState,setStatisticsConsent:function(status){if(status==='accepted'||status==='rejected')choose(status,mode!=='external_cmp')},isMatomoOptedOut:visitorOptedOut};var initialChoice=mode==='external_cmp'?'':consentState();applyState(initialChoice);if(showBanner&&initialChoice!=='accepted'&&initialChoice!=='rejected'){openDialog()}else{closeDialog(!1)}}())

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.