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