1(function(){ 2 window.addEventListener('cookieadmin_before_consent_display', function(){ 3 if(cookieadmin_pro_handle_gpc()){ 4 cookieadmin_policy.hide_banner = true; 5 } 6 }); 7})() 8 9function cookieadmin_pro_set_consent(prefrenc, days) { 10 11 // Handling GPC override, preventing GPC signal 12 if(cookieadmin_pro_vars && cookieadmin_pro_vars.respect_gpc){ 13 if(!cookieadmin_pro_handle_set_gpc()){ 14 return false; 15 } 16 } 17 18 const data = 'action=cookieadmin_pro_ajax_handler&cookieadmin_act=save_consent' + 19 '&cookieadmin_preference=' + encodeURIComponent(JSON.stringify(Object.keys(prefrenc))); 20 21 22 let payload = data; 23 if (cookieadmin_is_obj(cookieadmin_is_consent) && !!cookieadmin_is_consent.consent) { 24 payload += '&cookieadmin_consent_id=' + cookieadmin_is_consent.consent; 25 } 26 27 // Make async request â don't block or wait 28 const xhttp = new XMLHttpRequest(); 29 30 xhttp.open('POST', cookieadmin_pro_vars.ajax_url, true); // true = async 31 32 xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 33 34 xhttp.onload = function () { 35 if(this.status === 200){ 36 try { 37 const parsed = JSON.parse(this.responseText); 38 if (parsed.success && parsed.data && parsed.data.response) { 39 cookieadmin_save_consent_cookie(prefrenc, days, parsed.data.response); 40 41 // Showing override option if we have GPC enabled. 42 if(cookieadmin_pro_vars && cookieadmin_pro_vars.respect_gpc){ 43 var overrideEle = document.getElementById('cookieadmin_gpc_override'); 44 45 if(overrideEle){ 46 overrideEle.style.display = 'block'; 47 } 48 } 49 } 50 } catch (e) { 51 console.error("Invalid JSON response:", e); 52 } 53 } 54 }; 55 56 xhttp.onerror = function () { 57 console.error("AJAX request failed"); 58 }; 59 60 xhttp.send(payload); 61 62 // Immediately return 63 return true; 64} 65 66// Decided if GPC is enabled and if user has enabled the override when saving preference 67function cookieadmin_pro_handle_set_gpc(){ 68 var consentData = cookieadmin_is_cookie("cookieadmin_consent"); 69 if (consentData && consentData.respect_gpc) { 70 var override = document.getElementById('cookieadmin-override_gpc'); 71 72 if(!override || !override.checked){ 73 alert(cookieadmin_pro_vars.gpc_alert ? cookieadmin_pro_vars.gpc_alert : 'Please accept override GPC before saving preference.'); 74 return false; 75 } 76 } 77 78 return true; 79} 80 81// GPC (Global Privacy Control) Detection and Handling 82function cookieadmin_pro_check_gpc(){ 83 // Check if respect_gpc setting is enabled 84 if(!cookieadmin_pro_vars || !cookieadmin_pro_vars.respect_gpc){ 85 return false; 86 } 87 88 // Check navigator.globalPrivacyControl property (browser-level GPC signal) 89 if(typeof navigator !== 'undefined' && typeof navigator.globalPrivacyControl !== 'undefined'){ 90 if(navigator.globalPrivacyControl === true || navigator.globalPrivacyControl === 'true'){ 91 return true; 92 } 93 } 94 95 // Check if GPC was detected server-side (Sec-GPC header) 96 if(cookieadmin_pro_vars && cookieadmin_pro_vars.gpc_enabled){ 97 return true; 98 } 99 100 return false; 101} 102 103function cookieadmin_pro_handle_gpc(){ 104 // Check if GPC is enabled and should be respected 105 if(!cookieadmin_pro_check_gpc()){ 106 return false; 107 } 108 109 // Handling visibility of Override option in Cookie Customizer modal 110 var overRideEle = document.getElementById('cookieadmin_gpc_override'); 111 var consentData = cookieadmin_is_cookie("cookieadmin_consent"); 112 113 if(overRideEle){ 114 overRideEle.style.display = (consentData && consentData.respect_gpc === true) ? '' : 'none'; 115 } 116 117 // Check if consent was already saved 118 if(consentData){ 119 return false; 120 } 121 122 // Apply auto-reject consent for GPC users 123 // Only allow necessary/functional cookies, reject analytics and marketing 124 const gpc_preferences = { 125 'functional': true, 126 'respect_gpc': true, 127 }; 128 129 // Set consent for 365 days 130 cookieadmin_pro_set_consent(gpc_preferences, 365); 131 132 // Show GPC honored message if banner element exists 133 cookieadmin_pro_show_gpc_message(); 134 135 return true; 136} 137 138function cookieadmin_pro_show_gpc_message() { 139 140 var toast = document.getElementById('cookieadmin-gpc-toast'); 141 142 if(!toast){ 143 return; 144 } 145 146 closeBtn = toast.querySelector('button'); 147 148 if(!closeBtn){ 149 return; 150 } 151 152 // Add hover effects for the close button 153 closeBtn.addEventListener('mouseenter', () => closeBtn.style.opacity = '1'); 154 closeBtn.addEventListener('mouseleave', () => closeBtn.style.opacity = '0.7'); 155 156 // Add click event to remove the toast with a fade-out animation 157 closeBtn.addEventListener('click', () => { 158 toast.style.opacity = '0'; 159 toast.style.transform = 'translateY(20px)'; 160 toast.style.transition = 'opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s'; 161 toast.style.visibility = 'hidden'; 162 setTimeout(() => { 163 if (document.body.contains(toast)) { 164 document.body.removeChild(toast); 165 } 166 }, 300); // Wait for transition to finish 167 }); 168 169 // Trigger the fade-in animation 170 requestAnimationFrame(() => { 171 toast.style.visibility = 'visible'; 172 toast.style.opacity = '1'; 173 toast.style.transform = 'translateY(0)'; 174 toast.style.transition = 'opacity 0.3s ease, transform 0.3s ease, visibility 0s'; 175 }); 176 177 // Auto-hide after 10 seconds 178 setTimeout(() => { 179 if(document.body.contains(toast)){ 180 toast.style.opacity = '0'; 181 toast.style.transform = 'translateY(20px)'; 182 toast.style.transition = 'opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s'; 183 toast.style.visibility = 'hidden'; 184 setTimeout(() => { 185 if (document.body.contains(toast)) { 186 document.body.removeChild(toast); 187 } 188 }, 300); 189 } 190 }, 10000); 191} 192
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.