function setCookie(name, value, days) {
var d = new Date();
if (days == 0) {
d.setTime(d.getTime() + (365.25 * 100 * 24 * 60 * 60 * 1000)); // 100 years, should be infinite
}
else {
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
}
document.cookie = name + "=" + value + ";expires="+ d.toUTCString() + ";path=/;SameSite=Strict" + ((window.location.protocol == 'https:') ? ";Secure" : "");
}
function getCookie(name) {
var name = name + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function deleteCookie(name) {
setCookie(name, '-', -1);
}
function showCookiesConfirmation() {
if ($('.cc_banner-wrapper').length == 0) {
var cookies = getCookie('Cookies_OK');
var cookieHTML = '<div class="cc_banner-wrapper">' + "\n";
cookieHTML += ' <div class="cc_banner cc_container cc_container--open" style="' + ((Position == 'bottom') ? 'bottom' : 'top') + ': 0px;">' + "\n";
cookieHTML += ' <a href="#null" data-cc-event="click:agreeAll" class="cc_btn cc_btn_accept_all">' + AllButtonText + '</a>' + "\n";
cookieHTML += ' <p class="cc_message">' + Infotext;
if (Infolink != '') {
cookieHTML += ' <a rel="nofollow" data-cc-if="options.link" class="cc_more_info" href="' + Infolink + '">' + InfolinkText + '</a>';
}
cookieHTML += '</p>' + "\n";
cookieHTML += ' <div style="clear: both; height: 2px;"></div>' + "\n";
if ((MarketingText) || (PersonalizationText) || (AnalyticsText)) {
cookieHTML += ' <a href="#null" data-cc-event="click:agreeSelection" class="cc_btn cc_btn_accept_selection">' + SelectionButtonText + '</a>' + "\n";
cookieHTML += ' <p class="cc_selection">';
cookieHTML += '<label class="cc_option_toggle" title="' + RequiredText + '" for="cc_option_checkbox_required"><input type="checkbox" class="cc_option_checkbox" id="cc_option_checkbox_required" checked disabled><span class="cc_option_toggle_switch" data-name="Required"></span><span class="cc_option_toggle_label">' + RequiredText + '</span></label>';
if (MarketingText) {
cookieHTML += '<label class="cc_option_toggle" title="' + MarketingText + '" for="cc_option_checkbox_marketing"><input type="checkbox" class="cc_option_checkbox" id="cc_option_checkbox_marketing"' + (((cookies.indexOf('Marketing') > -1) || (cookies == 'All')) ? ' checked' : '') + '><span class="cc_option_toggle_switch" data-name="Marketing"></span><span class="cc_option_toggle_label">' + MarketingText + '</span></label>';
}
if (PersonalizationText) {
cookieHTML += '<label class="cc_option_toggle" title="' + PersonalizationText + '" for="cc_option_checkbox_personalization"><input type="checkbox" class="cc_option_checkbox" id="cc_option_checkbox_personalization"' + (((cookies.indexOf('Personalization') > -1) || (cookies == 'All')) ? ' checked' : '') + '><span class="cc_option_toggle_switch" data-name="Personalization"></span><span class="cc_option_toggle_label">' + PersonalizationText + '</span></label>';
}
if (AnalyticsText) {
cookieHTML += '<label class="cc_option_toggle" title="' + AnalyticsText + '" for="cc_option_checkbox_analytics"><input type="checkbox" class="cc_option_checkbox" id="cc_option_checkbox_analytics"' + (((cookies.indexOf('Analytics') > -1) || (cookies == 'All')) ? ' checked' : '') + '><span class="cc_option_toggle_switch" data-name="Analytics"></span><span class="cc_option_toggle_label">' + AnalyticsText + '</span></label>';
}
cookieHTML += '</p>' + "\n";
cookieHTML += ' <div style="clear: both;"></div>' + "\n";
}
if (ReworkText) {
cookieHTML += ' ' + ReworkText;
}
cookieHTML += ' </div>' + "\n";
cookieHTML += ' <script>' + "\n";
cookieHTML += ' $(".cc_selection .cc_option_toggle .cc_option_checkbox").each(function() {' + "\n";
cookieHTML += ' if ($(this).prop("checked")) {' + "\n";
cookieHTML += ' $(this).parent().children(".cc_option_toggle_switch").addClass("selected");' + "\n";
cookieHTML += ' }' + "\n";
cookieHTML += ' });' + "\n";
cookieHTML += ' $(".cc_selection .cc_option_toggle .cc_option_toggle_switch").click(function(e) {' + "\n";
cookieHTML += ' if (!$(this).parent().children(0).prop("disabled")) {' + "\n";
cookieHTML += ' if ($(this).parent().children(".cc_option_checkbox").prop("checked")) {' + "\n";
cookieHTML += ' $(this).parent().children(".cc_option_checkbox").attr("checked", false);' + "\n";
cookieHTML += ' $(this).parent().children(".cc_option_toggle_switch").removeClass("selected");' + "\n";
cookieHTML += ' } else {' + "\n";
cookieHTML += ' $(this).parent().children(".cc_option_checkbox").attr("checked", true);' + "\n";
cookieHTML += ' $(this).parent().children(".cc_option_toggle_switch").addClass("selected");' + "\n";
cookieHTML += ' }' + "\n";
cookieHTML += ' }' + "\n";
cookieHTML += ' });' + "\n";
cookieHTML += ' </script>' + "\n";
cookieHTML += '</div>';
$('body').prepend(cookieHTML);
$('.cc_btn_accept_all').click(function(e) {
e.preventDefault();
setCookie('Cookies_OK', 'All', 0);
$('.cc_banner-wrapper').css('display', 'none');
$('.cc_banner-wrapper').remove();
});
$('.cc_btn_accept_selection').click(function(e) {
e.preventDefault();
var sel = '';
$('.cc_option_toggle_switch').each(function() {
if ($(this).hasClass('selected')) {
sel += $(this).attr('data-name') + ',';
}
else {
if ($(this).attr('data-name') == 'Personalization') {
// We are not allowed to save personalization cookies, delete them
deleteCookie('Theme');
deleteCookie('Listview');
}
}
});
setCookie('Cookies_OK', sel.substring(0, sel.length - 1), 365);
$('.cc_banner-wrapper').css('display', 'none');
$('.cc_banner-wrapper').remove();
});
}
}
function checkCookiesOK() {
var cookie = getCookie('Cookies_OK');
if (cookie.length == 0) {
showCookiesConfirmation();
}
}
|