"use strict";
// Copyright Avvio 2018. All rights reserved.
// crafted by SW, design by KK
if ( typeof AvvioCC == 'undefined' )
{
// variables after script means script is loaded first and
// variables are defined afterwards
var AvvioCC = { variablesAfterScript:true }
} else
{
// variables are defined further up in the DOM
// script is loaded after variables are set
// AvvioCC global var is already created.
AvvioCC.variablesAfterScript=false;
}
//---------------------------------------------------------------------------80
// configuration values
if ( ! AvvioCC.hasOwnProperty('defaultConsent') ) AvvioCC.defaultConsent="1000";
if ( ! AvvioCC.hasOwnProperty('silentMode') ) AvvioCC.silentMode=false;
if ( ! AvvioCC.hasOwnProperty('debug') ) AvvioCC.debug=false;
if ( ! AvvioCC.hasOwnProperty('allowPeek') ) AvvioCC.allowPeek=true;
if ( ! AvvioCC.hasOwnProperty('stopPeekAfter') ) AvvioCC.stopPeekAfter=10;
if ( ! AvvioCC.hasOwnProperty('smartBodyContainerId') ) AvvioCC.smartBodyContainerId='ACCsmartBodyContainer';
if ( ! AvvioCC.hasOwnProperty('zIndex') ) AvvioCC.zIndex=30000; // modern template uses values in the range up to 2xxx
if ( ! AvvioCC.hasOwnProperty('popupPosition') ) AvvioCC.popupPosition="center";
if ( ! AvvioCC.hasOwnProperty('colorScheme') ) AvvioCC.colorScheme="bw";
if ( ! AvvioCC.hasOwnProperty('popupAligment') ) AvvioCC.popupAligment="center";
//if ( ! AvvioCC.hasOwnProperty('fontColor') ) AvvioCC.fontColor="002d3e";
//if ( ! AvvioCC.hasOwnProperty('darkBackgroundColor') ) AvvioCC.darkBackgroundColor="002d3e";
//if ( ! AvvioCC.hasOwnProperty('opacity') ) AvvioCC.opacity="0.8";
if ( ! AvvioCC.hasOwnProperty('cookieNameConsentLevel') ) AvvioCC.cookieNameConsentLevel='cL_16539';
if ( ! AvvioCC.hasOwnProperty('cookieNameImpressions') ) AvvioCC.cookieNameImpressions='iM_16539';
if ( ! AvvioCC.hasOwnProperty('cookieExpiryDays') ) AvvioCC.cookieExpiryDays=365;
if ( ! AvvioCC.hasOwnProperty('primaryRelayURL') ) AvvioCC.primaryRelayURL='https://secure.lakedistrictcastleinn.com/crm/rpc/Lake%20District%20Castle%20Inn/relayACC.php';
if ( ! AvvioCC.hasOwnProperty('additionalRelayURLs') )
{
AvvioCC.additionalRelayURLs=[];
}
if ( ! AvvioCC.hasOwnProperty('primaryCRMImageURL') ) AvvioCC.primaryCRMImageURL='https://secure.lakedistrictcastleinn.com/crm/rpc/Lake%20District%20Castle%20Inn/image.php?el=NFf0efM2IJbMrG22M4J6IAzcgT1-L2mZABFWFLuF0rw';
if ( ! AvvioCC.hasOwnProperty('additionalCRMImageURLs') ) AvvioCC.additionalCRMImageURLs=[];
if ( ! AvvioCC.hasOwnProperty('alloraImageURL') ) AvvioCC.alloraImageURL='https://secure.lakedistrictcastleinn.com/ai/rpc/Lake%20District%20Castle%20Inn/image.php?el=NFf0efM2IJbMrG22M4J6IAzcgT1-L2mZABFWFLuF0rw';
if ( ! AvvioCC.hasOwnProperty('useGoogleTagManager') ) AvvioCC.useGoogleTagManager=true;
// ConsumerSide uses it's own tracking, CMS uses also historical crm/track.php
// MG: disable automagic 1px generation by ACC for now
if ( ! AvvioCC.hasOwnProperty('userDeploysAvvio') ) AvvioCC.userDeploysAvvio=true;
//---------------------------------------------------------------------------80
// interface methods
if ( ! AvvioCC.hasOwnProperty('userDeployRequiredCookies') ) AvvioCC.userDeployRequiredCookies=function(){ if ( this.debug ) console.log("userDeployRequiredCookies not set"); };
if ( ! AvvioCC.hasOwnProperty('userDeployFunctionalCookies') ) AvvioCC.userDeployFunctionalCookies=function(){ if ( this.debug ) console.log("userDeployFunctionalCookies not set"); };
if ( ! AvvioCC.hasOwnProperty('userDeployStatisticalCookies') ) AvvioCC.userDeployStatisticalCookies=function(){ if ( this.debug ) console.log("userDeployStatisticalCookies not set"); };
if ( ! AvvioCC.hasOwnProperty('userDeployMarketingCookies') ) AvvioCC.userDeployMarketingCookies=function(){ if ( this.debug ) console.log("userDeployMarketingCookies not set"); };
// no removal of cookies right now
//if ( ! AvvioCC.hasOwnProperty('userRemoveRequiredCookies') ) AvvioCC.userRemoveRequiredCookies=function(){ if ( this.debug ) console.log("userRemoveRequiredCookies not set"); };
//if ( ! AvvioCC.hasOwnProperty('userRemoveFunctionalCookies') ) AvvioCC.userRemoveFunctionalCookies=function(){ if ( this.debug ) console.log("userRemoveFunctionalCookies not set"); };
//if ( ! AvvioCC.hasOwnProperty('userRemoveStatisticalCookies') ) AvvioCC.userRemoveStatisticalCookies=function(){ if ( this.debug ) console.log("userRemoveStatisticalCookies not set"); };
//if ( ! AvvioCC.hasOwnProperty('userRemoveMarketingCookies') ) AvvioCC.userRemoveMarketingCookies=function(){ if ( this.debug ) console.log("userRemoveMarketingCookies not set"); };
if ( ! AvvioCC.hasOwnProperty('userUpdateConsent') ) AvvioCC.userUpdateConsent=function(){ if ( this.debug ) console.log("userUpdateConsent not set"); };
if ( ! AvvioCC.hasOwnProperty('fragments') ) AvvioCC.fragments=[];
//---------------------------------------------------------------------------80
// css and html injected into host page
if ( ! AvvioCC.hasOwnProperty('useCSS') ) AvvioCC.useCSS="#ACClayerBackground { display: none; height: 100vh; top: 0; position: fixed; width: 100%; z-index: @ZINDEXV@; background: rgba(@BGDARKV@, @BGDARKV@, @BGDARKV@, @OPACITY@); }.ACClayer { @POPUPALIGMENTV@; background-color: transparent; }.ACClayer .kkPositionHelper { height: auto; @POPUPPOSITIONKV@ position: fixed; width: 100%; }.ACClayer * { /* reset */ padding:0; margin:0; text-decoration:none; border:none; color: #@FONTCOLORV@; width: auto; font-family: @FONTFAMILYV@; }.ACClayer a:hover { color: #@FONTCOLORV@; font-size: inherit; font-weight: inherit; }.ACCcontainer { font-family: @FONTFAMILYV@; min-width: 400px; margin-left: auto; margin-right: auto; display: inline-block; font-size: 14px; font-weight: normal; vertical-align: middle; line-height: 1.4; text-align: left; background-color: #@BGCOLORV@; border: 3px solid #@BGCOLORV@; padding-left: 40px; padding-right: 20px; @POPUPALIGMENTCONTAINERV@; @POPUPMAXWIDTHV@}#ACCsmallCookieLayer .ACCcontainer{ max-width: 500px; }#ACCsiteLogo { background-position: center; background-image: url('@SITELOGOV@'); background-repeat: no-repeat; width: 200px; height: 100px; content: ' '; display: block; margin: 30px auto 0 auto; }.ACCcontainer.kkACCbasic { padding-right: 40px; }.ACCcontainer a:hover { text-decoration: none; }.ACCcontainer h4 { text-align: left; padding: 30px 0; font-family: @FONTFAMILYV@; }.kkACCheader { overflow: hidden; margin-top: 20px; font-weight: 700; box-sizing: content-box; margin-left: -40px; margin-right: -40px; height: 60px; color: #@FONTCOLORV@; line-height: 60px; padding: 0 40px; background-color: #@BGCOLORV@; font-size: 20px; text-align: left; }.kkACCdetails .kkACCheader { margin-right: -20px; }.textAllCookies { margin-top: 20px; }.ACClayer .kkACCreadFullPolicy { text-decoration: underline; font-weight: 400; font-size: 16px !important; color: #@FONTCOLORV@; float: right; cursor: hand; cursor: pointer; }.ACClayer .kkACCreadFullPolicy:hover { font-weight: 400; color: #@FONTCOLORV@ !important; text-decoration: none; }.ACClayer .fullCookiePolicyText { margin-top: 30px; }.ACClayer .fullCookiePolicyText a{ text-decoration: underline; }.ACClayer .fullCookiePolicyText a:hover { text-decoration: none; }.kkACCheaderP { text-align: left; padding: 20px 0 0px 0; line-height: 1.4; }.kkACCheaderP p{ margin-bottom: 20px; }.kkACCButtonsTop { display: inline-block; width: 100%; margin-top: 10px; margin-bottom: 20px; }.kkACCButtons { font-size: 16px; display: inline-block; width: 100%; margin-top: 40px; margin-bottom: 33px; }.kkACCButtons a{ text-decoration: none; }.kkACCdetails .kkACCButtons { margin-top: 20px; }.kkACCButtonsLeft { float: left; text-align: left; }.kkACCButtonsRight { float: right; text-align: right; }.kkACCdetails .kkACCButtonsBottom .kkACCButtonsRight a { display: flex; z-index: 10; }.kkACCdetails .kkACCButtonsBottom .kkACCButtonsRight { display: flex; }.kkACCdetails .kkACCButtonsBottom a { margin: 0; }.ACClayer .kkACCButton { display: inline-block; -webkit-transition: all .15s ease-in-out; -moz-transition: all .15s ease-in-out; -ms-transition: all .15s ease-in-out; -o-transition: all .15s ease-in-out; transition: all .15s ease-in-out; cursor: pointer; cursor: hand; border: 2px solid #@DARKBACKGROUNDCOLORV@; padding: 8px 28px; background-color: #@DARKBACKGROUNDCOLORV@; color: #@BGCOLORV@; margin: 0 10px; }.ACClayer .kkACCButton:hover { background-color: #@DARKBACKGROUNDCOLORV@; color: #@BGCOLORV@; -webkit-box-shadow: 0 0 0px 1px #@DARKBACKGROUNDCOLORV@, 4px 4px 6px 1px #rgba(0, 0, 0, 0.5); box-shadow: 0 0 0px 1px #@DARKBACKGROUNDCOLORV@, 4px 4px 6px 1px rgba(0, 0, 0, 0.5); }.ACClayer .kkACCButtonLearnMore { opacity: 0.7; padding: 9px 28px; background-color: #@BGCOLORV@; display: inline-block; color: #@FONTCOLORV@; margin: 5px 10px 0 -18px; }.ACClayer .kkACCButtonLearnMore:hover { background-color: #@BGCOLORV@; color: #@FONTCOLORV@; }.kkACCButtons .kkACCButtonsBottom { margin: 0; }.kkACCrow { float: left; width: 100%; padding: 10px 0; border-bottom: 1px solid #@DARKBACKGROUNDCOLORV@; }.kkACCrow:last-child { border-bottom: none; }.kkACCrow > span { line-height: 40px; vertical-align: middle; }.kkACCrow .kkACCrowTitle { font-size: 125%; display: inline-block; cursor: hand; cursor: pointer; }.kkACCrow .kkACCrowDesc { width: 91%; line-height: 1.4; text-align: left; display: none; margin-bottom: 10px; }.kkACCrow.active .kkACCrowDesc { display: inline-block; }.kkACCrow .kkACCrowShowMore { white-space: nowrap; float: right; font-size: 80%; visibility: visible; display: inline-block; text-align: right; cursor: hand; cursor: pointer; }.kkACCrow.active .kkACCrowShowMore { visibility: hidden; }.kkACCrow .kkACCrowSwitch { float: right; margin-left: 10px; display: inline-block; text-align: right; font-size: 200%; }.kkACCrow label { padding: 7px; margin-right: -7px; max-width: none; display: flex; }.kkACCBlock { position: relative; max-height: 70vh; overflow: auto; padding-right: 20px;}.kkACChideBig { display: none; }#kkACCrowRequired .kkACCslider { cursor: not-allowed !important; opacity: .5; }#kkACCrowRequired .kkACCrowSwitch { margin-left: 17px; }.kkACCSwitch { position: relative; display: block; width: 35px; height: 20px; margin-top: 1px; }.kkACCSwitchDisabled { position: relative; display: block; width: 35px; height: 20px; margin: 0px; margin-top: 9px; }.kkACCrowSwitch .kkACCslider { position: absolute; cursor: pointer; cursor: hand; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; -webkit-transition: .2s; transition: .2s; border-radius: 10px; }.kkACCrowSwitch .kkACCslider:before { position: absolute; content: \"\"; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: #FFF; -webkit-transition: .2s; transition: .2s; border-radius: 50%; }.kkACCrowSwitch input:checked + .kkACCslider { background-color: #008800; }.kkACCrowSwitch input:focus + .kkACCslider { box-shadow: 0 0 1px #008800; }.kkACCrowSwitch input:checked + .kkACCslider:before { -webkit-transform: translateX(14px); -ms-transform: translateX(14px); transform: translateX(14px); }.kkACCTransparentGradient { right: 15px; display: block; position: absolute; bottom: -1px; width: 100%; height: 40px; background-image: linear-gradient(to bottom, rgba(@BGLIGHTV@, @BGLIGHTV@, @BGLIGHTV@, 0), rgba(@BGLIGHTV@, @BGLIGHTV@, @BGLIGHTV@, 1)); }.kkACCBlockWrapper { position: relative; }.sr-only{ border: 0; clip: rect(0,0,0,0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px;}@media screen and (max-width: 1300px) { .ACCcontainer{ margin-left: 15px; margin-right: 15px; @POPUPMAXWIDTHV@; }}@media screen and (max-width: 768px) { .kkACCdetails { position: relative; } .ACCcontainer{ min-width: auto !important; padding-left: 20px; padding-right: 10px; max-height: 95vh; } .ACCcontainer.kkACCbasic { padding-left: 20px; padding-right: 20px; } .kkACCBlock { padding-right: 10px; max-height: 70vh; padding-bottom: 0px; } .kkACCheader { margin-top: 0px; margin-left: -20px; padding-left: 20px; margin-right: -20px; padding-right: 20px; line-height: 60px; height: 60px; font-size: 120%; } .kkACCdetails .kkACCheader { margin-right: -10px; } .kkACCheaderP { font-size: 85%; padding-top: 18px; } .kkACCrow { padding: 2px 0; } .kkACCrow .kkACCrowTitle { font-size: 80%; } .kkACCrow .kkACCrowShowMore { font-size: 70%; padding-right: 10px; padding-left: 10px; } .kkACCrow .kkACCrowSwitch { font-size: 125%; padding: 0; } .kkACCrow .kkACCrowDesc { font-size: 80%; } .kkACCrow > span { padding: 8px 0; line-height: 18px; } .kkACCButtons { margin: 20px 0 9px 0; } .kkACCdetails .kkACCButtons { } .kkACCbasic .kkACCButtons { margin-bottom: 14px; } .kkACCdetails .kkACCButtonsBottom .kkACCButtonsRight { margin-right: 0px; margin-bottom: 11px; } .kkACCButton { padding: 5px 15px; font-size: 14px !important; } .kkACChideSmall { display: none; } .kkACChideBig { display: inline-block; } .kkACCBlockWrapper { } .kkACCButtonsTop { margin-bottom: 15px; } .kkACCTransparentGradient { right: 5px; }}@media screen and (max-width: 425px) { .kkACCheader { line-height: 50px; height: 50px; font-size: 100%; } .kkACCheader .kkACCreadFullPolicy { font-size: 12px; margin-top: 0px; } .kkACCrow .kkACCrowSwitch { margin-left: 0px; } #kkACCrowRequired .kkACCrowSwitch { margin-left: 7px; } .kkACCButton { font-size: 13px !important; } .kkACCrow .kkACCrowTitle { font-size: 75%; letter-spacing: -0.2px; } .kkACCrow .kkACCrowShowMore { padding-right: 5px; padding-left: 5px; }}@media screen and (max-width: 359px) { .ACClayer .kkACCreadFullPolicy { font-size: 13px !important; } .kkACCheader .kkACCreadFullPolicy { font-size: 10px; } .kkACCheaderP { padding-top: 0px; font-size: 80%; } .kkACCheaderP p { margin-bottom: 10px; } .ACClayer .kkACCButtonLearnMore { padding-left: 20px; padding-right: 20px; }}";
if ( ! AvvioCC.hasOwnProperty('useHTML') ) AvvioCC.useHTML="
This website uses cookies to analyse and enhance your website experience, and in some cases for promotional purposes and ads personalisation.
";
//---------------------------------------------------------------------------80
// css and html injected into host page
AvvioCC.avvioTrackingDeployed=false;
AvvioCC.userDeployActiveCategorie = false;
AvvioCC.requiredCookiesDeployed=false;
AvvioCC.functionalCookiesDeployed=false;
AvvioCC.statisticalCookiesDeployed=false;
AvvioCC.marketingCookiesDeployed=false;
// ==========================================================================80
// cookie helper
AvvioCC.getCookieDomain=function()
{
var parts = window.location.hostname.split('.').reverse();
// www.myhotel.com
// => myhotel.com
// www.myhotel.co.uk
// myhotel.co.uk
// minimum 2
var returnValue = parts[1]+'.'+parts[0];
if ( parts.length >= 4 )
{
returnValue = parts[2]+'.'+returnValue;
}
return returnValue;
};
AvvioCC.setCookie=function(cname, cvalue, days)
{
var d = new Date();
d.setTime(d.getTime() + (days*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
var cookieString = cname + "=" + cvalue + ";" + expires + ";domain=."+this.getCookieDomain()+";path=/;SameSite=None;Secure";
//SW20211203: keep this in please!
if ( this.debug ) console.log("ACC:cookie="+cookieString );
document.cookie = cookieString;
};
AvvioCC.getCookie=function(cname)
{
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i=0; i= 1 ) ||
( ( fakeElement != null ) && ( fakeElement.childElementCount >= 1 ) ) )
{
// if we ran out of fake elements, convert the next fragment in a fake element
if ( ( fakeElement == null ) || ( fakeElement.childElementCount <= 0 ) )
{
if ( remainingFragments.length <= 0 )
return;
var firstFragment=remainingFragments.shift();
var fakeElement = document.createElement('div');
try
{
fakeElement.innerHTML = window.atob(firstFragment.d).trim();
} catch(e)
{
// TESTED 20180512 1422 - invalid strings are caught
console.log("invalid base64 string in fragment");
// use plaintext in insert
fakeElement.innerHTML = firstFragment.d;
}
previousSibling = firstFragment.s;
if ( previousSibling == null )
{
// IE11 currentScript workaround only relevant for fragments.push()
var scripts = document.getElementsByTagName('script');
for( var i=0; i= 0 )
{
previousSibling=scripts[i];
break;
}
}
if ( previousSibling == null )
{
console.log("STILL NOT FOUND: "+firstFragment.d );
previousSibling=document.body.lastChild;
}
}
}
while (fakeElement.firstChild)
{
var child=fakeElement.firstChild;
if ( child.tagName == 'SCRIPT' )
{
var scriptElement = document.createElement('script');
var typeAttribute = child.getAttribute('type')
if ( typeAttribute )
scriptElement.type = child.type;
if ( child.src.length > 0 )
{
var hasAsync = child.hasAttribute('async');
if ( this.debug) console.log("JS: FOUND src="+ child.src + " async="+hasAsync );
// external scrip is loaded in a slightly different way
scriptElement.src = child.src;
if ( hasAsync )
{
// WARNING: async scripts have no document write support by design
// makes no difference for scripts added past DOM ready
// scriptElement.setAttribute('async', 'async');
scriptElement.onload = function() {
// TESTED 20180512 1449 ... finished is reqored for the correct file!
if ( AvvioCC.debug ) console.log("JS: ASYNC finished= " + this.src );
}
// no document write redirect for async script!!!
previousSibling.parentNode.insertBefore(scriptElement, previousSibling.nextSibling);
previousSibling = scriptElement;
fakeElement.removeChild(child);
} else
{
var docWriteBuffer ='';
var docWriteBackup = document.write;
document.write = function( newHTMLString )
{
docWriteBuffer+=newHTMLString;
};
// WARNING: this (^document.write override) is not race condition save because some other script way run in between and do the same, or use document.write
scriptElement.onload = function() {
if ( AvvioCC.debug )
{
// TESTED 20180512 1451 correct file is reported
console.log("JS: sync finished="+this.src + " resume: " + fakeElement.childElementCount + "/" + remainingFragments.length );
}
var localPreviousSibling=this;
document.write = docWriteBackup;
if ( docWriteBuffer.length > 0 )
{
// TESTED 20180512 1512 additional data is queued at the top of the current fragment
// queue the new stuff into the fakeElement at the top !
fakeElement.innerHTML = docWriteBuffer.trim() + fakeElement.innerHTML;
}
// continue with remaining elements
AvvioCC.insertRemainingFragments( remainingFragments, fakeElement, localPreviousSibling );
};
scriptElement.onerror = function() {
if ( AvvioCC.debug )
{
// TESTED 20180512 1505 missing file is reported
console.log("JS: sync FAILED="+this.src + " resume: " + fakeElement.childElementCount + "/" + remainingFragments.length );
}
var localPreviousSibling=this;
document.write = docWriteBackup;
// continue with remaining elements
AvvioCC.insertRemainingFragments( remainingFragments, fakeElement, localPreviousSibling );
};
previousSibling.parentNode.insertBefore(scriptElement, previousSibling.nextSibling);
previousSibling = scriptElement;
fakeElement.removeChild(child);
//WARNING!!!!
//WARNING!!!! SYNC EXECUTION !!! WAIT FOR EXT FILE TO BE LOADED AND EXECUTED !!!
//WARNING!!!!
return false;
}
} else
{
var debugString = child.text.substring(0,100);
if ( this.debug ) console.log("JS: FOUND inline=" + debugString.replace(/\s/g,"") );
scriptElement.text = child.text;
var docWriteBuffer ='';
var docWriteBackup = document.write;
document.write = function( newHTMLString )
{
docWriteBuffer+=newHTMLString;
};
// this will execute contained code instantly
// TESTED 20180521 1357
previousSibling.parentNode.insertBefore(scriptElement, previousSibling.nextSibling);
// TESTED 20180521 1402 - original function is restored correctly
document.write = docWriteBackup;
previousSibling = scriptElement;
fakeElement.removeChild(child);
if ( docWriteBuffer.length > 0 )
{
// TESTED 20180512 1409 ... document.write content is added to the top of the fakeElements queue
// queue the new stuff into the fakeElement at the top !
fakeElement.innerHTML = docWriteBuffer.trim() + fakeElement.innerHTML;
}
}
} else
{
var nodeToMove = fakeElement.firstChild;
previousSibling.parentNode.insertBefore(nodeToMove, previousSibling.nextSibling);
previousSibling = nodeToMove;
}
}
}
}
AvvioCC.insertFragmentsFunctionFactory=function( remainingFragments, fakeElement, previousSibling )
{
// this is used to preserve scope of raminingFragment in case of multiple insert processes running concurently
return function() {
AvvioCC.insertRemainingFragments( remainingFragments, fakeElement, previousSibling );
}
}
// ==========================================================================80
// public interface to add blob of html to any position in the DOM
AvvioCC.pushOrInsertFragment=function( newFragment )
{
if ( newFragment.b == false )
{
// deploy instantly
var localFragments=[];
localFragments.push(newFragment);
var scopePreserver=AvvioCC.insertFragmentsFunctionFactory( localFragments, null, null );
scopePreserver();
} else
{
// part of user deploy, delayed deployment
this.fragments.push(newFragment);
}
}
AvvioCC.appendHTMLToBody=function( htmlString )
{
var newFragment={
d: window.btoa(htmlString),
b: this.userDeployActiveCategorie,
s: document.body.lastChild
};
this.pushOrInsertFragment( newFragment );
}
AvvioCC.appendB64HTMLToBody=function( base64HTMLstring )
{
var newFragment={
d: base64HTMLstring,
b: this.userDeployActiveCategorie,
s: document.body.lastChild
};
this.pushOrInsertFragment( newFragment );
}
AvvioCC.getBodySmartLastChild=function()
{
var destinationElement = document.body;
var smartContainer=document.getElementById(this.smartBodyContainerId);
if ( smartContainer != null )
{
destinationElement = smartContainer;
// child element count is not incremented with comments!
//console.log( destinationElement.childNodes.length + " / " + destinationElement.childElementCount );
if ( destinationElement.childNodes.length <= 0 )
{
var c = document.createComment("first node");
destinationElement.appendChild(c);
}
}
return destinationElement.lastChild;
}
AvvioCC.appendHTMLToBodySmart=function( htmlString )
{
var newFragment={
d: window.btoa(htmlString),
b: this.userDeployActiveCategorie,
s: this.getBodySmartLastChild()
};
this.pushOrInsertFragment( newFragment );
}
AvvioCC.appendB64HTMLToBodySmart=function( base64HTMLstring )
{
var newFragment={
d: base64HTMLstring,
b: this.userDeployActiveCategorie,
s: this.getBodySmartLastChild()
};
this.pushOrInsertFragment( newFragment );
}
AvvioCC.appendHTMLToHead=function( htmlString )
{
var newFragment={
d: base64HTMLstring,
b: this.userDeployActiveCategorie,
s: document.head.lastChild
};
this.pushOrInsertFragment( newFragment );
}
AvvioCC.appendB64HTMLToHead=function( base64HTMLstring )
{
var newFragment={
d: base64HTMLstring,
b: this.userDeployActiveCategorie,
s: document.head.lastChild
};
this.pushOrInsertFragment( newFragment );
}
// ==========================================================================80
// hide/unhide divs
AvvioCC.fadeInById=function( id, time )
{
var elem = document.getElementById( id );
if ( elem == null )
{
return;
}
elem.style.opacity = 0;
elem.style.display = 'block';
var dtStarted = new Date();
(function goIn() {
var timePassedMS = new Date() - dtStarted;
var reached=false;
var newOpacity = 1.0 * timePassedMS/time;
if ( newOpacity >= 1.0 )
{
reached=true;
newOpacity = 1.0;
}
//console.log("time passed:" + timePassedMS + " opacity:" + newOpacity + " time:"+time);
elem.style.opacity = newOpacity;
//TODO?
// for IE
//elem.style.filter = 'alpha(opacity=' + elem.style.opacity * 100 + ')';
if( ! reached )
{
setTimeout( goIn, 50 );
}
else
{
// keep display block
}
})();
};
AvvioCC.fadeOutById=function( id, time )
{
var elem = document.getElementById( id );
if ( elem == null )
{
return;
}
if ( elem.style.display == 'none' )
{
return;
}
//elem.style.opacity = 0;
//elem.style.display = 'block';
var dtStarted = new Date();
(function goIn() {
var timePassedMS = new Date() - dtStarted;
var reached=false;
var newOpacity = 1.0 - 1.0 * timePassedMS/time;
if ( newOpacity <= 0.0 )
{
reached=true;
newOpacity = 0.0;
}
//console.log("time passed:" + timePassedMS + " opacity:" + newOpacity + " time:"+time);
elem.style.opacity = newOpacity;
//TODO?
// for IE
//elem.style.filter = 'alpha(opacity=' + elem.style.opacity * 100 + ')';
if( ! reached )
{
setTimeout( goIn, 50 );
}
else
{
elem.style.display = 'none';
// keep display block
}
})();
};
// ==========================================================================80
// accessors
// 0123 01234567890123456789012345
// string may be 1111, 1000, 1100,2018-01-12T12:12:12,t
AvvioCC.getWellFormatedConsentLevelFromString=function( consentLevelString )
{
consentLevelString = consentLevelString.toLowerCase();
if ( consentLevelString.length == 26 )
{
var temp = consentLevelString.split(',');
if ( temp.length != 3 )
{
console.log("invalid LONG consent level string: "+consentLevelString );
return false;
}
consentLevelString = temp[0];
}
if ( consentLevelString.length == 4 )
{
if ( (consentLevelString[0] != '0') && (consentLevelString[0] != '1') )
return false;
if ( (consentLevelString[1] != '0') && (consentLevelString[1] != '1') )
return false;
if ( (consentLevelString[2] != '0') && (consentLevelString[2] != '1') )
return false;
if ( (consentLevelString[3] != '0') && (consentLevelString[3] != '1') )
return false;
return consentLevelString;
}
console.log("invalid consent level string: "+consentLevelString );
return false;
}
AvvioCC.consentLevelCountBitsSet=function( consentLevel )
{
var bits=0;
// LSB FIRST
if ( consentLevel[0] == '1' ) bits++;
if ( consentLevel[1] == '1' ) bits++;
if ( consentLevel[2] == '1' ) bits++;
if ( consentLevel[3] == '1' ) bits++;
return bits;
}
AvvioCC.getEffectiveConsentLevel=function()
{
var consentedYet = AvvioCC.getCookie( AvvioCC.cookieNameConsentLevel );
if ( ( consentedYet != false ) && ( consentedYet.length > 0 ) ) consentedYet=AvvioCC.getWellFormatedConsentLevelFromString(consentedYet);
var effectiveConsent = this.defaultConsent;
if ( consentedYet != false ) effectiveConsent = consentedYet;
return effectiveConsent;
};
// ==========================================================================80
// avvio specific tools/cookies
AvvioCC.getCacheBuster=function()
{
return '&b=' + new Date().getTime();
}
AvvioCC.getRelayDomain=function( partialURL )
{
var parser = document.createElement('a');
parser.href = partialURL;
var domain = parser.hostname;
var parts = domain.split('.').reverse();
// minimum 2
var returnValue = parts[1]+'.'+parts[0];
if ( parts.length >= 4 )
{
returnValue = parts[2]+'.'+returnValue;
}
return returnValue;
}
AvvioCC.addRelayToGroupByDomain=function( partialURL, group )
{
var parser = document.createElement('a');
parser.href = partialURL;
var domain = parser.hostname;
// 0 1 2 3
// .... /crm/rpc/site
var parts = parser.pathname.split('/');
var siteName = parts[3];
if ( ! group.hasOwnProperty(domain) ) group[domain]=[siteName];
else group[domain].push(siteName);
}
AvvioCC.getRelaySitesByDomain=function()
{
var group={};
if ( this.primaryRelayURL != '' )
{
this.addRelayToGroupByDomain( this.primaryRelayURL, group );
}
var nofAdditionalRelay = this.additionalRelayURLs.length;
for( var i=0; i= 0 )
{
remainingFragments.push( oneFragment )
}
}
if ( this.debug ) console.log("nof fragments to deploy ("+effectiveConsent+"): "+remainingFragments.length );
this.insertRemainingFragments( remainingFragments, null, null );
};
// ==========================================================================80
// init
AvvioCC.initFinishUp=function( effectiveConsent )
{
if ( this.debug ) console.log("initFinishUp("+effectiveConsent+")");
// deploy avvio tools (if level permits)
AvvioCC.deployAvvioCookies( effectiveConsent );
// deploy 3rd party tools
AvvioCC.deployCookies( effectiveConsent );
// give visual hint on webpages what the consent level looks like
AvvioCC.userUpdateConsent();
}
AvvioCC.startPeekIntoRelaySites=function()
{
var allRelayURLs = [];
if ( AvvioCC.primaryRelayURL.length > 0 ) allRelayURLs.push( AvvioCC.primaryRelayURL );
for( var i=0; i< this.additionalRelayURLs.length; i++ )
{
allRelayURLs.push( this.additionalRelayURLs[i] );
}
this.allPeekRequests = [];
for ( var peekIndex=0; peekIndex bestConsentLevelBitsSet )
{
//console.log("BETTER");
bestConsentLevelBitsSet=score;
bestConsentLevel=result;
bestPeekIndex = k;
} else
{
//console.log("WORSE s:"+score+" bcl:"+bestConsentLevelBitsSet);
}
}
}
} else
{
pending++;
}
}
//console.log("LOOPEND pending:"+pending)
if ( pending <= 0 )
{
//console.log("ALLDONE bestConsentLevel"+bestConsentLevel);
var effectiveConsent=AvvioCC.defaultConsent;
if ( bestConsentLevel == false )
{
if ( AvvioCC.silentMode )
{
} else
{
AvvioCC.fadeInById( 'ACClayerBackground', 500 );
AvvioCC.fadeInById('ACCsmallCookieLayer', 1000);
setTimeout(function(){ document.getElementById('ACCsmallCookieLayer').focus(); }, 1010);
}
} else
{
//AvvioCC.setCookie(AvvioCC.cookieNameConsentLevel, bestConsentLevel, AvvioCC.cookieExpiryDays );
var consentLevelString = AvvioCC.allPeekRequests[bestPeekIndex].consentLevelString;
if ( AvvioCC.debug ) console.log("cookie consent "+consentLevelString+" peeked from "+AvvioCC.allPeekRequests[bestPeekIndex].url);
AvvioCC.setCookie(AvvioCC.cookieNameConsentLevel, consentLevelString, AvvioCC.cookieExpiryDays );
AvvioCC.removeCookie(AvvioCC.cookieNameImpressions);
effectiveConsent=bestConsentLevel;
}
AvvioCC.initFinishUp(effectiveConsent);
}
}
};
this.allPeekRequests[peekIndex].xhttp = xhttp;
xhttp.open("GET", allRelayURLs[peekIndex]+'?peek=1', true );
xhttp.send();
}
}
AvvioCC.initCSS=function()
{
var opacityValue = 0.8;
var fontColorValue = "FFF";
var bgColorValue = "000";
var bgDarkValue = "255";
var bgLightValue = "0";
var darkBackgroundColorValue = "AAA";
var siteLogoValue = "";
var fontFamilyValue = "'Open Sans', sans-serif;";
if ( AvvioCC.colorScheme == 'dark' )
{
// nothing to do, default is "dark"
} else if ( AvvioCC.colorScheme == 'light' )
{
opacityValue = 0.8;
fontColorValue = "555";
bgColorValue = "FFF";
bgDarkValue = "0";
bgLightValue = "255";
darkBackgroundColorValue = "555";
} else if ( AvvioCC.colorScheme == 'bw' )
{
//MG: TODO
opacityValue = 0.7;
fontColorValue = "000000";
bgColorValue = "FFF";
bgDarkValue = "0";
bgLightValue = "255";
darkBackgroundColorValue = "000000";
} else
{
console.log("invalid colorScheme:"+this.colorScheme);
}
// Set fancy background color
if(this.darkBackgroundColor) darkBackgroundColorValue = this.darkBackgroundColor.replace('#','');
// Set fancy text color
if(this.fontColor) fontColorValue = this.fontColor.replace('#','');
// Set opacity
if(this.opacity) opacityValue = this.opacity;
if(this.siteLogo) siteLogoValue = this.siteLogo;
if(this.fontFamily) fontFamilyValue = this.fontFamily;
this.useCSS = this.useCSS.replace(/@FONTFAMILYV@/g,fontFamilyValue);
this.useCSS = this.useCSS.replace(/@ZINDEXV@/g,this.zIndex);
this.useCSS = this.useCSS.replace(/@OPACITY@/g,opacityValue);
this.useCSS = this.useCSS.replace(/@FONTCOLORV@/g,fontColorValue);
this.useCSS = this.useCSS.replace(/@BGCOLORV@/g,bgColorValue);
this.useCSS = this.useCSS.replace(/@BGDARKV@/g,bgDarkValue);
this.useCSS = this.useCSS.replace(/@BGLIGHTV@/g,bgLightValue);
this.useCSS = this.useCSS.replace(/@SITELOGOV@/g,siteLogoValue);
this.useCSS = this.useCSS.replace(/@DARKBACKGROUNDCOLORV@/g,darkBackgroundColorValue);
var maxWidthString = "max-width: 1100px;";
if(this.popupMaxWidth)
{
maxWidthString = "max-width: "+this.popupMaxWidth+"; min-width: 400px;";
}
this.useCSS = this.useCSS.replace(/@POPUPMAXWIDTHV@/g, maxWidthString);
// position top default 50%
var ACCpositionString = "top: 50%; transform: translateY(-50%); ";
if ( this.popupPosition.indexOf("bottom") != -1)
{
ACCpositionString = this.popupPosition+"; ";
}
else if ( this.popupPosition.indexOf("top") != -1)
{
ACCpositionString = this.popupPosition+"; ";
}
this.useCSS = this.useCSS.replace(/@POPUPPOSITIONKV@/g, ACCpositionString);
var popupAligmentString = "text-align: center;";
var popupAligmentContainerString = "";
if ( this.popupAligment.indexOf("left") != -1){
popupAligmentString = "text-align: left;";
popupAligmentContainerString = "margin-left: "+this.popupAligment.replace('left:','')+";";
}else if ( this.popupAligment.indexOf("right") != -1){
popupAligmentString = "text-align: right;";
popupAligmentContainerString = "margin-right: "+this.popupAligment.replace('right:','')+";";
}
this.useCSS = this.useCSS.replace(/@POPUPALIGMENTV@/g,popupAligmentString);
this.useCSS = this.useCSS.replace(/@POPUPALIGMENTCONTAINERV@/g,popupAligmentContainerString);
}
AvvioCC.init=function()
{
if ( this.debug ) console.log("ACC init() call");
// dom can't be savely changed until document is ready
var continueInitAtDOMReady=function()
{
if ( AvvioCC.debug ) console.log("ACC ready() callback");
AvvioCC.initCSS();
// site logo
AvvioCC.appendCSSToHead( AvvioCC.useCSS );
AvvioCC.appendHTMLTo( AvvioCC.useHTML, document.body );
if(!AvvioCC.siteLogo) document.getElementById("ACCsiteLogo").style.display = "none";
// there is no easy way passing "this" from the outside
// to the inside of this dynamic function
// we are accessing "AvvioCC" as global variable!
var impressionsWithoutConsent = false;
var consentedYet = AvvioCC.getCookie( AvvioCC.cookieNameConsentLevel );
if ( ( consentedYet != false ) && ( consentedYet.length > 0 ) ) consentedYet=AvvioCC.getWellFormatedConsentLevelFromString(consentedYet);
if ( consentedYet == false )
{
var impressionsString=AvvioCC.getCookie( AvvioCC.cookieNameImpressions );
impressionsWithoutConsent = 0;
if ( impressionsString.length > 0 )
{
impressionsWithoutConsent = parseInt(impressionsString);
}
impressionsWithoutConsent += 1;
AvvioCC.setCookie( AvvioCC.cookieNameImpressions, impressionsWithoutConsent, 1 );
} else
{
AvvioCC.initFinishUp(consentedYet);
return;
}
var relaySitesGrouped = AvvioCC.getRelaySitesByDomain();
for(var domainName in relaySitesGrouped)
{
if ( AvvioCC.debug ) console.log( domainName + ":" +relaySitesGrouped[domainName].join("##") );
}
var performPeek = true;
if ( impressionsWithoutConsent == false )
{
performPeek = false;
if ( AvvioCC.debug ) console.log("skipping peek, consent already given/peeked..");
} else
{
if ( ( AvvioCC.stopPeekAfter > 0 ) &&
( impressionsWithoutConsent >= AvvioCC.stopPeekAfter ) )
{
performPeek = false;
if ( AvvioCC.debug ) console.log("skipping peek, peeking limit reached ..");
}
}
if ( AvvioCC.primaryRelayURL.length <=0 )
{
performPeek = false;
if ( AvvioCC.debug ) console.log("skipping peek, no primary relay ...");
}
else
{
var cookieDomain = AvvioCC.getCookieDomain();
var relayDomain = AvvioCC.getRelayDomain(AvvioCC.primaryRelayURL);
if ( cookieDomain == relayDomain )
{
performPeek = false;
if ( AvvioCC.debug ) console.log("skipping peek, same domain ...");
}
}
if ( AvvioCC.allowPeek != true )
{
performPeek=false;
if ( AvvioCC.debug ) console.log("skipping peek, allow peek disabled...");
}
if ( performPeek )
{
AvvioCC.startPeekIntoRelaySites();
// premature exit, wait for result
return;
}
// NO peeking, no cosent available
if ( ! AvvioCC.silentMode )
{
AvvioCC.fadeInById('ACCsmallCookieLayer', 500);
AvvioCC.fadeInById('ACClayerBackground', 500);
}
var effectiveConsent = AvvioCC.getWellFormatedConsentLevelFromString(AvvioCC.defaultConsent);
if ( effectiveConsent == false )
{
console.log("invalid defaultConsent:" + AvvioCC.defaultConsent );
// if default consent is specified incorrectly, fallback to required
effectiveConsent="1000";
}
AvvioCC.initFinishUp(effectiveConsent);
};
// WAIT FOR DOM READY
// in case the document is already rendered
if (document.readyState!='loading') continueInitAtDOMReady();
// modern browsers
else if (document.addEventListener) document.addEventListener('DOMContentLoaded', continueInitAtDOMReady);
// IE <= 8
else document.attachEvent('onreadystatechange', function(){
if (document.readyState=='complete') continueInitAtDOMReady();
});
}
// ==========================================================================80
// public interface
AvvioCC.setDefaultsMoreDetails=function( effectiveConsent )
{
document.getElementById('ACCrequired').checked = true;
if ( effectiveConsent[1]=='1' )
{
document.getElementById('ACCfunctional').checked = true;
//AvvioCC.ACCaddClass(document.getElementById('ACCswitchFunctional'), 'switchOn');
}
if ( effectiveConsent[2]=='1' )
{
document.getElementById('ACCstatistical').checked = true;
//AvvioCC.ACCaddClass(document.getElementById('ACCswitchStatistical'), 'switchOn');
}
if ( effectiveConsent[3]=='1' )
{
document.getElementById('ACCmarketing').checked = true;
//AvvioCC.ACCaddClass(document.getElementById('ACCswitchMarketing'), 'switchOn');
}
}
AvvioCC.showMoreDetails=function(fade = true)
{
this.fadeOutById( 'ACCsmallCookieLayer', 350 );
var consentedYet = AvvioCC.getCookie( AvvioCC.cookieNameConsentLevel );
if ( ( consentedYet != false ) && ( consentedYet.length > 0 ) ) consentedYet=AvvioCC.getWellFormatedConsentLevelFromString(consentedYet);
var effectiveConsent = '1000';
if ( consentedYet != false )
{
effectiveConsent = consentedYet;
}
this.setDefaultsMoreDetails(effectiveConsent);
this.fadeInById( 'ACCtabedCookieLayer', 300 );
if(fade) this.fadeInById( 'ACClayerBackground', 350 );
document.getElementById('ACCdetailsSaveButton').scrollIntoView();
setTimeout(function(){
document.getElementById('ACCscrollToTop').scrollIntoView({behavior: 'smooth'});
}, 500);
};
AvvioCC.getConsentLevelString=function( consentLevel, source)
{
// similar to Date.toISOString()
// we needed our our version here to avoid problems with original prototype overriden
var now=new Date();
var mon = ''+(now.getUTCMonth()+1);
if ( mon.length <= 1 ) mon='0'+mon;
var day = ''+now.getUTCDate();
if ( day.length <= 1 ) day='0'+day;
var h = ''+now.getHours();
if ( h.length <= 1 ) h='0'+h;
var m = ''+now.getMinutes();
if ( m.length <= 1 ) m='0'+m;
var s = ''+now.getSeconds();
if ( s.length <= 1 ) s='0'+s;
var dateTimeString = now.getUTCFullYear()+'-'+mon+'-'+day+' '+h+':'+m+':'+s;
return consentLevel+','+dateTimeString+','+source;
}
AvvioCC.consentGivenSmall=function()
{
var consentLevel="1111";
var consentLevelString = this.getConsentLevelString( consentLevel, 's' ); // +s for small
this.setCookie(this.cookieNameConsentLevel, consentLevelString, this.cookieExpiryDays );
this.removeCookie(this.cookieNameImpressions);
this.deployCookies( consentLevel );
this.relayExplicitConsent( consentLevelString, "0000" );
this.fadeOutById( 'ACCsmallCookieLayer', 500 );
this.fadeOutById( 'ACCtabedCookieLayer', 500 );
this.fadeOutById( 'ACClayerBackground', 500 );
this.userUpdateConsent();
}
AvvioCC.saveConsentTickboxes=function()
{
function replaceCharAt( s, index, c )
{
return s.substr(0, index) + c + s.substr(index + 1);
}
var consentLevel="1000";
if ( document.getElementById('ACCfunctional').checked == true ) consentLevel=replaceCharAt(consentLevel, 1, '1');
if ( document.getElementById('ACCstatistical').checked == true ) consentLevel=replaceCharAt(consentLevel, 2, '1');
if ( document.getElementById('ACCmarketing').checked == true ) consentLevel=replaceCharAt(consentLevel, 3, '1');
var previousString = this.getCookie(this.cookieNameConsentLevel);
var previous;
if ( ( previousString != false ) && ( previousString.length > 0 ) ) previous = this.getWellFormatedConsentLevelFromString(previousString);
if ( previous == false ) previous="1000";
var consentLevelString = this.getConsentLevelString( consentLevel, 't' ); // +t for tickboxes
this.setCookie(this.cookieNameConsentLevel, consentLevelString, this.cookieExpiryDays );
this.removeCookie(this.cookieNameImpressions);
if ( consentLevel != previous )
{
this.deployCookies( consentLevel );
}
this.relayExplicitConsent( consentLevelString, previous );
this.fadeOutById( 'ACCsmallCookieLayer', 500 );
this.fadeOutById( 'ACCtabedCookieLayer', 500 );
this.fadeOutById( 'ACClayerBackground', 500 );
this.userUpdateConsent();
};
AvvioCC.invalidateConsent=function()
{
this.fadeOutById( 'ACCtabedCookieLayer', 200 );
this.fadeOutById( 'ACCsmallCookieLayer', 200 );
this.removeCookie( this.cookieNameConsentLevel );
this.fadeInById( 'ACCsmallCookieLayer', 1000 );
};
// ==========================================================================80
// init
if ( ! AvvioCC.variablesAfterScript )
{
// if variables are defined before the script, then execute init now!
AvvioCC.init();
}
// KK Js
AvvioCC.ACCremoveClass=function(el, className)
{
if (el.classList.contains(className))
el.classList.remove(className);
}
AvvioCC.ACCaddClass=function(el, className)
{
if ( ! el.classList.contains(className))
el.classList.add(className);
}
AvvioCC.isKeydownAndEnterEvent = function( event )
{
if( event.type == 'keydown' )
{
var keycode = event.keyCode ? event.keyCode : event.which;
if( keycode == '13' )
{
return true;
}
return false;
}
return true;
}
var clickedACCrow = false;
AvvioCC.ACCclickShowMore=function(id)
{
if( ! AvvioCC.isKeydownAndEnterEvent( event ) ) return;
var elements = document.getElementsByClassName('kkACCrow');
for(var i = 0; i < elements.length; i ++)
{
AvvioCC.ACCremoveClass(elements[i], 'active');
}
if(id != clickedACCrow)
{
AvvioCC.ACCaddClass(document.getElementById('kkACCrow'+id), 'active');
clickedACCrow = id;
}
else
clickedACCrow = false;
}
AvvioCC.ACCswitchAll=function(mode, event)
{
if( ! AvvioCC.isKeydownAndEnterEvent( event ) ) return;
if(mode == "on")
{
var elements = document.getElementsByClassName('kkACCSwitchLabel');
for(var i = 0; i < elements.length; i ++)
{
// switch on and checkbox
document.getElementById(elements[i].htmlFor).checked = true;
}
// wait 1000 miliseconds then save & close popup
setTimeout(function(){
AvvioCC.saveConsentTickboxes();
}, 1000)
}else if(mode == "off")
{
var elements = document.getElementsByClassName('kkACCrowSwitch');
for(var i = 0; i < elements.length; i ++)
{
// switch off and uncheckbox
document.getElementById(elements[i].htmlFor).checked = false;
}
}
}