Gestione della nuova cookie policy completata
This commit is contained in:
@@ -211,23 +211,17 @@ const cookieBlockHtml_Bs4 = `
|
||||
</div>`;
|
||||
|
||||
// Terze Parti Html Block
|
||||
const cookieAnalyticsGTagBlock = `
|
||||
<script class="gtag_block" async src="https://www.googletagmanager.com/gtag/js?id=UA-15275419-1"></script>
|
||||
<script class="gtag_block">
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-15275419-1');
|
||||
</script>`;
|
||||
const cookieAnalyticsGTagBlock = ``;
|
||||
|
||||
// Funzioni per la gestione dei cookie
|
||||
function createCookie(name, value, days) {
|
||||
const expires = () => {
|
||||
if(!days) return "";
|
||||
let expires = "";
|
||||
if (days) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
return "; expires=" + date.toGMTString();
|
||||
};
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
}
|
||||
|
||||
document.cookie = name + "=" + value + expires + "; path=/";
|
||||
}
|
||||
|
||||
@@ -251,7 +245,7 @@ function removeCookieTerzeParti() {
|
||||
}
|
||||
|
||||
function addCookieTerzeParti() {
|
||||
$(document.head).append(cookieAnalyticsGTagBlock);
|
||||
if(cookieAnalyticsGTagBlock) $(document.head).append(cookieAnalyticsGTagBlock);
|
||||
}
|
||||
|
||||
function closeBanner(slide = true) {
|
||||
|
||||
Vendored
+1
-8
@@ -189,11 +189,4 @@ const cookiePolicyUrl="https://www.adriaticasistemi.it/it/cookiepolicy",cookieAp
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`,cookieAnalyticsGTagBlock=`
|
||||
<script class="gtag_block" async src="https://www.googletagmanager.com/gtag/js?id=UA-15275419-1"></script>
|
||||
<script class="gtag_block">
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-15275419-1');
|
||||
</script>`;function createCookie(o,i,e){document.cookie=o+"="+i+(()=>{if(!e)return"";const o=new Date;return o.setTime(o.getTime()+24*e*60*60*1e3),"; expires="+o.toGMTString()})+"; path=/"}function readCookie(o){var e=o+"=",t=document.cookie.split(";");for(let i=0;i<t.length;i++){let o=t[i];for(;" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null}function eraseCookie(o){createCookie(o,"",-1)}function removeCookieTerzeParti(){$(".gtag_block").remove()}function addCookieTerzeParti(){$(document.head).append(cookieAnalyticsGTagBlock)}function closeBanner(o=!0){const i=$("#cookie_banner"),e=$("#cookie_main_btn");o?i.slideUp():i.hide(),o?e.slideDown():e.show()}function showBanner(o=!0){const i=$("#cookie_banner"),e=$("#cookie_main_btn");o?i.slideDown():i.show(),o?e.slideUp():e.hide()}function initCookiePlugin(){var o=4===cookieBsVersione?cookieBlockStyle_Bs4:cookieBlockStyle,i=4===cookieBsVersione?cookieBlockHtml_Bs4:cookieBlockHtml;$(document.head).append(o),$(document.body).append(i)}$(document).ready(function(){initCookiePlugin();var o=JSON.parse(readCookie("cookiePolicyInfo"));(readCookie("displayCookiePolicy")?closeBanner:showBanner)(!1),o&&o.CheckCookieTerzeParti&&addCookieTerzeParti()}).delegate(".cookie_btn","click",o=>{o.preventDefault();const i=$(o.target);if(!i.attr("disabled")){const e=i.children("i");o="all"===i.data("cookie");const t={url:cookieApiUrl,type:"POST",dataType:"json",contentType:"application/json",data:JSON.stringify({CheckCookieTecnici:!0,CheckCookieTerzeParti:o,UrlSito:window.location.host})},a=o?"fa-check":"fa-times";e.removeClass(a).addClass("fa-circle-o-notch fa-spin"),$(".cookie_btn").attr("disabled",!0),cookieApiH&&(t.headers={Authorization:cookieApiH}),$.ajax(t).done(o=>{createCookie("displayCookiePolicy",o.Identificativo,cookieExpiresDays),createCookie("cookiePolicyInfo",JSON.stringify(o),cookieExpiresDays),(o.CheckCookieTerzeParti?addCookieTerzeParti:removeCookieTerzeParti)(),closeBanner()}).fail(()=>{eraseCookie("displayCookiePolicy"),eraseCookie("cookiePolicyInfo")}).always(()=>{$(".cookie_btn").removeAttr("disabled"),e.removeClass("fa-circle-o-notch fa-spin").addClass(a)})}}).delegate("#cookie_main_btn","click",()=>{showBanner()}).delegate("#close_btn","click",()=>{closeBanner()});
|
||||
</div>`,cookieAnalyticsGTagBlock="";function createCookie(o,i,e){let c="";if(e){const t=new Date;t.setTime(t.getTime()+24*e*60*60*1e3),c="; expires="+t.toGMTString()}document.cookie=o+"="+i+c+"; path=/"}function readCookie(o){var e=o+"=",c=document.cookie.split(";");for(let i=0;i<c.length;i++){let o=c[i];for(;" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null}function eraseCookie(o){createCookie(o,"",-1)}function removeCookieTerzeParti(){$(".gtag_block").remove()}function addCookieTerzeParti(){cookieAnalyticsGTagBlock&&$(document.head).append(cookieAnalyticsGTagBlock)}function closeBanner(o=!0){const i=$("#cookie_banner"),e=$("#cookie_main_btn");o?i.slideUp():i.hide(),o?e.slideDown():e.show()}function showBanner(o=!0){const i=$("#cookie_banner"),e=$("#cookie_main_btn");o?i.slideDown():i.show(),o?e.slideUp():e.hide()}function initCookiePlugin(){var o=4===cookieBsVersione?cookieBlockStyle_Bs4:cookieBlockStyle,i=4===cookieBsVersione?cookieBlockHtml_Bs4:cookieBlockHtml;$(document.head).append(o),$(document.body).append(i)}$(document).ready(function(){initCookiePlugin();var o=JSON.parse(readCookie("cookiePolicyInfo"));(readCookie("displayCookiePolicy")?closeBanner:showBanner)(!1),o&&o.CheckCookieTerzeParti&&addCookieTerzeParti()}).delegate(".cookie_btn","click",o=>{o.preventDefault();const i=$(o.target);if(!i.attr("disabled")){const e=i.children("i");o="all"===i.data("cookie");const c={url:cookieApiUrl,type:"POST",dataType:"json",contentType:"application/json",data:JSON.stringify({CheckCookieTecnici:!0,CheckCookieTerzeParti:o,UrlSito:window.location.host})},t=o?"fa-check":"fa-times";e.removeClass(t).addClass("fa-circle-o-notch fa-spin"),$(".cookie_btn").attr("disabled",!0),cookieApiH&&(c.headers={Authorization:cookieApiH}),$.ajax(c).done(o=>{createCookie("displayCookiePolicy",o.Identificativo,cookieExpiresDays),createCookie("cookiePolicyInfo",JSON.stringify(o),cookieExpiresDays),(o.CheckCookieTerzeParti?addCookieTerzeParti:removeCookieTerzeParti)(),closeBanner()}).fail(()=>{eraseCookie("displayCookiePolicy"),eraseCookie("cookiePolicyInfo")}).always(()=>{$(".cookie_btn").removeAttr("disabled"),e.removeClass("fa-circle-o-notch fa-spin").addClass(t)})}}).delegate("#cookie_main_btn","click",()=>{showBanner()}).delegate("#close_btn","click",()=>{closeBanner()});
|
||||
Reference in New Issue
Block a user