/* Aira GDPR Cookies bootstrap Javascript */ (function() { var debug = false; var scripts = document.getElementsByTagName('script'); var src = scripts[scripts.length - 1].src; var lang = scripts[scripts.length - 1].lang || 'cs'; var backendBase = src.substring(0, src.lastIndexOf('/') + 1); if(debug) { console.log(backendBase); console.log(lang); } window.addEventListener("load", function() { if(typeof jQuery === 'undefined') { var headTag = document.getElementsByTagName("head")[0]; var scTag = document.createElement('script'); scTag.type = 'text/javascript'; scTag.src = '//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'; scTag.onload = function() { init(jQuery); }; headTag.appendChild(scTag); } else { init(jQuery); } }); function init($){ function _cookies() { this.consentCookie = null; this.cookieName = '_AiraGdprConsent'; var that = this; var topMenuElm = ['#AiraGdprCookiesDetailBodyContentTextOverview','#AiraGdprCookiesDetailBodyContentTextAbout']; var topMenuLinks = ['#AiraGdprCookiesDetailBodyContentTabsOverview','#AiraGdprCookiesDetailBodyContentTabsAbout']; var cookieTypesElm = ['#AiraGdprCookiesDetailBodyContentCookieTabsNecessary', '#AiraGdprCookiesDetailBodyContentCookieTabsStatistics', '#AiraGdprCookiesDetailBodyContentCookieTabsAdvertising', '#AiraGdprCookiesDetailBodyContentCookieTabsUnclassified']; var categoryLinks = ['#AiraGdprCookiesDetailBodyContentCookieContainerNecessary', '#AiraGdprCookiesDetailBodyContentCookieContainerStatistical', '#AiraGdprCookiesDetailBodyContentCookieContainerAdvertising', '#AiraGdprCookiesDetailBodyContentCookieContainerUnclassified']; var stringResources = { cs: { toggleHide: 'Skrýt detaily', toggleShow: 'Zobrazit detaily', consentedAll: "nezbytných, statistických i marketingových", consentedStatistical: "nezbytných a marketingových", consentedMarketing: "nezbytných a marketingových", consentedEssential: "pouze nezbytných" }, en: { toggleHide: 'Hide details', toggleShow: 'Show details', consentedAll: "essential, statistical and marketing", consentedStatistical: "essential and statistical", consentedMarketing: "essential and marketing", consentedEssential: "only essential" }, de: { toggleHide: "Details ausblenden", toggleShow: "Zeige Details", consentedAll: "essenziell, statistisch und narketing", consentedStatistical: "essenziell und statistisch", consentedMarketing: "essenziell und marketing", consentedEssential: "nur essenziell" }, sk: { toggleHide: 'Skryť detaily', toggleShow: 'Zobraziť detaily', consentedAll: "nevyhnutných, štatistických aj marketingových", consentedStatistical: "nevyhnutných aj štatistických", consentedMarketing: "nevyhnutných aj marketingových", consentedEssential: "len nevyhnutných" } }; $(document).mouseup(function (e) { var container = $("#warning-modal"); if (container.is(":visible")) { if (that.consentCookie != null) { if (container.is(e.target)) { container.hide(); } } } }); this.addStyles = function(id,styles) { $('#' + id).remove(); $('head').append(''); }; this.linkcb = function(id1,id2) { $('#'+id1).change(function(){ $('#'+id2).prop('checked', this.checked); }); $('#'+id2).change(function(){ $('#'+id1).prop('checked', this.checked); }); } this.renderDialog = function(id,dialog) { that.dialogId = id; $(dialog).appendTo('body'); that.linkcb('AiraGdprCookiesBodyButtonsStatistics', 'AiraGdprCookiesBodyLevelButtonStatistics'); that.linkcb('AiraGdprCookiesBodyButtonsMarketing', 'AiraGdprCookiesBodyLevelButtonMarketing'); that.showDialog(); }; this.getWhiteList = function(name) { $('#' + that.dialogId + " ." + name).each(function() { that.whitelist.push($(this).text()); }); } this.setConsent = function(consentObj, expiry) { that.whitelist = []; that.getWhiteList('CookieEssential'); if(consentObj.consent.statistical){ that.getWhiteList('CookieStatistical'); } if(consentObj.consent.marketing){ that.getWhiteList('CookieMarketing'); } if(debug) console.log(that.whitelist); that.removeCookies(); that.setCookie(cm.cookieName, JSON.stringify(consentObj), expiry); that.consentCookie = consentObj; if(consentObj.consentKey) { that.enableCookies(); } }; this.decline = function() { $('#AiraGdprCookiesBodyLevelButtonStatistics').prop('checked', false); $('#AiraGdprCookiesBodyLevelButtonMarketing').prop('checked', false); that.saveConsent(); }; this.saveConsentAll = function () { var essential = true; var statistical = $('#AiraGdprCookiesBodyLevelButtonStatistics').prop('checked', true); var marketing = $('#AiraGdprCookiesBodyLevelButtonMarketing').prop('checked', true); // var statistical = $('#AiraGdprCookiesBodyLevelButtonStatistics').is(':checked'); // var marketing = $('#AiraGdprCookiesBodyLevelButtonMarketing').is(':checked'); $('#' + that.dialogId).hide(); var url = "consent.js?"; if (that.consentCookie != null) { if (that.consentCookie.consent.essential === essential && that.consentCookie.consent.statistical === statistical && that.consentCookie.consent.marketing === marketing) { return; } if (that.consentCookie.consentKey) { //withdraw url += "consentWithdraw=" + that.consentCookie.consentKey + "&"; } } url += "essential=true&"; url += "statistical=true&"; url += "marketing=true&"; url += "lang=" + lang; that.backendRequest(url); /* hides popup after accepting some cookies */ var popupDiv = document.getElementById("warning-modal"); if (popupDiv != null) popupDiv.style.display = "none"; }; this.saveOnlyEssential = function () { var url = "consent.js?"; var url = "consent.js?"; url += "essential=true&"; url += "statistical=false&"; url += "marketing=false&"; url += "lang=" + lang; that.backendRequest(url); /* hides popup after accepting some cookies */ var popupDiv = document.getElementById("warning-modal"); if (popupDiv != null) popupDiv.style.display = "none"; }; this.saveConsent = function() { var essential = true; // var statistical = $('#AiraGdprCookiesBodyLevelButtonStatistics').is(':checked'); // var marketing = $('#AiraGdprCookiesBodyLevelButtonMarketing').is(':checked'); var statistical = $('#AiraGdprCookiesBodyLevelButtonStatistics').prop('checked'); var marketing = $('#AiraGdprCookiesBodyLevelButtonMarketing').prop('checked'); $('#' + that.dialogId).hide(); var url = "consent.js?"; if(that.consentCookie != null) { if (that.consentCookie.consent.statistical === statistical && that.consentCookie.consent.marketing === marketing) { var popupDiv = document.getElementById("warning-modal"); if (popupDiv != null) popupDiv.style.display = "none"; } if(that.consentCookie.consent.essential === essential && that.consentCookie.consent.statistical === statistical && that.consentCookie.consent.marketing === marketing) { return; } if(that.consentCookie.consentKey) { //withdraw url += "consentWithdraw="+that.consentCookie.consentKey+"&"; } } url += "essential="+essential+"&"; url += "statistical="+statistical+"&"; url += "marketing="+marketing+"&"; url += "lang="+lang; that.backendRequest(url); /* hides popup after accepting some cookies */ var popupDiv = document.getElementById("warning-modal"); if (popupDiv != null) popupDiv.style.display = "none"; }; this.formatDate = function(date) { function prepend0(i) { if(i < 10) i = '0' + i; return i; } date = new Date(date); let year = date.getFullYear(); let month = prepend0(date.getMonth()+1); let day = prepend0(date.getDate()); return day + "." + month + "." + year; }, this.getFormattedConsent = function() { if(that.consentCookie.consent.statistical && that.consentCookie.consent.marketing) { return stringResources[lang].consentedAll; } else if(that.consentCookie.consent.statistical) { return stringResources[lang].consentedStatistical; } else if(that.consentCookie.consent.marketing) { return stringResources[lang].consentedMarketing; } else { return stringResources[lang].consentedEssential; } }; this.showDialog = function() { if(!that.dialogId){ that.backendRequest('dialog.js?referer=' + encodeURIComponent(window.location.hostname) + "&lang=" + lang); } else { var popupDiv = document.getElementById("warning-modal"); var onlyEssentialButton = document.getElementById("only-essential"); if (debug) console.log(that.consentCookie); if (that.consentCookie != null) { $('#AiraGdprCookiesBodyLevelButtonStatistics').prop('checked', that.consentCookie.consent.statistical); $('#AiraGdprCookiesBodyLevelButtonMarketing').prop('checked', that.consentCookie.consent.marketing); $('#AiraGdprCookiesBodyButtonsStatistics').prop('checked', that.consentCookie.consent.statistical); $('#AiraGdprCookiesBodyButtonsMarketing').prop('checked', that.consentCookie.consent.marketing); $('#AiraGdprCookiesCurrentConsentDate').text(that.formatDate(that.consentCookie.consentDate)); $('#AiraGdprCookiesCurrentConsentOptions').text(that.getFormattedConsent()); $('#AiraGdprCookiesCurrentConsent').show(); if (onlyEssentialButton != null) onlyEssentialButton.style.display = "none"; } else { $('#AiraGdprCookiesCurrentConsent').hide(); } $('#' + that.dialogId).show(); if (popupDiv != null) popupDiv.style.display = "flex"; } }; this.toggleDetails = function() { $('#AiraGdprCookiesDetail').slideToggle(250, function () { var button = $('#AiraGdprCookiesBodyButtonDetails'); const screenWidth = $(window).width(); if ($('#AiraGdprCookiesDetail').is(':visible')) { button.html(stringResources[lang].toggleHide + ' ▴'); button.addClass('AiraGdprCookiesBodyLinkExpanded'); if (screenWidth <= 480) { var acceptButton = document.getElementById("accept-button"); acceptButton.scrollIntoView({ behavior: "smooth" }); } } else { button.html(stringResources[lang].toggleShow + ' ▾'); button.removeClass('AiraGdprCookiesBodyLinkExpanded'); } }); }; this.toggleElements = function(arrElements,arrLinks,indexActive,activeClass,inactiveClass) { arrElements.forEach(function(e) { $(e).hide(); }); arrLinks.forEach(function(e) { $(e).removeClass(activeClass); !inactiveClass || $(e).addClass(inactiveClass); }) $(arrElements[indexActive]).show(); $(arrLinks[indexActive]).addClass(activeClass); !inactiveClass || $(arrLinks[indexActive]).removeClass(inactiveClass); }; this.showAbout = function() { that.toggleElements(topMenuElm,topMenuLinks,1,'AiraGdprCookiesDetailBodyContentTabsItemSelected'); }; this.showList = function() { that.toggleElements(topMenuElm,topMenuLinks,0,'AiraGdprCookiesDetailBodyContentTabsItemSelected'); }; this.showCategory = function(i) { that.toggleElements(cookieTypesElm,categoryLinks,i,'AiraGdprCookiesDetailBodyContentCookieContainerTypesSelected','AiraGdprCookiesDetailBodyContentCookieContainerTypes'); }; this.backendRequest = function(url) { $('head').append(''); }; this.setCookie = function(name, value, expiry) { var d = new Date(); d.setTime(d.getTime() + expiry); var expires = "expires="+ d.toUTCString(); document.cookie = name + "=" + value + ";path=/;" + expires + ";secure"; }; this.getCookie = function(name) { var values = document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)'); return values ? values.pop() : ''; }; this.enableCookies = function() { if(that.consentCookie) { $('script:not([defer])').each(function() { that.filterScript($(this)); }); $('script[defer]').each(function() { that.filterScript($(this)); }); $('iframe, img, audio, video, embed').each(function() { that.filterSource($(this)); }); } }; this.filterScript = function(element) { if(debug) console.log("filterSource %s / %s", element.attr("type"), element.data("cookiecategory")); if(element.attr("type") == "text/plain" && element.data("cookiecategory")) { var types = element.data("cookiecategory").split(','); for(var i = 0; i < types.length; ++i){ var type = types[i].trim(); if (type.startsWith('!')) { var newType = type.substring(1); if (that.consentCookie.consent[newType]) { return; } } if(!that.consentCookie.consent[type]) { return; } } if(debug) console.log("Enabling script..."); var clone = $('