| 1 |
const days = cookieadmin_policy.cookieadmin_days; |
| 2 |
|
| 3 |
if(typeof cookieadmin_is_consent === 'undefined'){ |
| 4 |
window.cookieadmin_is_consent = {}; |
| 5 |
} |
| 6 |
var cookieadmin_allcookies = cookieadmin_policy.categorized_cookies; |
| 7 |
//setInterval(cookieadmin_categorize_cookies, 5000); |
| 8 |
|
| 9 |
function cookieadmin_is_obj(consentObj){ |
| 10 |
return (Object.keys(consentObj).length !== 0); |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
// function cookieadmin_cookie_interceptor(){ |
| 15 |
|
| 16 |
const originalCookieDescriptor = |
| 17 |
Object.getOwnPropertyDescriptor(Document.prototype, 'cookie') || |
| 18 |
Object.getOwnPropertyDescriptor(document, 'cookie'); |
| 19 |
var allowed_cookies = ''; |
| 20 |
|
| 21 |
// Override document.cookie to intercept cookie setting. |
| 22 |
Object.defineProperty(document, 'cookie', { |
| 23 |
configurable: true, |
| 24 |
enumerable: true, |
| 25 |
get: function(){ |
| 26 |
return originalCookieDescriptor.get.call(document); |
| 27 |
}, |
| 28 |
set: function(val){ |
| 29 |
|
| 30 |
val_name = val.split("=")[0].trim(); |
| 31 |
rm_val = val_name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; |
| 32 |
|
| 33 |
if(val_name === "cookieadmin_consent"){ |
| 34 |
return originalCookieDescriptor.set.call(document, val); |
| 35 |
} |
| 36 |
|
| 37 |
if(cookieadmin_is_obj(cookieadmin_is_consent) && (val_name in cookieadmin_allcookies) ){ |
| 38 |
|
| 39 |
switch(cookieadmin_is_consent.action){ |
| 40 |
|
| 41 |
case "reject": |
| 42 |
if(cookieadmin_allcookies[val_name].sync){ |
| 43 |
cookieadmin_allcookies[val_name].sync = false; |
| 44 |
return originalCookieDescriptor.set.call(document, rm_val); |
| 45 |
} |
| 46 |
return true; |
| 47 |
|
| 48 |
case "accept": |
| 49 |
if(!cookieadmin_allcookies[val_name].sync){ |
| 50 |
cookieadmin_allcookies[val_name].sync = true; |
| 51 |
return originalCookieDescriptor.set.call(document, val); |
| 52 |
} |
| 53 |
return true; |
| 54 |
|
| 55 |
default: |
| 56 |
if(cookieadmin_is_consent.action[cookieadmin_allcookies[val_name].category] && !cookieadmin_allcookies[val_name].sync){ |
| 57 |
cookieadmin_allcookies[val_name].sync = true; |
| 58 |
return originalCookieDescriptor.set.call(document, val); |
| 59 |
} |
| 60 |
else if(!(cookieadmin_is_consent.action[cookieadmin_allcookies[val_name].category]) && cookieadmin_allcookies[val_name].sync){ |
| 61 |
cookieadmin_allcookies[val_name].sync = false; |
| 62 |
return originalCookieDescriptor.set.call(document, rm_val); |
| 63 |
} |
| 64 |
return true; |
| 65 |
} |
| 66 |
|
| 67 |
}else{ |
| 68 |
(cookieadmin_allcookies[val_name] = cookieadmin_allcookies[val_name] || {}).string = val.trim(); |
| 69 |
return false; |
| 70 |
} |
| 71 |
|
| 72 |
} |
| 73 |
}); |
| 74 |
// } |
| 75 |
// cookieadmin_cookie_interceptor(); |
| 76 |
|
| 77 |
|
| 78 |
function cookieadmin_is_cookie(name){ |
| 79 |
|
| 80 |
if(!document.cookie) return false; |
| 81 |
|
| 82 |
let coki = document.cookie.split(";") ; |
| 83 |
|
| 84 |
if(name == "all"){ |
| 85 |
return coki ? coki : []; |
| 86 |
} |
| 87 |
let nam = name + "="; |
| 88 |
|
| 89 |
for(let i=0; i < coki.length; i++){ |
| 90 |
if(coki[i].trim().indexOf(nam) == 0){ |
| 91 |
return coki[i].trim(); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
return false; |
| 96 |
} |
| 97 |
|
| 98 |
function cookieadmin_check_consent(){ |
| 99 |
|
| 100 |
if(cookieadmin_cookie = cookieadmin_is_cookie("cookieadmin_consent")){ |
| 101 |
cookieadmin_cookie = JSON.parse(cookieadmin_cookie.split("=")[1]); |
| 102 |
if(!!cookieadmin_cookie.consent){ |
| 103 |
cookieadmin_is_consent.consent = cookieadmin_cookie.consent; |
| 104 |
delete cookieadmin_cookie.consent; |
| 105 |
} |
| 106 |
cookieadmin_is_consent.action = cookieadmin_cookie; |
| 107 |
} |
| 108 |
} |
| 109 |
cookieadmin_check_consent(); |
| 110 |
|
| 111 |
function cookieadmin_restore_cookies(update) { |
| 112 |
|
| 113 |
var cookieadmin_accepted_categories = []; |
| 114 |
|
| 115 |
if(update.accept && update.accept == "true"){ |
| 116 |
|
| 117 |
document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){ |
| 118 |
key = e.children[0].id; |
| 119 |
if (key.includes("cookieadmin-")) { |
| 120 |
key = key.replace("cookieadmin-", ""); |
| 121 |
cookieadmin_accepted_categories.push(key); |
| 122 |
} |
| 123 |
}); |
| 124 |
|
| 125 |
}else if(update.reject && update.reject == "true"){ |
| 126 |
return true; |
| 127 |
}else{ |
| 128 |
for (const [key, value] of Object.entries(update)) { |
| 129 |
if(key != "consent"){ |
| 130 |
cookieadmin_accepted_categories.push(key); |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
cookieadmin_accepted_categories.forEach(function(category) { |
| 136 |
|
| 137 |
document.querySelectorAll( |
| 138 |
'script[type="text/plain"][data-cookieadmin-category="' + category + '"]' |
| 139 |
).forEach(function(el) { |
| 140 |
const newScript = document.createElement('script'); |
| 141 |
|
| 142 |
// Copy attributes |
| 143 |
if (el.src) { |
| 144 |
newScript.src = el.src; |
| 145 |
} else { |
| 146 |
newScript.text = el.textContent; |
| 147 |
} |
| 148 |
|
| 149 |
if (el.defer) newScript.defer = true; |
| 150 |
if (el.async) newScript.async = true; |
| 151 |
|
| 152 |
// Copy other attributes if needed |
| 153 |
['id', 'class', 'data-name'].forEach(attr => { |
| 154 |
if (el.hasAttribute(attr)) { |
| 155 |
newScript.setAttribute(attr, el.getAttribute(attr)); |
| 156 |
} |
| 157 |
}); |
| 158 |
|
| 159 |
el.parentNode.replaceChild(newScript, el); |
| 160 |
}); |
| 161 |
}); |
| 162 |
} |
| 163 |
|
| 164 |
function cookieadmin_set_cookie(name, value, days = 365, domain = "") { |
| 165 |
if (!name || !value) return false; |
| 166 |
|
| 167 |
const date = new Date(); |
| 168 |
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); // default 1 year |
| 169 |
|
| 170 |
let cookieString = `${encodeURIComponent(name)}=${JSON.stringify(value)};`; |
| 171 |
cookieString += ` expires=${date.toUTCString()};`; |
| 172 |
cookieString += ` path=${cookieadmin_policy.base_path};`; |
| 173 |
cookieString += ` SameSite=Lax;`; |
| 174 |
if(cookieadmin_policy.is_ssl || window.location.protocol === 'https:'){ |
| 175 |
cookieString += ` Secure;`; |
| 176 |
} |
| 177 |
|
| 178 |
// Add domain if explicitly passed |
| 179 |
if (domain) { |
| 180 |
cookieString += ` domain=${domain};`; |
| 181 |
} |
| 182 |
|
| 183 |
document.cookie = cookieString; |
| 184 |
return true; |
| 185 |
} |
| 186 |
|
| 187 |
//Populates modal with consent if selected |
| 188 |
function cookieadmin_populate_preference(){ |
| 189 |
|
| 190 |
consent = cookieadmin_is_consent.action; |
| 191 |
|
| 192 |
if(!!consent){ |
| 193 |
|
| 194 |
if(consent.accept){ |
| 195 |
document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){ |
| 196 |
e.children[0].checked = true; |
| 197 |
}); |
| 198 |
} |
| 199 |
else if(consent.reject){ |
| 200 |
document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){ |
| 201 |
e.children[0].checked = false; |
| 202 |
}); |
| 203 |
} |
| 204 |
else{ |
| 205 |
for(btn in consent){ |
| 206 |
if(btn_ele = document.querySelector("#cookieadmin-" + btn)){ |
| 207 |
btn_ele.checked = true; |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
cookieadmin_shown = (typeof cookieadmin_shown !== "undefined") ? cookieadmin_shown : []; |
| 214 |
|
| 215 |
if(cookieadmin_allcookies){ |
| 216 |
|
| 217 |
cookieadmin_filtrd = Object.keys(cookieadmin_allcookies).filter(e => !cookieadmin_shown.includes(e)); |
| 218 |
|
| 219 |
for(c_info of cookieadmin_filtrd){ |
| 220 |
|
| 221 |
if(e = document.querySelector(".cookieadmin-" + cookieadmin_allcookies[c_info].category?.toLowerCase())){ |
| 222 |
e.innerHTML = (e.innerHTML == 'None') ? '' : e.innerHTML; |
| 223 |
|
| 224 |
exp = cookieadmin_policy.lang.session; |
| 225 |
|
| 226 |
if(!!cookieadmin_allcookies[c_info].expires){ |
| 227 |
exp = Math.round((cookieadmin_allcookies[c_info].expires - Date.now())/86400); |
| 228 |
if(exp < 1 && !!res['Max-Age']){ |
| 229 |
exp = res['Max-Age']; |
| 230 |
}else{ |
| 231 |
exp = cookieadmin_policy.lang.session; |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
e.innerHTML += '<div class="cookieadmin-cookie-card"> <div class="cookieadmin-cookie-header"> <strong class="cookieadmin-cookie-name">'+ c_info.replace(/_+$/, "") +'</strong> <span class="cookieadmin-cookie-duration"><b>'+ cookieadmin_policy.lang.duration +':</b> '+ exp +'</span> </div> <p class="cookieadmin-cookie-description">'+ cookieadmin_allcookies[c_info].description +'</p> <div class="cookieadmin-cookie-tags"> ' + (cookieadmin_allcookies[c_info].platform ? '<span class="cookieadmin-tag">' + cookieadmin_allcookies[c_info].platform + '</span>' : "") + ' </div> </div>'; |
| 236 |
} |
| 237 |
cookieadmin_shown.push(c_info); |
| 238 |
} |
| 239 |
} |
| 240 |
|
| 241 |
} |
| 242 |
|
| 243 |
function cookieadmin_toggle_overlay(){ |
| 244 |
|
| 245 |
if(window.getComputedStyle(document.getElementsByClassName("cookieadmin_modal_overlay")[0]).display == "none"){ |
| 246 |
document.getElementsByClassName("cookieadmin_modal_overlay")[0].style.display = "block"; |
| 247 |
}else{ |
| 248 |
document.getElementsByClassName("cookieadmin_modal_overlay")[0].style.display = "none"; |
| 249 |
} |
| 250 |
|
| 251 |
} |
| 252 |
|
| 253 |
function cookieadmin_categorize_cookies(){ |
| 254 |
|
| 255 |
if(!cookieadmin_allcookies){ |
| 256 |
return; |
| 257 |
} |
| 258 |
|
| 259 |
var cookieadmin_chk_cookies = {}; |
| 260 |
var cookieadmin_consent_chng = []; |
| 261 |
|
| 262 |
for(a_cookie in cookieadmin_allcookies){ |
| 263 |
if(!cookieadmin_allcookies[a_cookie].category){ |
| 264 |
cookieadmin_chk_cookies[a_cookie] = cookieadmin_allcookies[a_cookie]; |
| 265 |
}else if(cookieadmin_is_consent.old_action !== cookieadmin_is_consent.action && a_cookie !== "cookieadmin_consent"){ |
| 266 |
document.cookie = cookieadmin_allcookies[a_cookie].string; |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
if(!cookieadmin_is_obj(cookieadmin_chk_cookies)){ |
| 271 |
return; |
| 272 |
} |
| 273 |
|
| 274 |
/* const xhttp2 = new XMLHttpRequest(); |
| 275 |
|
| 276 |
var data = 'action=cookieadmin_ajax_handler&cookieadmin_act=categorize_cookies&cookieadmin_security=' + cookieadmin_policy.nonce + "&cookieadmin_cookies=" + JSON.stringify(cookieadmin_chk_cookies); |
| 277 |
|
| 278 |
xhttp2.onload = function() { |
| 279 |
parsd = JSON.parse(this.responseText); |
| 280 |
|
| 281 |
if(parsd.success){ |
| 282 |
cookies = parsd.data; |
| 283 |
for(coki in cookies){ |
| 284 |
cookieadmin_chk_cookies[coki].name = coki; |
| 285 |
if(cookies[coki].category === "un_c"){ |
| 286 |
cookieadmin_chk_cookies[coki].source = "unknown"; |
| 287 |
cookieadmin_chk_cookies[coki].description = "unknown"; |
| 288 |
} |
| 289 |
cookieadmin_allcookies[coki] = cookieadmin_chk_cookies[coki]; |
| 290 |
document.cookie = cookieadmin_chk_cookies[coki].string; |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
xhttp2.open("POST", cookieadmin_policy.ajax_url, true); |
| 296 |
xhttp2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
| 297 |
xhttp2.send(data); */ |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
document.addEventListener("DOMContentLoaded", function() { |
| 302 |
|
| 303 |
var cookieadmin_show_reconsent = 0; |
| 304 |
if(cookieadmin_policy.is_pro != 0 && cookieadmin_pro_vars.reconsent != 0){ |
| 305 |
var cookieadmin_show_reconsent = 1; |
| 306 |
} |
| 307 |
|
| 308 |
//Create overlay |
| 309 |
var cookieadmin_ovrlay = document.createElement("div"); |
| 310 |
cookieadmin_ovrlay.className = "cookieadmin_modal_overlay"; |
| 311 |
document.body.appendChild(cookieadmin_ovrlay); |
| 312 |
|
| 313 |
//Show notice or re-consent icon as needed |
| 314 |
if(!cookieadmin_is_obj(cookieadmin_is_consent)){ |
| 315 |
|
| 316 |
if(cookieadmin_policy.cookieadmin_layout !== "popup"){ |
| 317 |
document.getElementsByClassName("cookieadmin_law_container")[0].style.display = "block"; |
| 318 |
}else{ |
| 319 |
cookieadmin_toggle_overlay(); |
| 320 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "flex"; |
| 321 |
} |
| 322 |
|
| 323 |
/* //block cookie scripts |
| 324 |
var cookieadmin_blockedScripts = [ |
| 325 |
'https://www.google-analytics.com/analytics.js', |
| 326 |
'https://connect.facebook.net/en_US/fbevents.js', |
| 327 |
'https://www.youtube.com/iframe_api' |
| 328 |
]; |
| 329 |
|
| 330 |
cookieadmin_blockedScripts.forEach(function(scriptUrl) { |
| 331 |
var scriptTag = document.querySelector(`script[src='${scriptUrl}']`); |
| 332 |
if (scriptTag) { |
| 333 |
scriptTag.remove(); // Remove script if already loaded |
| 334 |
} |
| 335 |
}); */ |
| 336 |
|
| 337 |
}else if(cookieadmin_show_reconsent){ |
| 338 |
document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "block"; |
| 339 |
|
| 340 |
} |
| 341 |
|
| 342 |
//Edit Notice and Modal contents |
| 343 |
document.getElementsByClassName("cookieadmin_reconsent_img")[0].src = cookieadmin_policy.plugin_url + "/assets/images/cookieadmin_icon.svg"; |
| 344 |
|
| 345 |
cookieadmin_populate_preference(); |
| 346 |
|
| 347 |
for(data in cookieadmin_policy){ |
| 348 |
|
| 349 |
typ = 0; |
| 350 |
if(data.includes("_bg_color")){ |
| 351 |
d_ele = data.replace("_bg_color", ""); |
| 352 |
typ = 1; |
| 353 |
}else if(data.includes("_border_color")){ |
| 354 |
d_ele = data.replace("_border_color", ""); |
| 355 |
typ = 2; |
| 356 |
}else if(data.includes("_color")){ |
| 357 |
d_ele = data.replace("_color", ""); |
| 358 |
typ = 3; |
| 359 |
}else{ |
| 360 |
d_ele = data; |
| 361 |
} |
| 362 |
|
| 363 |
d_eles = []; |
| 364 |
if(document.getElementById(d_ele)){ |
| 365 |
d_eles = [document.getElementById(d_ele)]; |
| 366 |
} |
| 367 |
if(document.getElementsByClassName(d_ele).length){ |
| 368 |
d_eles = (document.getElementsByClassName(d_ele).length > 1) ? document.getElementsByClassName(d_ele) : [document.getElementsByClassName(d_ele)[0]]; |
| 369 |
} |
| 370 |
|
| 371 |
if(!!d_eles){ |
| 372 |
i = 0; |
| 373 |
while(i < d_eles.length){ |
| 374 |
d_ele = d_eles[i]; |
| 375 |
if(typ == 3){ |
| 376 |
d_ele.style.color = cookieadmin_policy[data]; |
| 377 |
}else if(typ == 2){ |
| 378 |
d_ele.style.borderColor = cookieadmin_policy[data]; |
| 379 |
}else if(typ == 1){ |
| 380 |
d_ele.style.backgroundColor = cookieadmin_policy[data]; |
| 381 |
}else{ |
| 382 |
d_ele.innerHTML = cookieadmin_policy[data]; |
| 383 |
} |
| 384 |
i++; |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
//Add layout as class |
| 390 |
if(!!cookieadmin_policy.cookieadmin_position){ |
| 391 |
cookieadmin_policy.cookieadmin_position.split("_").forEach(function(clas){ |
| 392 |
clas = "cookieadmin_" + clas; |
| 393 |
document.getElementsByClassName("cookieadmin_law_container")[0].classList.add(clas); |
| 394 |
}); |
| 395 |
} |
| 396 |
|
| 397 |
// Change consent layout dynamically |
| 398 |
document.getElementsByClassName("cookieadmin_law_container")[0].classList.add("cookieadmin_" + cookieadmin_policy.cookieadmin_layout); |
| 399 |
|
| 400 |
// Change Modal layout dynamically |
| 401 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].classList.add("cookieadmin_" + cookieadmin_policy.cookieadmin_modal); |
| 402 |
|
| 403 |
/*if(cookieadmin_policy.layout == "footer"){ |
| 404 |
|
| 405 |
}*/ |
| 406 |
|
| 407 |
if(cookieadmin_policy.cookieadmin_modal == "side"){ |
| 408 |
document.getElementsByClassName("cookieadmin_modal_footer")[0].style.flexDirection = "column"; |
| 409 |
} |
| 410 |
|
| 411 |
// Remove modal close Button |
| 412 |
if(cookieadmin_policy.cookieadmin_layout == "popup"){ |
| 413 |
document.getElementsByClassName("cookieadmin_close_pref")[0].style.display = "none"; |
| 414 |
} |
| 415 |
|
| 416 |
//show preference modal |
| 417 |
cookieadmin_show_modal_elemnts = document.querySelectorAll(".cookieadmin_re_consent, .cookieadmin_customize_btn"); |
| 418 |
cookieadmin_show_modal_elemnts.forEach(function(e){ |
| 419 |
|
| 420 |
e.addEventListener("click", function(e){ |
| 421 |
|
| 422 |
/*cookieadmin_is_cookie("all").forEach(function(e){ |
| 423 |
c_name = e.split("=")[0].trim(); |
| 424 |
if(!!cookieadmin_allcookies[c_name]){ |
| 425 |
console.log(JSON.stringify(cookieadmin_allcookies[c_name])); |
| 426 |
} |
| 427 |
});*/ |
| 428 |
|
| 429 |
cookieadmin_toggle_overlay(); |
| 430 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "flex"; |
| 431 |
document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "none"; |
| 432 |
document.getElementsByClassName("cookieadmin_law_container")[0].style.display = "none"; |
| 433 |
|
| 434 |
if(cookieadmin_policy["cookieadmin_modal"] == "side"){ |
| 435 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "grid"; |
| 436 |
} |
| 437 |
|
| 438 |
if(e.target.className == "cookieadmin_re_consent"){ |
| 439 |
document.getElementsByClassName("cookieadmin_close_pref")[0].id = "cookieadmin_re_consent"; |
| 440 |
}else{ |
| 441 |
document.getElementsByClassName("cookieadmin_close_pref")[0].id = "cookieadmin_law_container"; |
| 442 |
} |
| 443 |
}); |
| 444 |
}); |
| 445 |
|
| 446 |
//Save preference |
| 447 |
document.querySelector(".cookieadmin_save_btn").addEventListener("click", function(){ |
| 448 |
|
| 449 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none"; |
| 450 |
if(cookieadmin_show_reconsent){ |
| 451 |
document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "block"; |
| 452 |
} |
| 453 |
|
| 454 |
var prefer = {}; |
| 455 |
|
| 456 |
document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){ |
| 457 |
if(!!e.children[0].checked){ |
| 458 |
prefer[e.children[0].id.replace("cookieadmin-","")] = 'true'; |
| 459 |
} |
| 460 |
}); |
| 461 |
|
| 462 |
if(Object.keys(prefer).length !== 0){ |
| 463 |
if(Object.keys(prefer).length === 3){ |
| 464 |
document.querySelectorAll(".cookieadmin_accept_btn")[1].click(); |
| 465 |
return; |
| 466 |
} |
| 467 |
}else{ |
| 468 |
document.querySelectorAll(".cookieadmin_reject_btn")[1].click(); |
| 469 |
return; |
| 470 |
} |
| 471 |
|
| 472 |
cookieadmin_toggle_overlay(); |
| 473 |
|
| 474 |
cookieadmin_set_consent(prefer, days); |
| 475 |
|
| 476 |
if(!!cookieadmin_policy.reload_on_consent){ |
| 477 |
location.reload(); |
| 478 |
}else{ |
| 479 |
cookieadmin_restore_cookies(prefer); |
| 480 |
} |
| 481 |
}); |
| 482 |
|
| 483 |
|
| 484 |
//Accept or reject all cookies |
| 485 |
cookieadmin_save_all_cookie_elemnts = document.querySelectorAll(".cookieadmin_accept_btn, .cookieadmin_reject_btn"); |
| 486 |
|
| 487 |
cookieadmin_save_all_cookie_elemnts.forEach(function(e){ |
| 488 |
|
| 489 |
e.addEventListener("click", function(){ |
| 490 |
// console.log(e); |
| 491 |
|
| 492 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none"; |
| 493 |
document.getElementsByClassName("cookieadmin_law_container")[0].style.display = "none"; |
| 494 |
if(cookieadmin_show_reconsent){ |
| 495 |
document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "block"; |
| 496 |
} |
| 497 |
|
| 498 |
if(e.id.includes("modal")){ |
| 499 |
cookieadmin_toggle_overlay(); |
| 500 |
} |
| 501 |
|
| 502 |
var prefer2 = e.classList.contains("cookieadmin_reject_btn") ? {reject: "true"} : {accept: "true"}; |
| 503 |
|
| 504 |
cookieadmin_set_consent(prefer2, days); |
| 505 |
|
| 506 |
if(!!cookieadmin_policy.reload_on_consent){ |
| 507 |
location.reload(); |
| 508 |
}else{ |
| 509 |
cookieadmin_restore_cookies(prefer2); |
| 510 |
} |
| 511 |
}); |
| 512 |
}); |
| 513 |
|
| 514 |
//showmore modal btn |
| 515 |
document.getElementsByClassName("cookieadmin_showmore")[0]?.addEventListener("click", function(){ |
| 516 |
|
| 517 |
var cur_height = document.getElementsByClassName("cookieadmin_preference")[0].style.height; |
| 518 |
|
| 519 |
if(!cur_height){ |
| 520 |
document.getElementsByClassName("cookieadmin_preference")[0].style.height = "auto"; |
| 521 |
this.innerHTML = cookieadmin_policy.lang.show_less; |
| 522 |
}else{ |
| 523 |
document.getElementsByClassName("cookieadmin_preference")[0].style.height = ""; |
| 524 |
this.innerHTML = cookieadmin_policy.lang.show_more; |
| 525 |
} |
| 526 |
}); |
| 527 |
|
| 528 |
|
| 529 |
document.querySelectorAll(".cookieadmin_show_pref_cookies").forEach(function(e){ |
| 530 |
e.addEventListener("click", function(el){ |
| 531 |
|
| 532 |
var tgt = el.target.id; |
| 533 |
tgt = tgt.replace(/-container$/, ""); |
| 534 |
|
| 535 |
if(el.target.classList.contains("dwn")){ |
| 536 |
el.target.innerHTML = "►"; |
| 537 |
el.target.classList.remove("dwn"); |
| 538 |
document.querySelector("."+tgt).style.display = "none"; |
| 539 |
}else{ |
| 540 |
el.target.innerHTML = "▼"; |
| 541 |
el.target.classList.add("dwn"); |
| 542 |
document.querySelector("."+tgt).style.display = "block"; |
| 543 |
} |
| 544 |
}); |
| 545 |
}); |
| 546 |
|
| 547 |
document.getElementsByClassName("cookieadmin_close_pref")[0].addEventListener("click", function(e){ |
| 548 |
document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none"; |
| 549 |
cookieadmin_toggle_overlay(); |
| 550 |
if(!cookieadmin_is_obj(cookieadmin_is_consent)){ |
| 551 |
document.getElementsByClassName("cookieadmin_law_container")[0].style.display = "block"; |
| 552 |
}else if(cookieadmin_show_reconsent){ |
| 553 |
document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "block"; |
| 554 |
} |
| 555 |
}); |
| 556 |
|
| 557 |
}); |
| 558 |
|
| 559 |
function cookieadmin_set_consent(prefrenc, days){ |
| 560 |
|
| 561 |
var cookieadmin_consent = prefrenc; |
| 562 |
|
| 563 |
if (typeof cookieadmin_pro_set_consent === "function") { |
| 564 |
consent_id = cookieadmin_pro_set_consent(prefrenc, days); |
| 565 |
|
| 566 |
if(consent_id){ |
| 567 |
cookieadmin_is_consent.consent = consent_id; |
| 568 |
cookieadmin_consent['consent'] = consent_id; |
| 569 |
} |
| 570 |
} |
| 571 |
|
| 572 |
if(!cookieadmin_is_consent.consent){ |
| 573 |
cookieadmin_is_consent.consent = ""; |
| 574 |
} |
| 575 |
|
| 576 |
cookieadmin_is_consent["old_action"] = cookieadmin_is_consent.action ? cookieadmin_is_consent.action : {}; |
| 577 |
cookieadmin_is_consent.action = prefrenc; |
| 578 |
cookieadmin_populate_preference(); |
| 579 |
cookieadmin_set_cookie('cookieadmin_consent', cookieadmin_consent, days); |
| 580 |
|
| 581 |
if (typeof cookieadmin_update_gcm === "function") { |
| 582 |
cookieadmin_update_gcm(1); |
| 583 |
} |
| 584 |
|
| 585 |
} |
| 586 |
|
| 587 |
|