1(function () { 2 'use strict'; 3 4 var config = window.oyopiRgpdConsent || {}; 5 var cookieName = config.cookieName || 'cookie_consent'; 6 var cookieDays = config.cookieDays || 21; 7 8 function setCookie(name, value, days) { 9 var expires = ''; 10 if (days) { 11 var date = new Date(); 12 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 13 expires = '; expires=' + date.toUTCString(); 14 } 15 document.cookie = name + '=' + (value || '') + expires + '; path=/'; 16 } 17 18 function getCookie(name) { 19 var nameEQ = name + '='; 20 var cookies = document.cookie.split(';'); 21 22 for (var i = 0; i < cookies.length; i++) { 23 var cookie = cookies[i]; 24 while (cookie.charAt(0) === ' ') { 25 cookie = cookie.substring(1); 26 } 27 if (cookie.indexOf(nameEQ) === 0) { 28 return cookie.substring(nameEQ.length); 29 } 30 } 31 32 return null; 33 } 34 35 function hideCookieNotice() { 36 var notice = document.getElementById('cookie-notice'); 37 if (notice) { 38 notice.style.display = 'none'; 39 } 40 } 41 42 function deleteCookie(name, path, domain) { 43 document.cookie = name + '=; Path=' + (path || '/') + '; Domain=' + (domain || document.domain) + '; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; 44 } 45 46 function deleteGACookies() { 47 var currentDomain = document.domain.split('.').slice(-2); 48 deleteCookie('_ga', '/', '.' + currentDomain[0] + '.' + currentDomain[1]); 49 deleteCookie('_gid', '/', '.' + currentDomain[0] + '.' + currentDomain[1]); 50 } 51 52 function setConsent(allow) { 53 var status = allow ? 'allow' : 'deny'; 54 55 if (typeof wp_set_consent === 'function') { 56 wp_set_consent('statistics', status); 57 wp_set_consent('marketing', status); 58 return; 59 } 60 61 if (typeof gtag === 'function') { 62 gtag('consent', 'update', { 63 analytics_storage: allow ? 'granted' : 'denied', 64 ad_storage: allow ? 'granted' : 'denied', 65 ad_user_data: allow ? 'granted' : 'denied', 66 ad_personalization: allow ? 'granted' : 'denied' 67 }); 68 } 69 } 70 71 function restoreConsentFromCookie() { 72 var consent = getCookie(cookieName); 73 if (!consent) { 74 return; 75 } 76 77 setConsent(consent === 'yes'); 78 hideCookieNotice(); 79 } 80 81 function bindBannerActions() { 82 var refuseButton = document.getElementById('cn-refuse-cookie'); 83 var acceptButton = document.getElementById('cn-accept-cookie'); 84 85 if (refuseButton) { 86 refuseButton.onclick = function () { 87 setConsent(false); 88 hideCookieNotice(); 89 setCookie(cookieName, 'no', cookieDays); 90 if (typeof printCookieConsentValue === 'function') { 91 printCookieConsentValue(false); 92 } 93 deleteGACookies(); 94 return false; 95 }; 96 } 97 98 if (acceptButton) { 99 acceptButton.onclick = function () { 100 setConsent(true); 101 hideCookieNotice(); 102 setCookie(cookieName, 'yes', cookieDays); 103 if (typeof printCookieConsentValue === 'function') { 104 printCookieConsentValue(true); 105 } 106 return false; 107 }; 108 } 109 } 110 111 function initBanner() { 112 bindBannerActions(); 113 restoreConsentFromCookie(); 114 } 115 116 if (document.readyState === 'loading') { 117 document.addEventListener('DOMContentLoaded', initBanner); 118 } else { 119 initBanner(); 120 } 121})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.