(function ($) { var cookieVersion = '1.1'; var cookieName = 'smulweb-cookie-consent'; cookieName = cookieName + '-v' + cookieVersion; var save = function (level) { level = parseInt(level); var d = new Date(); d.setTime(d.getTime() + (90*60*60*24*1000)); document.cookie = cookieName + '=' + level + '; expires=' + d.toUTCString() + '; path=/'; // Set consent for Faktor which is used to grant access for Summit // advertising. if (level == 3) { window.__cmp('acceptAll', null, function(data) { console.log(data); }); } else { window.__cmp('revokeAll',{purposeIds:[1, 2, 3], vendorIds: []}, function(data){console.log(data)}) } // legacy if(level >= 2) { document.cookie = 'cookieOptin=true; expires=' + d.toUTCString() + '; path=/'; } }; var getLevel = function () { if (document.cookie && document.cookie.indexOf(cookieName) !== -1) { var value = "; " + document.cookie; var parts = value.split("; " + cookieName + "="); if (parts.length == 2) { value = parts.pop().split(";").shift(); if ([1, 2, 3, '1', '2', '3'].includes(value)) { return parseInt(value); } } } return -1; }; $('.js-btn-cookies-cancel').on('click', function () { window.history.back(); }); $('.js-btn-cookies-save').on('click', function () { save($('input.cookieRadio:checked').val()); $('.js-saved').removeClass('hide'); setTimeout(function () { window.history.back(); }, 500); }); $('.js-btn-cookies-accept-all').on('click', function () { save(3); $('.consent_container').addClass('hide'); }); if (getLevel() > 0) { // Set the form to the current state $('input.cookieRadio[value="' + getLevel() + '"]').prop('checked', true); $('.consent_container').addClass('hide'); } else { $('.consent_container').removeClass('hide'); } })(jQuery);