'use strict';
let cmplz_cookie_data=[];
let cmplzCleanCookieInterval;
function cmplz_create_element(el, content){
const obj=document.createElement(el);
obj.innerHtml=content;
return obj;
}
function cmplz_add_event(event, selector, callback){
document.addEventListener(event,(e)=> {
if(e.target.closest(selector) ){
callback(e);
}});
}
function cmplz_is_hidden(el){
return(el.offsetParent===null);
}
function cmplz_html_decode(input){
const doc=new DOMParser().parseFromString(input, 'text/html');
return doc.documentElement.textContent;
}
function cmplz_trap_focus(){
if(! cmplz_banner){
return;
}
if(! complianz.soft_cookiewall){
return;
}
cmplz_original_active_element=document.activeElement;
document.body.classList.add('cmplz-banner-active');
cmplz_banner.addEventListener('keydown', cmplz_handle_tab_navigation);
const focusableElements=cmplz_banner.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);
if(focusableElements.length > 0){
focusableElements[ 0 ].focus();
}}
function cmplz_handle_tab_navigation(e){
if(e.key==='Tab'){
const focusableElements=cmplz_banner.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);
if(focusableElements.length===0){
return;
}
const firstElement=focusableElements[ 0 ];
const lastElement=focusableElements[ focusableElements.length - 1 ];
if(e.shiftKey){
if(document.activeElement===firstElement){
e.preventDefault();
lastElement.focus();
}}else{
if(document.activeElement===lastElement){
e.preventDefault();
firstElement.focus();
}}
}}
function cmplz_release_focus_trap(){
if(cmplz_banner){
cmplz_banner.removeEventListener('keydown', cmplz_handle_tab_navigation);
}
document.body.classList.remove('cmplz-banner-active');
if(cmplz_original_active_element&&cmplz_original_active_element.focus){
try {
cmplz_original_active_element.focus();
} catch(e){
document.body.focus();
}}
}
document.querySelectorAll('.cmplz-consent-area.cmplz-placeholder').forEach(( cmplzConsentArea)=> {
cmplzConsentArea.addEventListener('click',(e)=> {
let container=e.target;
if(! container.classList.contains('cmplz-consent-area') ){
container=e.target.closest('.cmplz-consent-area.cmplz-placeholder');
}
if(container){
const consentedService=container.getAttribute('data-service');
cmplz_set_service_consent(consentedService, true);
cmplzLoadConsentAreaContent(false, consentedService);
cmplz_enable_category(null, consentedService);
cmplz_set_banner_status('dismissed');
}});
document.addEventListener('cmplz_enable_category', function(consentData){
const consentedCategory=consentData.detail.category;
const consentedService=consentData.detail.service;
cmplzLoadConsentAreaContent(consentedCategory, consentedService);
});
});
function cmplzLoadConsentAreaContent(consentedCategory, consentedService){
document.querySelectorAll('.cmplz-consent-area.cmplz-placeholder').forEach(( obj)=> {
const category=obj.getAttribute('data-category');
const service=obj.getAttribute('data-service');
const postId=obj.getAttribute('data-post_id');
const blockId=obj.getAttribute('data-block_id');
if(consentedCategory===category||consentedService===service){
const request=new XMLHttpRequest();
request.open('GET', complianz.url + 'consent-area/' + postId + '/' + blockId, true);
request.setRequestHeader('Content-type', 'application/json');
request.send();
obj.classList.remove('cmplz-placeholder');
request.onload=function(){
obj.innerHTML=JSON.parse(request.response);
obj.querySelectorAll('script').forEach(( scriptEl)=> {
cmplz_run_script(scriptEl.innerHTML, category, service, 'inline', scriptEl);
});
};}});
}
document.addEventListener('cmplz_manage_consent_container_loaded', function(){
const url=window.location.href;
if(url.indexOf('#')!=-1){
const end_pos=url.lastIndexOf('?')!=-1 ? url.lastIndexOf('?'):undefined;
const anchor=url.substring(url.indexOf('#') + 1, end_pos);
const element=document.getElementById(anchor);
if(element){
const y=element.getBoundingClientRect().top + window.pageYOffset - 200;
window.scrollTo({ top: y, behavior: 'smooth' });
}}
});
complianz.locale=complianz.locale + '&token=' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
(function(){
if(typeof window.CustomEvent==='function'){
return false;
}
function CustomEvent(event, params){
params=params||{ bubbles: false, cancelable: false, detail: undefined };
const evt=document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype=window.Event.prototype;
window.CustomEvent=CustomEvent;
}());
let cmplz_banner;
const cmplz_banner_container=document.getElementById('cmplz-cookiebanner-container');
let cmplz_manage_consent_button;
const cmplz_waiting_inline_scripts=[];
const cmplz_waiting_scripts=[];
const cmplz_fired_scripts=[];
let cmplz_placeholder_class_index=0;
let cmplz_all_scripts_hook_fired=false;
let cmplz_consent_stored_once=false;
const cmplz_fired_category_events=[ 'functional' ];
const cmplz_fired_service_events=[];
const cmplz_categories=[
'functional',
'preferences',
'statistics',
'marketing',
];
var cmplz_original_active_element=null;
window.cmplz_get_cookie=function(name){
if(typeof document==='undefined'){
return '';
}
name=complianz.prefix + name;
const cookies=document.cookie.split(';');
for(let i=0; i < cookies.length; i++){
const cookie=cookies[ i ].trim();
if(cookie.startsWith(name + '=') ){
return cookie.substring(name.length + 1);
}}
return '';
};
window.cmplz_set_cookie=function(name, value, use_prefix){
if(typeof document==='undefined'){
return;
}
use_prefix=typeof use_prefix!=='undefined' ? use_prefix:true;
const secure=window.location.protocol==='https:' ? ';secure':'';
const date=new Date();
date.setTime(date.getTime() +(complianz.cookie_expiry * 24 * 60 * 60 * 1000) );
const expires=';expires=' + date.toGMTString();
const domain=cmplz_get_cookie_domain();
const domainString=domain.length > 0 ? `;domain=${ domain }`:'';
const prefix=use_prefix ? complianz.prefix:'';
const cookiePath=cmplz_get_cookie_path();
document.cookie=`${ prefix }${ name }=${ value };SameSite=Lax${ secure }${ expires }${ domainString };path=${ cookiePath }`;
};
window.cmplz_in_array=function(needle, haystack){
return haystack.includes(needle);
};
window.cmplz_highest_accepted_category=function(){
const consentedCategories=cmplz_accepted_categories();
const priorityCategories=[ 'marketing', 'statistics', 'preferences' ];
for(let i=0; i < priorityCategories.length; i++){
if(cmplz_in_array(priorityCategories[ i ], consentedCategories) ){
return priorityCategories[ i ];
}}
return 'functional';
};
const cmplz_set_category_as_body_class=()=> {
const classList=document.body.classList;
for(let i=classList.length - 1; i >=0; i--){
if(classList[ i ].startsWith('cmplz-')&&classList[ i ]!=='cmplz-document'){
classList.remove(classList[ i ]);
}}
const cats=cmplz_accepted_categories();
Object.values(cats).forEach(( category)=> {
if(typeof category==='string'){
classList.add('cmplz-' + category);
}});
const services=cmplz_get_all_service_consents();
Object.entries(services).forEach(( [ service, consent ])=> {
if(consent){
classList.add('cmplz-' + service);
}});
classList.add('cmplz-' + complianz.region, 'cmplz-' + complianz.consenttype);
const event=new CustomEvent('cmplz_set_category_as_bodyclass');
document.dispatchEvent(event);
};
const cmplz_append_css=(css)=> {
const head=document.head||document.getElementsByTagName('head')[ 0 ];
const style=document.createElement('style');
style.setAttribute('type', 'text/css');
style.appendChild(document.createTextNode(css) );
head.appendChild(style);
};
const cmplz_load_css=(path)=> {
const head=document.head||document.getElementsByTagName('head')[ 0 ];
const targetObj=document.createElement('link');
targetObj.rel='stylesheet';
targetObj.type='text/css';
targetObj.href=path;
head.appendChild(targetObj);
};
function cmplz_run_script(script, category, service, type, sourceObj){
const targetObj=document.createElement('script');
if(type!=='inline'){
targetObj.src=script;
}else{
if(typeof script!=='string'){
script=script.innerHTML;
}
targetObj.innerHTML=[ script, 'cmplzScriptLoaded();' ].join('\n');
}
if(cmplz_in_array(script, cmplz_fired_scripts) ){
return;
}
cmplzCopyAttributes(sourceObj, targetObj);
try {
if(type!=='inline'){
targetObj.onload=function(){
cmplz_run_after_all_scripts(category, service);
cmplz_maybe_run_waiting_scripts(script, category, service, sourceObj);
};}else{
window.cmplzScriptLoaded=function(){
cmplz_run_after_all_scripts(category, service);
cmplz_maybe_run_waiting_scripts(script, category, service, sourceObj);
};}
document.head.appendChild(targetObj);
} catch(exception){
cmplz_run_after_all_scripts(category, service);
throw 'Something went wrong ' + exception + ' while loading ' + script;
}}
function cmplz_maybe_run_waiting_scripts(script, category, service, sourceObj){
const waitingScript=cmplz_get_waiting_script(cmplz_waiting_scripts, script);
if(waitingScript){
cmplz_run_script(waitingScript, category, service, 'src', sourceObj);
}
const waiting_inline_script=cmplz_get_waiting_script(cmplz_waiting_inline_scripts, script);
if(waiting_inline_script){
cmplz_run_script(waiting_inline_script, category, service, 'inline', sourceObj);
}}
const cmplzLazyLoader=()=> {
const cmplzLazyLoadElements=document.querySelectorAll('.cmplz-blocked-content-container');
const cmplzObserver=new IntersectionObserver(( entries, observer)=> {
entries.forEach(( entry)=> {
if(entry.isIntersecting){
const element=entry.target;
const src=element.getAttribute('data-placeholder-image');
if(src){
const index=element.getAttribute('data-placeholder_class_index');
cmplz_append_css('.cmplz-placeholder-' + index + ' {background-image: url(' + src + ') !important;}');
cmplz_set_blocked_content_container_aspect_ratio(element, src, index);
}
observer.unobserve(element);
}});
});
cmplzLazyLoadElements.forEach(( element)=> {
cmplzObserver.observe(element);
});
};
function cmplz_set_blocked_content_container(){
document.querySelectorAll('.cmplz-image').forEach(( obj)=> {
if(obj.classList.contains('cmplz-processed') ){
return;
}
obj.classList.add('cmplz-processed');
const service=obj.getAttribute('data-service');
const category=obj.getAttribute('data-category');
const blocked_image_container=obj.parentElement;
blocked_image_container.classList.add('cmplz-blocked-content-container');
const curIndex=blocked_image_container.getAttribute('data-placeholder_class_index');
if(obj.getAttribute('loading')==='lazy'){
obj.removeAttribute('loading');
obj.setAttribute('data-deferlazy', 1);
}
if(curIndex==null){
cmplz_placeholder_class_index++;
blocked_image_container.classList.add('cmplz-placeholder-' + cmplz_placeholder_class_index, 'cmplz-blocked-content-container');
blocked_image_container.setAttribute('data-placeholder_class_index', cmplz_placeholder_class_index);
cmplz_insert_placeholder_text(blocked_image_container, category, service);
}});
document.querySelectorAll('.cmplz-placeholder-element').forEach(( obj)=> {
if(obj.classList.contains('cmplz-processed') ){
return;
}
obj.classList.add('cmplz-processed');
const service=obj.getAttribute('data-service');
const category=obj.getAttribute('data-category');
let blocked_content_container;
if(obj.classList.contains('cmplz-iframe') ){
if(obj.getAttribute('loading')==='lazy'){
obj.removeAttribute('loading');
obj.setAttribute('data-deferlazy', 1);
}
blocked_content_container=obj.parentElement;
}else{
blocked_content_container=obj;
}
const curIndex=blocked_content_container.getAttribute('data-placeholder_class_index');
if(curIndex===null){
cmplz_placeholder_class_index++;
blocked_content_container.classList.add('cmplz-placeholder-' + cmplz_placeholder_class_index, 'cmplz-blocked-content-container');
blocked_content_container.setAttribute('data-placeholder_class_index', cmplz_placeholder_class_index);
cmplz_insert_placeholder_text(blocked_content_container, category, service);
const src=obj.getAttribute('data-placeholder-image');
if(src&&typeof src!=='undefined'&&src.length){
blocked_content_container.setAttribute('data-placeholder-image', src);
}}
});
cmplzLazyLoader();
if(cmplz_has_consent('statistics') ){
cmplz_enable_category('statistics');
}
if(cmplz_has_consent('marketing') ){
cmplz_enable_category('marketing');
}}
function cmplz_insert_placeholder_text(container, category, service){
if(! container.querySelector('.cmplz-blocked-content-notice') ){
let placeholder_text=complianz.placeholdertext;
category=category||'marketing';
let body;
if(typeof placeholder_text!=='undefined'){
if(complianz.clean_cookies==1){
let service_nicename=service ? service.replace('-', ' '):'';
service_nicename=service_nicename.charAt(0).toUpperCase() + service_nicename.slice(1);
placeholder_text=placeholder_text.replace('{service}', service_nicename);
body=cmplz_create_element('div', placeholder_text);
body.innerHTML=placeholder_text;
body.classList.add('cmplz-blocked-content-notice');
const btn=body.querySelector('button');
btn.setAttribute('data-service', service);
btn.setAttribute('data-category', category);
btn.setAttribute('aria-label', complianz.aria_label.replace('{service}', service_nicename) );
const pageLinks=complianz.page_links[ complianz.region ];
const link=body.querySelector('.cmplz-links a');
if(pageLinks&&pageLinks.hasOwnProperty('cookie-statement') ){
link.setAttribute('href', pageLinks[ 'cookie-statement' ].url);
if(link.innerText==='{title}'){
link.innerText=pageLinks[ 'cookie-statement' ].title;
}}else if(link){
link.parentElement.style.display='none';
}}else{
const btn=cmplz_create_element('button', '');
const category_nicename=complianz.categories.hasOwnProperty(category) ? complianz.categories[ category ]:'marketing';
btn.innerText=placeholder_text.replace('{category}', category_nicename);
btn.classList.add('cmplz-blocked-content-notice', 'cmplz-accept-category', 'cmplz-accept-' + category); //'cmplz-accept-'+category is deprecated
btn.setAttribute('data-service', service);
btn.setAttribute('data-category', category);
btn.setAttribute('aria-label', complianz.aria_label.replace('{category}', category) );
body=btn;
}
if(container.tagName!=='VIDEO'){
container.appendChild(body);
}else{
container.parentElement.appendChild(body);
}}
}}
function cmplz_set_blocked_content_container_aspect_ratio(container, src, placeholder_class_index){
if(container==null){
return;
}
const img=new Image();
img.addEventListener('load', function(){
const imgWidth=this.naturalWidth||1;
const imgHeight=this.naturalHeight;
const w=container.clientWidth;
const h=imgHeight *(w / imgWidth);
const heightCSS=src.indexOf('placeholder.jpg')===-1 ? 'height:' + h + 'px;':'';
cmplz_append_css('.cmplz-placeholder-' + placeholder_class_index + ' {' + heightCSS + '}');
});
img.src=src;
}
let cmplzResizeTimer;
window.addEventListener('resize', function(){
clearTimeout(cmplzResizeTimer);
cmplzResizeTimer=setTimeout(cmplz_set_blocked_content_container, 500);
}, true);
if(complianz.block_ajax_content==1){
setInterval(function(){
cmplz_set_blocked_content_container();
}, 2000);
}
function cmplz_has_blocked_scripts(){
const scriptElements=document.querySelectorAll('script[data-category], script[data-service]');
return scriptElements.length > 0;
}
function cmplz_enable_category(category, service){
if(complianz.tm_categories==1&&category!==''){
cmplz_run_tm_event(category);
}
const details={};
details.category=category;
details.categories=cmplz_accepted_categories();
details.region=complianz.region;
const event=new CustomEvent('cmplz_before_category', { detail: details });
document.dispatchEvent(event);
service=typeof service!=='undefined' ? service:'do_not_match';
if(category===''){
category='do_not_match';
}
if(category==='functional'){
return;
}
if(category==='marketing'){
cmplz_set_integrations_cookies();
}
let selector;
if(service!=='do_not_match'){
selector='.cmplz-blocked-content-notice [data-service="' + service + '"]';
}else{
selector=complianz.clean_cookies!=1 ? '.cmplz-blocked-content-notice.cmplz-accept-' + category:'.cmplz-blocked-content-notice [data-category="' + category + '"]';
}
document.querySelectorAll(selector).forEach(( obj)=> {
const blockedElementService=obj.getAttribute('data-service');
if(obj.parentNode.classList.contains('cmplz-blocked-content-notice') ){
obj=obj.parentNode;
}
if(! cmplz_is_service_denied(blockedElementService) ){
obj.parentNode.removeChild(obj);
}});
document.querySelectorAll('[data-category="' + category + '"], [data-service="' + service + '"]').forEach(( obj)=> {
const elementService=obj.getAttribute('data-service');
if(cmplz_is_service_denied(elementService) ){
return;
}
if(obj.getAttribute('data-category')==='functional'){
return;
}
if(obj.classList.contains('cmplz-activated') ){
return;
}
const tagName=obj.tagName;
if(tagName==='LINK'){
obj.classList.add('cmplz-activated');
const src=obj.getAttribute('data-href');
cmplz_load_css(src, category);
}else if(tagName==='IMG'){
obj.classList.add('cmplz-activated');
const src=obj.getAttribute('data-src-cmplz');
obj.setAttribute('src', src);
if(obj.getAttribute('data-deferlazy') ){
obj.setAttribute('loading', 'lazy');
}
cmplz_remove_placeholder(obj);
}else if(tagName==='IFRAME'){
obj.classList.add('cmplz-activated');
let src=obj.getAttribute('data-src-cmplz');
const srcAttribute=obj.getAttribute('data-cmplz-target') ? obj.getAttribute('data-cmplz-target'):'src';
const autoplay=cmplz_get_url_parameter(obj.getAttribute(srcAttribute), 'autoplay');
if(autoplay==='1'){
src=src + '&autoplay=1';
}
if(obj.getAttribute('data-deferlazy') ){
obj.setAttribute('loading', 'lazy');
}
obj.addEventListener('load', ()=> {
cmplz_remove_placeholder(obj);
});
obj.setAttribute(srcAttribute, src);
}else if(obj.classList.contains('cmplz-placeholder-element') ){
obj.classList.add('cmplz-activated');
const cssIndex=obj.getAttribute('data-placeholder_class_index');
obj.classList.remove('cmplz-blocked-content-container', 'cmplz-placeholder-' + cssIndex);
}});
const scriptElements=document.querySelectorAll('script[data-category="' + category + '"], script[data-service="' + service + '"]');
scriptElements.forEach(( obj)=> {
const waitfor=obj.getAttribute('data-waitfor');
const src=obj.getAttribute('data-cmplz-src');
if(waitfor){
if(src){
cmplz_waiting_scripts[ waitfor ]=src;
}else if(obj.innerText.length > 0){
cmplz_waiting_inline_scripts[ waitfor ]=obj;
}}
if(obj.parentElement){
obj.parentElement.removeChild(obj);
}});
scriptElements.forEach(( obj)=> {
const script_mime_type=obj.getAttribute('type');
if(obj.classList.contains('cmplz-activated')||(! script_mime_type||script_mime_type==='text/javascript') ){
return;
}
obj.classList.add('cmplz-activated');
const src=obj.getAttribute('data-cmplz-src');
if(src){
obj.removeAttribute('type');
if(cmplz_is_waiting_script(cmplz_waiting_scripts, src) ){
return;
}
if(obj.getAttribute('data-post_scribe_id') ){
const psID='#' + obj.getAttribute('data-post_scribe_id');
const postScribeObj=document.querySelector(psID);
if(postScribeObj){
postScribeObj.innerHtml('');
postscribe(psID, '<script src=' + src + '></script>');
}}else{
cmplz_run_script(src, category, service, 'src', obj);
}}else if(obj.innerText.length > 0){
if(cmplz_is_waiting_script(cmplz_waiting_inline_scripts, obj.innerText) ){
return;
}
cmplz_run_script(obj.innerText, category, service, 'inline', obj);
}});
cmplz_run_after_all_scripts(category, service);
}
function cmplz_remove_placeholder(obj){
const blocked_content_container=obj.closest('.cmplz-blocked-content-container');
if(blocked_content_container){
const cssIndex=blocked_content_container.getAttribute('data-placeholder_class_index');
blocked_content_container.classList.remove('cmplz-blocked-content-container', 'cmplz-placeholder-' + cssIndex);
}
obj.classList.remove('cmplz-iframe-styles', 'cmplz-iframe', 'video-wrap');
}
function cmplz_get_waiting_script(waiting_scripts, src){
for(const waitfor in waiting_scripts){
if(waiting_scripts.hasOwnProperty(waitfor) ){
if(src.indexOf(waitfor)!==-1){
const output=waiting_scripts[ waitfor ];
delete waiting_scripts[ waitfor ];
return output;
}}
}
return false;
}
function cmplz_array_is_empty(arr){
for(const key in arr){
if(arr.hasOwnProperty(key) ){
return false;
}}
return true;
}
function cmplz_is_waiting_script(waiting_scripts, srcOrScript){
for(const waitfor in waiting_scripts){
if(waiting_scripts.hasOwnProperty(waitfor) ){
let waitingScript=waiting_scripts[ waitfor ];
if(typeof waitingScript!=='string'){
waitingScript=waitingScript.innerText;
}
if(srcOrScript.indexOf(waitingScript)!==-1||waitingScript.indexOf(srcOrScript)!==-1){
return true;
}}
}
return false;
}
function cmplz_run_after_all_scripts(category, service){
const enableService=service!=='do_not_match'&&! cmplz_in_array(service, cmplz_fired_service_events);
const enableCategory=category!=='do_not_match'&&! cmplz_in_array(category, cmplz_fired_category_events);
if(enableCategory||enableService){
if(enableCategory){
cmplz_fired_category_events.push(category);
}
if(enableService){
cmplz_fired_service_events.push(service);
}
const details={};
details.category=category;
details.service=service;
details.categories=cmplz_accepted_categories();
details.services=cmplz_get_all_service_consents();
details.region=complianz.region;
const event=new CustomEvent('cmplz_enable_category', { detail: details });
document.dispatchEvent(event);
}
if(! cmplz_all_scripts_hook_fired&&cmplz_array_is_empty(cmplz_waiting_inline_scripts)&&cmplz_array_is_empty(cmplz_waiting_scripts) ){
const event=new CustomEvent('cmplz_run_after_all_scripts', { detail: category, service });
document.dispatchEvent(event);
cmplz_all_scripts_hook_fired=true;
}}
const cmplz_fired_events=[];
function cmplz_run_tm_event(category){
if(cmplz_fired_events.indexOf(category)===-1){
cmplz_fired_events.push(category);
window.dataLayer=window.dataLayer||[];
window.dataLayer.push({
event: 'cmplz_event_' + category,
});
const event=new CustomEvent('cmplz_tag_manager_event', { detail: category });
document.dispatchEvent(event);
}}
window.cmplz_accept_all=function(){
cmplz_clear_all_service_consents();
cmplz_fire_before_categories_consent(cmplz_categories);
for(const key in cmplz_categories){
if(cmplz_categories.hasOwnProperty(key) ){
cmplz_set_consent(cmplz_categories[ key ], 'allow');
}}
cmplz_sync_category_checkboxes();
};
function cmplz_fire_before_categories_consent(categories){
const details={};
details.categories=categories;
details.region=complianz.region;
const event=new CustomEvent('cmplz_before_categories_consent', { detail: details });
document.dispatchEvent(event);
}
window.cmplz_deny_all=function(){
for(const key in cmplz_categories){
if(cmplz_categories.hasOwnProperty(key) ){
cmplz_set_consent(cmplz_categories[ key ], 'deny');
}}
const consentLevel=cmplz_highest_accepted_category();
let reload=false;
if(consentLevel!=='functional'||cmplz_exists_service_consent()){
reload=true;
}
if(cmplz_clear_cookies('cmplz_service') ){
reload=true;
}
cmplz_clear_all_service_consents();
cmplz_integrations_revoke();
cmplz_fire_categories_event();
cmplz_track_status();
const event=new CustomEvent('cmplz_revoke', { detail: reload });
document.dispatchEvent(event);
if(! complianz.tcf_active&&reload){
cmplz_reload_browser_compatible();
}};
function cmplz_check_cookie_policy_id(){
const user_policy_id=cmplz_get_cookie('policy_id');
if(user_policy_id&&(parseInt(complianz.current_policy_id)!==parseInt(user_policy_id) )){
cmplz_deny_all();
cmplz_set_banner_status('show');
cmplz_clear_cookies('cmplz');
}}
window.conditionally_show_banner=function(){
complianz=cmplz_merge_object(complianz, cmplz_user_data);
cmplz_maybe_auto_redirect();
cmplz_set_blocked_content_container();
window.wp_consent_type=complianz.consenttype;
let event=new CustomEvent('wp_consent_type_defined');
document.dispatchEvent(event);
event=new CustomEvent('cmplz_before_cookiebanner');
document.dispatchEvent(event);
if(complianz.forceEnableStats==1&&complianz.consenttype==='optin'){
cmplz_set_consent('statistics', 'allow');
}
const rev_cats=cmplz_categories.reverse();
const consented_categories=[];
for(const key in rev_cats){
if(rev_cats.hasOwnProperty(key) ){
const category=cmplz_categories[ key ];
if(cmplz_has_consent(category) ){
consented_categories.push(category);
}}
}
cmplz_fire_before_categories_consent(consented_categories);
for(const key in consented_categories){
if(rev_cats.hasOwnProperty(key) ){
const category=consented_categories[ key ];
cmplz_enable_category(category);
}}
if(cmplz_exists_service_consent()){
cmplz_enable_category('', 'general');
const services=cmplz_get_services_on_page();
for(const key in services){
if(services.hasOwnProperty(key) ){
const service=services[ key ].service;
const category=services[ key ].category;
if(cmplz_has_service_consent(service, category) ){
document.querySelectorAll('.cmplz-accept-service[data-service="' + service + '"]').forEach(( obj)=> {
obj.checked=true;
});
cmplz_enable_category('', service);
}}
}}
cmplz_sync_category_checkboxes();
cmplz_integrations_init();
cmplz_check_cookie_policy_id();
cmplz_set_up_auto_dismiss();
cmplz_load_manage_consent_container();
event=new CustomEvent('cmplz_cookie_banner_data', { detail: complianz });
document.dispatchEvent(event);
if(cmplz_get_cookie('saved_categories')===''){
if(complianz.consenttype!=='optin'&&complianz.consenttype!=='optout'){
cmplz_track_status('no_warning');
}else if(cmplz_do_not_track()){
cmplz_track_status('do_not_track');
}}
cmplz_set_category_as_body_class();
cmplz_fire_categories_event();
if(! cmplz_do_not_track()){
if(complianz.consenttype==='optin'){
if(complianz.forceEnableStats){
cmplz_enable_category('statistics');
}
console.log('opt-in');
show_cookie_banner();
}else if(complianz.consenttype==='optout'){
console.log('opt-out');
show_cookie_banner();
}else{
console.log('other consent type, no cookie warning');
cmplz_accept_all();
}}else{
console.log('global privacy control or do not track detected: no banner.');
cmplz_track_status('do_not_track');
}};
function cmplz_do_not_track(){
const dnt='doNotTrack' in navigator&&navigator.doNotTrack==='1';
const gpc='globalPrivacyControl' in navigator&&navigator.globalPrivacyControl;
return !!(complianz.do_not_track_enabled&&(gpc||dnt) );
}
function cmplz_get_services_on_page(){
const services=[];
document.querySelectorAll('[data-service]').forEach(( obj)=> {
const service=obj.getAttribute('data-service');
const category=obj.getAttribute('data-category');
if(services.indexOf(service)==-1){
services.push({
category,
service,
});
}});
return services;
}
window.show_cookie_banner=function(){
let disableCookiebanner=complianz.disable_cookiebanner||cmplz_is_speedbot();
let tmpDismissCookiebanner=false;
if(document.querySelector('#cmplz-manage-consent-container')||document.querySelector('.cmplz-dropdown-cookiepolicy') ){
tmpDismissCookiebanner=true;
}
const container=document.getElementById('cmplz-cookiebanner-container');
if(container){
document.body.prepend(container);
}
const link=document.createElement('link');
const pageLinks=complianz.page_links[ complianz.region ];
cmplz_banner=document.querySelector('.cmplz-cookiebanner.banner-' + complianz.user_banner_id + '.' + complianz.consenttype);
if(! cmplz_banner){
disableCookiebanner=true;
}
cmplz_manage_consent_button=document.querySelector('#cmplz-manage-consent .cmplz-manage-consent.manage-consent-' + complianz.user_banner_id);
const css_file_url=complianz.css_file.replace('{type}', complianz.consenttype).replace('{banner_id}', complianz.user_banner_id);
if(complianz.css_file.indexOf('cookiebanner/css/defaults/banner')!==-1){
console.log('Fallback default css file used. Please re-save banner settings, or check file writing permissions in uploads directory');
}
link.href=css_file_url;
link.type='text/css';
link.rel='stylesheet';
link.onload=function(){
if(! disableCookiebanner){
cmplz_banner.classList.remove('cmplz-hidden');
cmplz_manage_consent_button.classList.remove('cmplz-hidden');
if(cmplz_get_banner_status()==='show'){
cmplz_trap_focus();
const closeButton=cmplz_banner.querySelector('.cmplz-close');
if(closeButton){
closeButton.focus();
}}
}};
document.getElementsByTagName('head')[ 0 ].appendChild(link);
if(cmplz_banner&&! disableCookiebanner){
cmplz_banner.querySelectorAll('.cmplz-links a:not(.cmplz-external), .cmplz-buttons a:not(.cmplz-external)').forEach(( obj)=> {
const docElement=obj;
docElement.classList.add('cmplz-hidden');
for(const pageType in pageLinks){
if(pageLinks.hasOwnProperty(pageType)&&docElement.classList.contains(pageType) ){
docElement.setAttribute('href', pageLinks[ pageType ].url + docElement.getAttribute('data-relative_url') );
if(docElement.innerText==='{title}'){
docElement.innerText=cmplz_html_decode(pageLinks[ pageType ].title);
}
docElement.classList.remove('cmplz-hidden');
}}
});
cmplz_set_banner_status();
if(tmpDismissCookiebanner){
cmplz_banner.classList.remove('cmplz-show');
cmplz_banner.classList.add('cmplz-dismissed');
cmplz_manage_consent_button.classList.remove('cmplz-dismissed');
cmplz_manage_consent_button.classList.add('cmplz-show');
}}
const event=new CustomEvent('cmplz_cookie_warning_loaded', { detail: complianz.region });
document.dispatchEvent(event);
};
window.cmplz_get_banner_status=function(){
return cmplz_get_cookie('banner-status');
};
window.cmplz_set_banner_status=function(status){
let prevStatus=cmplz_get_cookie('banner-status');
status=typeof status!=='undefined' ? status:prevStatus;
if(status!==prevStatus){
cmplz_set_cookie('banner-status', status);
}
if(status.length===0){
status='show';
}
if(status==='show'){
prevStatus='dismissed';
}else{
prevStatus='show';
}
if(cmplz_banner&&status.length > 0){
cmplz_banner.classList.remove('cmplz-' + prevStatus);
cmplz_banner.classList.add('cmplz-' + status);
if(cmplz_manage_consent_button){
cmplz_manage_consent_button.classList.add('cmplz-' + prevStatus);
cmplz_manage_consent_button.classList.remove('cmplz-' + status);
}}
if(cmplz_banner_container&&complianz.soft_cookiewall){
cmplz_banner_container.classList.remove('cmplz-' + prevStatus);
cmplz_banner_container.classList.add('cmplz-' + status, 'cmplz-soft-cookiewall');
}
const event=new CustomEvent('cmplz_banner_status', { detail: status });
document.dispatchEvent(event);
cmplz_start_clean();
if(status==='show'){
cmplz_trap_focus();
const closeButton=cmplz_banner.querySelector('.cmplz-close');
if(closeButton){
closeButton.focus();
}}else{
cmplz_release_focus_trap();
}};
function cmplz_is_bot(){
const botPattern='(googlebot\/|Googlebot-Mobile|Google-InspectionTool|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)';
const reBot=new RegExp(botPattern, 'i');
const userAgent=navigator.userAgent;
return reBot.test(userAgent);
}
function cmplz_is_speedbot(){
const userAgent=navigator.userAgent;
const speedBotPattern='(GTmetrix|pingdom|pingbot|Lighthouse)';
const speedBot=new RegExp(speedBotPattern, 'i');
return speedBot.test(userAgent);
}
window.cmplz_has_consent=function(category){
if(cmplz_is_bot()){
return true;
}
if(category==='functional'){
return true;
}
let has_consent, value;
if(cmplz_do_not_track()){
value=cmplz_get_cookie(category);
has_consent=(value==='allow');
return has_consent;
}
value=cmplz_get_cookie(category);
if(( complianz.consenttype==='optout'||complianz.consenttype==='other')&&value===''){
has_consent=true;
}else{
has_consent=(value==='allow');
}
return has_consent;
};
window.cmplz_is_service_denied=function(service){
const consented_services_json=cmplz_get_cookie('consented_services');
let consented_services;
try {
consented_services=JSON.parse(consented_services_json);
} catch(e){
consented_services={};}
if(! consented_services.hasOwnProperty(service) ){
return false;
}
return ! consented_services[ service ];
};
window.cmplz_has_service_consent=function(service, category){
const consented_services_json=cmplz_get_cookie('consented_services');
let consented_services;
try {
consented_services=JSON.parse(consented_services_json);
} catch(e){
consented_services={};}
if(! consented_services.hasOwnProperty(service) ){
return cmplz_has_consent(category);
}
return consented_services[ service ];
};
function cmplz_exists_service_consent(){
const consented_services_json=cmplz_get_cookie('consented_services');
let consented_services;
try {
consented_services=JSON.parse(consented_services_json);
for(const key in consented_services){
if(consented_services.hasOwnProperty(key) ){
if(consented_services[ key ]==true){
return true;
}}
}} catch(e){
return false;
}
return false;
}
function cmplz_set_service_consent(service, consented){
const consented_services_json=cmplz_get_cookie('consented_services');
let consented_services;
try {
consented_services=JSON.parse(consented_services_json);
} catch(e){
consented_services={};}
consented_services[ service ]=consented;
cmplz_set_cookie('consented_services', JSON.stringify(consented_services) );
const details={};
details.service=service;
details.value=consented;
details.region=complianz.region;
cmplz_all_scripts_hook_fired=false;
const event=new CustomEvent('cmplz_status_change_service', { detail: details });
document.dispatchEvent(event);
}
function cmplz_clear_all_service_consents(){
cmplz_set_cookie('consented_services', '');
}
function cmplz_get_all_service_consents(){
const consented_services_json=cmplz_get_cookie('consented_services');
let consented_services;
try {
consented_services=JSON.parse(consented_services_json);
} catch(e){
consented_services={};}
return consented_services;
}
function cmplz_get_cookie_path(){
return typeof complianz.cookie_path!=='undefined'&&complianz.cookie_path!=='' ? complianz.cookie_path:'/';
}
function cmplz_get_cookie_domain(){
if(complianz.set_cookies_on_root==1&&complianz.cookie_domain.length > 3&&! complianz.cookie_domain.includes('localhost') ){
return complianz.cookie_domain;
}
return '';
}
window.cmplz_set_consent=function(category, value){
cmplz_set_accepted_cookie_policy_id();
value=category==='functional' ? 'allow':value;
const previous_value=cmplz_get_cookie(category);
const checked=value==='allow';
document.querySelectorAll('input.cmplz-' + category).forEach(( obj)=> {
obj.checked=checked;
});
if(previous_value===value){
return;
}
cmplz_set_cookie(category, value);
if(value==='allow'){
cmplz_enable_category(category);
}
cmplz_wp_set_consent(category, value);
if(category==='statistics'){
cmplz_wp_set_consent('statistics-anonymous', 'allow');
}
const details=new Object();
details.category=category;
details.value=value;
details.region=complianz.region;
details.categories=cmplz_accepted_categories();
cmplz_all_scripts_hook_fired=false;
const event=new CustomEvent('cmplz_status_change', { detail: details });
document.dispatchEvent(event);
if(category==='marketing'&&value==='deny'&&previous_value==='allow'){
cmplz_integrations_revoke();
setTimeout(function(){
cmplz_reload_browser_compatible();
}, 500);
}};
function cmplz_reload_browser_compatible(){
if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
const url=new URL(window.location.href);
url.searchParams.set('cmplz-force-reload', Date.now().toString());
window.location.href=url.toString();
}else{
window.location.reload();
}}
let cmplz_user_data=[];
if(typeof(Storage)!=='undefined'&&sessionStorage.cmplz_user_data){
cmplz_user_data=JSON.parse(sessionStorage.cmplz_user_data);
}
if(complianz.geoip==1&&(cmplz_user_data.length==0||(cmplz_user_data.version!==complianz.version)||(cmplz_user_data.banner_version!==complianz.banner_version) )){
const request=new XMLHttpRequest();
let cmplzUserRegion=cmplz_get_url_parameter(window.location.href, 'cmplz_user_region');
cmplzUserRegion=cmplzUserRegion ? '&cmplz_user_region=' + cmplzUserRegion:'';
request.open('GET', complianz.url + 'banner?' + complianz.locale + cmplzUserRegion, true);
request.setRequestHeader('Content-type', 'application/json');
request.send();
request.onload=function(){
cmplz_user_data=JSON.parse(request.response);
sessionStorage.cmplz_user_data=JSON.stringify(cmplz_user_data);
conditionally_show_banner();
};}else{
conditionally_show_banner();
}
if(complianz.store_consent==1){
const cmplz_id_cookie=cmplz_get_cookie('id');
let cmplz_id_session='';
let cmplz_id='';
if(typeof(Storage)!=='undefined'&&sessionStorage.cmplz_id){
cmplz_id_session=JSON.parse(sessionStorage.cmplz_id);
}
if(cmplz_id_cookie.length==0&&cmplz_id_session.length > 0){
cmplz_id=cmplz_id_session;
cmplz_set_cookie('id', cmplz_id);
}
if(cmplz_id_cookie.length > 0&&cmplz_id_session.length==0){
cmplz_id=cmplz_id_cookie;
}
if(typeof(Storage)!=='undefined'){
sessionStorage.cmplz_id=JSON.stringify(cmplz_id);
}}
document.addEventListener('visibilitychange', function(){
if(document.visibilityState==='hidden'){
cmplz_track_status_end();
}});
window.addEventListener('pagehide', cmplz_track_status_end, false);
window.addEventListener('beforeunload', cmplz_track_status_end, false);
function cmplz_track_status_end(){
if(! cmplz_consent_stored_once){
cmplz_track_status();
}}
document.addEventListener('cmplz_consent_action', function(e){
cmplz_set_consent(e.detail.category, 'allow');
cmplz_fire_categories_event();
cmplz_track_status();
});
cmplz_add_event('click', '.cmplz-accept', function(e){
e.preventDefault();
setTimeout(()=> {
cmplz_accept_all();
cmplz_set_banner_status('dismissed');
cmplz_fire_categories_event();
cmplz_track_status();
}, 0);
});
cmplz_add_event('click', '.cmplz-accept-category, .cmplz-accept-marketing', function(e){
e.preventDefault();
const obj=e.target;
const service=obj.getAttribute('data-service');
let category=obj.getAttribute('data-category');
category=category ? category:'marketing';
if(complianz.clean_cookies==1&&typeof service!=='undefined'&&service){
cmplz_set_service_consent(service, true);
cmplz_enable_category('', 'general');
cmplz_enable_category('', service);
}else{
cmplz_set_consent(category, 'allow');
}
cmplz_set_banner_status('dismissed');
cmplz_fire_categories_event();
cmplz_track_status();
});
cmplz_add_event('click', '.cmplz-accept-service', function(e){
const obj=e.target;
const tagName=obj.tagName;
if(tagName==='INPUT'){
return;
}
const service=obj.getAttribute('data-service');
if(typeof service!=='undefined'){
cmplz_set_service_consent(service, true);
cmplz_enable_category('', 'general');
cmplz_enable_category('', service);
}
cmplz_fire_categories_event();
cmplz_track_status();
});
cmplz_add_event('change', '.cmplz-accept-service', function(e){
const obj=e.target;
const tagName=obj.tagName;
const service=obj.getAttribute('data-service');
if(typeof service!=='undefined'){
if(tagName==='INPUT'){
cmplz_set_banner_status('dismissed');
if(obj.checked){
cmplz_set_service_consent(service, true);
cmplz_enable_category('', service);
}else{
cmplz_set_service_consent(service, false);
setTimeout(function(){
cmplz_reload_browser_compatible();
}, 500);
}}else{
e.preventDefault();
cmplz_set_service_consent(service, true);
cmplz_enable_category('', 'general');
cmplz_enable_category('', service);
setTimeout(function(){
cmplz_reload_browser_compatible();
}, 500);
}}
cmplz_fire_categories_event();
cmplz_track_status();
});
cmplz_add_event('click', '.cmplz-save-preferences', function(e){
const obj=e.target;
cmplz_banner=obj.closest('.cmplz-cookiebanner');
const consented_categories=[];
for(const key in cmplz_categories){
if(cmplz_categories.hasOwnProperty(key) ){
const category=cmplz_categories[ key ];
const categoryElement=cmplz_banner.querySelector('input.cmplz-' + category);
if(categoryElement&&categoryElement.checked){
consented_categories.push(category);
}}
}
cmplz_fire_before_categories_consent(consented_categories);
for(const key in cmplz_categories){
if(cmplz_categories.hasOwnProperty(key) ){
const category=cmplz_categories[ key ];
if(consented_categories.includes(category) ){
cmplz_set_consent(category, 'allow');
}else{
cmplz_set_consent(category, 'deny');
}}
}
cmplz_set_banner_status('dismissed');
cmplz_fire_categories_event();
cmplz_track_status();
});
cmplz_add_event('click', '.cmplz-close', function(){
cmplz_set_banner_status('dismissed');
});
cmplz_add_event('click', '.cmplz-view-preferences', function(e){
const obj=e.target;
cmplz_banner=obj.closest('.cmplz-cookiebanner');
if(cmplz_banner.querySelector('.cmplz-categories').classList.contains('cmplz-fade-in') ){
cmplz_banner.classList.remove('cmplz-categories-visible');
cmplz_banner.querySelector('.cmplz-categories').classList.remove('cmplz-fade-in');
cmplz_banner.querySelector('.cmplz-view-preferences').style.display='block';
cmplz_banner.querySelector('.cmplz-save-preferences').style.display='none';
}else{
cmplz_banner.classList.add('cmplz-categories-visible');
cmplz_banner.querySelector('.cmplz-categories').classList.add('cmplz-fade-in');
cmplz_banner.querySelector('.cmplz-view-preferences').style.display='none';
cmplz_banner.querySelector('.cmplz-save-preferences').style.display='block';
const firstCategory=cmplz_banner.querySelector('.cmplz-categories .cmplz-category');
if(firstCategory){
const summary=firstCategory.querySelector('summary');
if(summary){
summary.setAttribute('tabindex', '0');
summary.focus();
}}
}});
cmplz_add_event('change', '.cmplz-manage-consent-container .cmplz-category', function(){
for(const key in cmplz_categories){
if(cmplz_categories.hasOwnProperty(key) ){
const category=cmplz_categories[ key ];
const categoryElement=document.querySelector('.cmplz-manage-consent-container input.cmplz-' + category);
if(categoryElement){
if(categoryElement.checked){
cmplz_set_consent(category, 'allow');
}else{
cmplz_set_consent(category, 'deny');
}
cmplz_set_banner_status('dismissed');
cmplz_fire_categories_event();
cmplz_track_status();
}}
}});
cmplz_add_event('click', '.cmplz-deny', function(e){
e.preventDefault();
cmplz_set_banner_status('dismissed');
cmplz_deny_all();
});
cmplz_add_event('click', 'button.cmplz-manage-settings', function(e){
e.preventDefault();
const catsContainer=document.querySelector('.cmplz-cookiebanner .cmplz-categories');
const saveSettings=document.querySelector('.cmplz-save-settings');
const manageSettings=document.querySelector('button.cmplz-manage-settings');
if(! cmplz_is_hidden(catsContainer) ){
saveSettings.style.display='none';
manageSettings.style.display='block';
catsContainer.style.display='none';
}else{
saveSettings.style.display='block';
manageSettings.style.display='none';
catsContainer.style.display='block';
}});
cmplz_add_event('click', 'button.cmplz-manage-consent', function(e){
e.preventDefault();
cmplz_set_banner_status('show');
});
function cmplz_set_up_auto_dismiss(){
if(cmplz_get_banner_status()==='dismissed'){
return;
}
if(complianz.dismiss_on_scroll==1){
const onWindowScroll=function(){
if(window.pageYOffset > Math.floor(400) ){
window.removeEventListener('scroll', onWindowScroll);
this.onWindowScroll=null;
if(cmplz_get_banner_status()==='dismissed'){
return;
}
cmplz_set_banner_status('dismissed');
if(complianz.consenttype==='optout'){
cmplz_fire_categories_event();
cmplz_track_status();
}else{
cmplz_deny_all();
}}
};
window.addEventListener('scroll', onWindowScroll);
}
const delay=parseInt(complianz.dismiss_timeout);
if(delay > 0){
window.setTimeout(function(){
if(cmplz_get_banner_status()==='dismissed'){
return;
}
cmplz_set_banner_status('dismissed');
if(complianz.consenttype==='optout'){
cmplz_fire_categories_event();
cmplz_track_status();
}else{
cmplz_deny_all();
}}, Math.floor(delay) );
}}
function cmplz_fire_categories_event(){
const details=new Object();
details.category=cmplz_highest_accepted_category();
details.categories=cmplz_accepted_categories();
details.region=complianz.region;
const event=new CustomEvent('cmplz_fire_categories', { detail: details });
document.dispatchEvent(event);
}
function cmplz_track_status(status){
let cats=[];
status=typeof status!=='undefined' ? status:false;
const event=new CustomEvent('cmplz_track_status', { detail: status });
document.dispatchEvent(event);
if(! status){
cats=cmplz_accepted_categories();
}else{
cats=[ status ];
}
cmplz_set_category_as_body_class();
let saved_cats, saved_services;
try {
saved_cats=JSON.parse(cmplz_get_cookie('saved_categories') );
} catch(e){
saved_cats={};}
try {
saved_services=JSON.parse(cmplz_get_cookie('saved_services') );
} catch(e){
saved_services={};}
const consented_services=cmplz_get_all_service_consents();
if(cmplz_equals(saved_cats, cats)&&cmplz_equals(saved_services, consented_services) ){
return;
}
if(complianz.store_consent!=1||cmplz_is_bot()||cmplz_is_speedbot()){
return;
}
cmplz_set_cookie('saved_categories', JSON.stringify(cats) );
cmplz_set_cookie('saved_services', JSON.stringify(consented_services) );
cmplz_consent_stored_once=true;
const data={
consented_categories: cats,
consented_services,
consenttype: window.wp_consent_type,
};
const request=new XMLHttpRequest();
request.open('POST', complianz.url + 'track', true);
request.setRequestHeader('Content-type', 'application/json');
request.send(JSON.stringify(data) );
}
function cmplz_accepted_categories(){
let consentedCategories=cmplz_categories;
const consentedTemp=[];
for(const key in consentedCategories){
if(consentedCategories.hasOwnProperty(key) ){
const category=consentedCategories[ key ];
if(cmplz_has_consent(category) ){
consentedTemp.push(category);
}}
}
consentedCategories=consentedCategories.filter(function(value){
return cmplz_in_array(value, consentedTemp);
});
return consentedCategories;
}
function cmplz_sync_category_checkboxes(){
for(const key in cmplz_categories){
if(cmplz_categories.hasOwnProperty(key) ){
const category=cmplz_categories[ key ];
if(cmplz_has_consent(category)||category==='functional'){
document.querySelectorAll('input.cmplz-' + category).forEach(( obj)=> {
obj.checked=true;
});
}else{
document.querySelectorAll('input.cmplz-' + category).forEach(( obj)=> {
obj.checked=false;
});
}}
document.querySelectorAll('.cmplz-accept-service').forEach(( obj)=> {
const service=obj.getAttribute('data-service');
const category=obj.getAttribute('data-category');
if(cmplz_has_service_consent(service, category) ){
obj.checked=true;
}else if(cmplz_is_service_denied(service) ){
obj.checked=false;
}else{
obj.checked = !! cmplz_has_consent(category);
}});
}}
function cmplz_merge_object(userdata, ajax_data){
const output={};
for(const key in ajax_data){
if(ajax_data.hasOwnProperty(key) ){
output[ key ]=ajax_data[ key ];
}}
for(const key in userdata){
if(! ajax_data.hasOwnProperty(key)||typeof ajax_data[ key ]==='undefined'){
if(userdata.hasOwnProperty(key) ){
output[ key ]=userdata[ key ];
}}
}
return output;
}
function cmplz_clear_cookies(cookie_part){
if(typeof document==='undefined'){
return false;
}
let foundCookie=false;
const secure=window.location.protocol==='https:' ? ';secure':'';
const expires='expires=' + new Date().toGMTString();
const pathParts=location.pathname.replace(/^\/|\/$/g, '').split('/');
document.cookie.split('; ').forEach(function(cookie){
const cookieName=cookie.split(';')[ 0 ].split('=')[ 0 ];
if(cookieName.indexOf(cookie_part)!==-1){
foundCookie=true;
const domainParts=window.location.hostname.split('.');
const skipLast=domainParts.length > 1;
pathParts.forEach(function(pathPart){
const path='/' + pathPart;
document.cookie=encodeURIComponent(cookieName) + '=;SameSite=Lax' + secure + ';' + expires + ';domain=.' + domainParts.join('.') + ';path=' + path;
document.cookie=encodeURIComponent(cookieName) + '=;SameSite=Lax' + secure + ';' + expires + ';domain=.' + domainParts.join('.') + ';path=' + path + '/';
});
while(domainParts.length > 0){
const domain='.' + domainParts.join('.');
domainParts.shift();
if(skipLast&&domainParts.length===1){
domainParts.shift();
}
pathParts.forEach(function(pathPart){
const path='/' + pathPart;
document.cookie=encodeURIComponent(cookieName) + '=;SameSite=Lax' + secure + ';' + expires + ';domain=' + domain + ';path=' + path;
document.cookie=encodeURIComponent(cookieName) + '=;SameSite=Lax' + secure + ';' + expires + ';domain=' + domain + ';path=' + path + '/';
});
}}
});
cmplz_set_accepted_cookie_policy_id();
return foundCookie;
}
function cmplz_set_accepted_cookie_policy_id(){
cmplz_set_cookie('policy_id', complianz.current_policy_id);
}
function cmplz_integrations_init(){
const cookiesToSet=complianz.set_cookies;
for(const key in cookiesToSet){
if(cookiesToSet.hasOwnProperty(key)&&cookiesToSet[ key ][ 1 ]==='1'){
cmplz_set_cookie(key, cookiesToSet[ key ][ 1 ], false);
}}
}
function cmplz_integrations_revoke(){
const cookiesToSet=complianz.set_cookies;
for(const key in cookiesToSet){
if(cookiesToSet.hasOwnProperty(key) ){
cmplz_set_cookie(key, cookiesToSet[ key ][ 1 ], false);
if(cookiesToSet[ key ][ 1 ]==false){
cmplz_clear_cookies(key);
}}
}}
function cmplz_set_integrations_cookies(){
const cookiesToSet=complianz.set_cookies;
for(const key in cookiesToSet){
if(cookiesToSet.hasOwnProperty(key) ){
cmplz_set_cookie(key, cookiesToSet[ key ][ 0 ], false);
}}
}
function cmplz_get_url_parameter(sPageURL, sParam){
if(! sPageURL||typeof sPageURL==='undefined'||sPageURL.indexOf('?')===-1){
return false;
}
const queryString=sPageURL.split('?')[ 1 ];
if(! queryString){
return false;
}
const sURLVariables=queryString.split('&');
for(let i=0; i < sURLVariables.length; i++){
const sParameterName=sURLVariables[ i ].split('=');
if(sParameterName[ 0 ]===sParam){
return sParameterName[ 1 ]===undefined ? true:decodeURIComponent(sParameterName[ 1 ]);
}}
return false;
}
function cmplz_maybe_auto_redirect(){
const redirect=cmplz_get_url_parameter(window.location.href, 'cmplz_region_redirect');
const region=cmplz_get_url_parameter(window.location.href, 'cmplz-region');
if(redirect&&! region){
const newUrl=window.location.href.split('#')[ 0 ] + '&cmplz-region=' + complianz.region;
const hash=window.location.hash;
window.location.href=newUrl + hash;
}}
function cmplz_wp_set_consent(type, value){
if(typeof wp_set_consent==='function'){
wp_set_consent(type, value);
}}
function cmplz_start_clean(){
if(complianz.clean_cookies==1){
if(typeof(Storage)!=='undefined'){
cmplz_cookie_data=JSON.parse(sessionStorage.getItem('cmplz_cookie_data') );
}
if(! cmplz_cookie_data||cmplz_cookie_data.length===0){
const request=new XMLHttpRequest();
request.open('GET', complianz.url + 'cookie_data', true);
request.setRequestHeader('Content-type', 'application/json');
request.send();
request.onload=function(){
cmplz_cookie_data=JSON.parse(request.response);
sessionStorage.setItem('cmplz_cookie_data', JSON.stringify(cmplz_cookie_data) );
cmplz_setup_clean_interval();
};}else{
cmplz_setup_clean_interval();
}}
}
function cmplz_do_cleanup(){
const consent_categories=[ 'preferences', 'statistics', 'marketing' ];
for(const category of consent_categories){
if(! cmplz_has_consent(category)&&cmplz_cookie_data.hasOwnProperty(category) ){
const services=cmplz_cookie_data[ category ];
for(const service in services){
if(! cmplz_has_service_consent(service, category) ){
const cookies=services[ service ];
for(const item of cookies){
cmplz_clear_cookies(item);
cmplz_clear_storage(item);
}}
}}
}}
function cmplz_setup_clean_interval(){
if(! cmplz_cookie_data){
return;
}
if(cmplzCleanCookieInterval){
return;
}
cmplz_do_cleanup();
cmplzCleanCookieInterval=setInterval(cmplz_do_cleanup, 1000);
}
function cmplz_clear_storage(item){
if(typeof(Storage)!=='undefined'){
if(localStorage.getItem(item) ){
localStorage.removeItem(item);
}
if(sessionStorage.getItem(item) ){
sessionStorage.removeItem(item);
}}
}
function cmplz_load_manage_consent_container(){
const manage_consent_container=document.querySelector('.cmplz-manage-consent-container');
const is_block_editor=false;//document.querySelector('.wp-admin .cmplz-unlinked-mode');
if(manage_consent_container&&! is_block_editor){
const request=new XMLHttpRequest();
request.open('GET', complianz.url + 'manage_consent_html?' + complianz.locale, true);
request.setRequestHeader('Content-type', 'application/json');
request.send();
request.onload=function(){
const html=JSON.parse(request.response);
manage_consent_container.insertAdjacentHTML('beforeend', html);
cmplz_sync_category_checkboxes();
const nojavascript=document.querySelector('#cmplz-manage-consent-container-nojavascript');
nojavascript.style.display='none';
manage_consent_container.style.display='block';
const event=new CustomEvent('cmplz_manage_consent_container_loaded');
document.dispatchEvent(event);
};}}
cmplz_add_event('keypress', '.cmplz-banner-slider label', function(e){
const keycode=(e.keyCode ? e.keyCode:e.which);
if(keycode==32){
document.activeElement.click();
}});
cmplz_add_event('keypress', '.cmplz-cookiebanner .cmplz-header .cmplz-close', function(e){
const keycode=(e.keyCode ? e.keyCode:e.which);
if(keycode==13){
document.activeElement.click();
}});
function cmplz_equals(array_1, array_2){
if(typeof array_1==='object'&&array_1!==null&&! Array.isArray(array_1) &&
typeof array_2==='object'&&array_2!==null&&! Array.isArray(array_2) ){
const allKeys=[ ...new Set([ ...Object.keys(array_1), ...Object.keys(array_2) ]) ];
for(const key of allKeys){
if(array_1[ key ]!==array_2[ key ]){
return false;
}}
return true;
}
if(! Array.isArray(array_1) ){
array_1=Object.keys(array_1);
array_2=Object.keys(array_2);
}
if(! array_1||! array_2){
return false;
}
if(array_1.length!==array_2.length){
return false;
}
for(let i=0, l=array_1.length; i < l; i++){
if(array_1[ i ] instanceof Array&&array_2[ i ] instanceof Array){
if(! cmplz_equals(array_1[ i ], array_2[ i ]) ){
return false;
}}else if(array_1[ i ]!==array_2[ i ]){
return false;
}}
return true;
}
function cmplzCopyAttributes(source, target){
const excludes=[ 'type', 'data-service', 'data-category', 'async' ];
Array.from(source.attributes).forEach(( attribute)=> {
if(attribute.nodeName==='data-script-type'&&attribute.nodeValue==='module'){
target.setAttribute('type', 'module');
target.removeAttribute('data-script-type');
}else if(! excludes.includes(attribute.nodeName) ){
target.setAttribute(attribute.nodeName, attribute.nodeValue);
}});
}
const cmplz_has_wp_video=document.querySelector('.cmplz-wp-video-shortcode');
let cmplz_times_checked=0;
if('undefined'!==typeof window.jQuery){
jQuery(document).ready(function($){
if(cmplz_has_wp_video){
document.addEventListener('cmplz_enable_category', function(){
cmplz_activate_wp_video();
});
const cmplzInterval=setInterval(function(){
cmplz_times_checked +=1;
if(document.querySelector('.cmplz-wp-video-shortcode')&&cmplz_times_checked < 100){
cmplz_activate_wp_video();
}else{
clearInterval(cmplzInterval);
}}, 500);
}
function cmplz_activate_wp_video(){
if(! document.querySelector('.cmplz-wp-video-shortcode') ){
return;
}
const categories=cmplz_accepted_categories();
const services=cmplz_get_all_service_consents();
let selectorVideo='';
const selectorVideos=[];
for(const c_key in categories){
if(categories.hasOwnProperty(c_key) ){
const category=categories[ c_key ];
if(category==='functional'){
break;
}
selectorVideos.push('.cmplz-wp-video-shortcode[data-category="' + category + '"]');
}}
for(const s_key in services){
if(services.hasOwnProperty(s_key) ){
selectorVideos.push('.cmplz-wp-video-shortcode[data-service="' + s_key + '"]');
}}
selectorVideo=selectorVideos.join(',');
let should_initialize_video=false;
if(selectorVideo.length > 0){
document.querySelectorAll(selectorVideo).forEach(( obj)=> {
should_initialize_video=true;
obj.setAttribute('controls', 'controls');
obj.classList.add('wp-video-shortcode', 'cmplz-processed');
obj.classList.remove('cmplz-wp-video-shortcode');
obj.closest('.cmplz-wp-video').classList.remove('cmplz-wp-video');
const blocked_notice=obj.closest('.wp-video').querySelector('.cmplz-blocked-content-notice');
if(blocked_notice){
blocked_notice.parentElement.removeChild(blocked_notice);
}
obj.classList.remove('cmplz-blocked-content-container');
});
}
if(should_initialize_video){
if(window.wp.mediaelement){
window.wp.mediaelement.initialize();
}else{
const settings={};
settings.videoWidth='100%';
settings.videoHeight='100%';
settings.enableAutosize=true;
$('.wp-video-shortcode').mediaelementplayer(settings);
}}
}
document.querySelectorAll('.cmplz-video.cmplz-activated').forEach(( obj)=> {
cmplz_activate_fitvids(obj);
});
document.addEventListener('cmplz_enable_category', function(){
document.querySelectorAll('.cmplz-video.cmplz-activated').forEach(( obj)=> {
cmplz_activate_fitvids(obj);
});
});
function cmplz_activate_fitvids(obj){
const $obj=$(obj);
if(typeof $obj.parent().fitVids==='function'){
$obj.parent().fitVids();
}}
});
};