function getCookie(name) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop().split(';').shift(); } var Checked_preferenze = Checked_marketing = Checked_statistiche = ""; var cookie_prechoice = getCookie("clion_cookie"); if(typeof cookie_prechoice !== 'undefined'){ var arrChoices = cookie_prechoice.split('-'); if(arrChoices[0]==1){ //checked Checked_preferenze = "checked"; } if(arrChoices[1]==1){ //checked Checked_statistiche = "checked"; } if(arrChoices[2]==1){ //checked Checked_marketing = "checked"; } } function scriviCookie(nomeCookie,valoreCookie,durataCookie) { var scadenza = new Date(); var adesso = new Date(); scadenza.setTime(adesso.getTime() + (parseInt(durataCookie) * 60000)); document.cookie = nomeCookie + '=' + escape(valoreCookie) + '; expires=' + scadenza.toGMTString() + '; path=/'; console.log("cookie"); } function scriviCookie_time(nomeCookie,valoreCookie,durataCookie) { var scadenza = new Date(); var adesso = new Date(); scadenza.setTime(adesso.getTime() + (parseInt(durataCookie))); document.cookie = nomeCookie + '=' + escape(valoreCookie) + '; expires=' + scadenza.toGMTString() + '; path=/'; console.log("cookie"); } function toggleCookiebar(){ console.log('toggleCookiebar'); var el = document.querySelector('#clion_cookieBar'); el.classList.toggle('clion_cookieBar__show'); } function trayToggleCookiebar(){ console.log('trayToggleCookiebar'); var el = document.querySelector('#clion_cookieBar'); el.classList.toggle('clion_cookieBar__tray'); } function richiesta_ajax() { var isChecked_preferenze = isChecked_marketing = isChecked_statistiche = 0; if(document.getElementById('clion_preferenze').checked){ //checked isChecked_preferenze = 1; } if(document.getElementById('clion_marketing').checked){ //checked isChecked_marketing = 1; } if(document.getElementById('clion_statistiche').checked){ //checked isChecked_statistiche = 1; } scriviCookie( 'clion_cookie' ,isChecked_preferenze+'-'+isChecked_statistiche+'-'+isChecked_marketing,43200); var xmlhttp = new XMLHttpRequest(); xmlhttp.withCredentials = true; xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 if (xmlhttp.status == 200) { console.log("fatto"); document.getElementById('frame_cookie').contentWindow.location.reload(true); } else if (xmlhttp.status == 400) { console.log("errore"); } else { alert('something else other than 200 was returned'); } } }; window.location.reload(); } function richiesta_ajax_refuse() { var isChecked_preferenze = isChecked_marketing = isChecked_statistiche = 0; isChecked_preferenze = 0; isChecked_marketing = 0; isChecked_statistiche = 0; scriviCookie_time( 'clion_cookie' ,isChecked_preferenze+'-'+isChecked_statistiche+'-'+isChecked_marketing, 180 * 24 * 60 * 60 * 1000); var xmlhttp = new XMLHttpRequest(); xmlhttp.withCredentials = true; xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 if (xmlhttp.status == 200) { console.log("fatto"); document.getElementById('frame_cookie').contentWindow.location.reload(true); } else if (xmlhttp.status == 400) { console.log("errore"); } else { alert('something else other than 200 was returned'); } } }; window.location.reload(); } if (document.cookie.length > 0) { var inizio = document.cookie.indexOf( "ea45e9f505a6d43cd791acef488d0763" + "="); var inizio_gdpr = document.cookie.indexOf( "clion_cookie" + "="); var tray_if_compiled = ""; if ((inizio != -1)||(inizio_gdpr != -1)) { // already compiled tray_if_compiled = "clion_cookieBar__tray"; // /already compiled } //else { // not compiled document.write(''); document.write('
'); //} // /not compiled }else{ document.write(''); document.write(' '); } var trayBar = document.querySelector('#clion_cookieBar'); trayBar.addEventListener('click', function (event) { if(trayBar.classList.contains("clion_cookieBar__tray")){ trayBar.classList.remove('clion_cookieBar__tray'); } });