PluginProbe
CookieAdmin – Cookie Consent Banner / 1.1.9
CookieAdmin – Cookie Consent Banner v1.1.9
1.2.3 1.2.2 1.2.1 1.2.0 1.1.9 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
cookieadmin / assets / js / consent.js

consent.js in CookieAdmin – Cookie Consent Banner 1.1.9, at assets/js/consent.js

686 lines 20.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // This file handle the cookie banner and stuff related to that.
2
3 var days = cookieadmin_policy.cookieadmin_days;
4
5 if(typeof cookieadmin_is_consent === 'undefined'){
6 window.cookieadmin_is_consent = {};
7 }
8 var cookieadmin_allcookies = cookieadmin_policy.categorized_cookies;
9 //setInterval(cookieadmin_categorize_cookies, 5000);
10
11 function cookieadmin_is_obj(consentObj){
12 try{
13 return (
14 consentObj !== null &&
15 typeof consentObj === 'object' &&
16 !Array.isArray(consentObj) &&
17 Object.keys(consentObj).length > 0
18 );
19 }catch(e){
20 return false;
21 }
22 }
23
24
25 // function cookieadmin_cookie_interceptor(){
26
27 var originalCookieDescriptor =
28 Object.getOwnPropertyDescriptor(Document.prototype, 'cookie') ||
29 Object.getOwnPropertyDescriptor(document, 'cookie');
30 var allowed_cookies = '';
31
32 // Override document.cookie to intercept cookie setting.
33 Object.defineProperty(document, 'cookie', {
34 configurable: true,
35 enumerable: true,
36 get: function(){
37 return originalCookieDescriptor.get.call(document);
38 },
39 set: function(val){
40
41 if (!val) return;
42
43 var separatorIndex = val.indexOf('=');
44 if(separatorIndex === -1) {
45 return;
46 }
47
48 var cookieName = val.substring(0, separatorIndex).trim();
49 var cookieValue = val.substring(separatorIndex + 1).trim();
50
51 if(cookieName === "cookieadmin_consent"){
52 originalCookieDescriptor.set.call(document, val);
53 return;
54 }
55
56 // Set cookies which are meant to be deleted
57 if(val.includes('expires=Thu, 01 Jan 1970') || cookieValue.startsWith("deleted;")){
58 originalCookieDescriptor.set.call(document, val);
59 return;
60 }
61
62 var cookieInfo = cookieadmin_allcookies[cookieName] || {};
63 var category = (cookieInfo.category || 'uncategorized').toLowerCase();
64
65 // Set necessary cookies
66 if(category == "necessary"){
67 originalCookieDescriptor.set.call(document, val);
68 return;
69 }
70
71 if(cookieadmin_is_obj(cookieadmin_is_consent) || (Array.isArray(cookieadmin_policy['preload']) && cookieadmin_policy['preload'].length > 0)){
72
73 var consentAction = cookieadmin_is_consent.action;
74
75 if(!consentAction){
76 consentAction = cookieadmin_policy['preload'].reduce((a, val) => {a[val] = ''; return a;}, {});
77 }
78
79 if(consentAction.accept || consentAction[category]){
80 originalCookieDescriptor.set.call(document, val);
81 }else{
82
83 var pathMatch = val.match(/path=([^;]+)/i);
84 var domainMatch = val.match(/domain=([^;]+)/i);
85 var path = pathMatch ? pathMatch[1].trim() : '/';
86 var domain = domainMatch ? `domain=${domainMatch[1].trim()};` : '';
87
88 var deleteString = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}; ${domain}`;
89 originalCookieDescriptor.set.call(document, deleteString.trim());
90 }
91
92 }else{
93 (cookieadmin_allcookies[cookieName] = cookieadmin_allcookies[cookieName] || {}).string = val.trim();
94 return false;
95 }
96
97 }
98 });
99 // }
100 // cookieadmin_cookie_interceptor();
101
102
103 function cookieadmin_is_cookie(name){
104
105 if(!document.cookie) return false;
106
107 var coki = document.cookie.split(";") ;
108
109 if(name == "all"){
110 return coki ? coki : [];
111 }
112 var nam = name + "=";
113
114 for(var i=0; i < coki.length; i++){
115 if(coki[i].trim().indexOf(nam) == 0){
116 try {
117 var cookie_value = coki[i].trim().split("=");
118 if(!cookie_value[1]){
119 return false;
120 }
121
122 var decoded = decodeURIComponent(cookie_value[1]);
123 return JSON.parse(decoded);
124 } catch {
125 return false;
126 }
127 }
128 }
129
130 return false;
131 }
132
133 function cookieadmin_check_consent(){
134 var cookieadmin_cookie = cookieadmin_is_cookie("cookieadmin_consent");
135 if(!!cookieadmin_cookie){
136 if(!!cookieadmin_cookie.consent){
137 cookieadmin_is_consent.consent = cookieadmin_cookie.consent;
138 delete cookieadmin_cookie.consent;
139 }
140
141 cookieadmin_is_consent.action = cookieadmin_cookie;
142 }
143 }
144 cookieadmin_check_consent();
145
146 function cookieadmin_restore_cookies(update) {
147
148 var cookieadmin_accepted_categories = [];
149
150 if(update.accept && update.accept == "true"){
151
152 document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){
153 key = e.children[0].id;
154 if (key.includes("cookieadmin-")) {
155 key = key.replace("cookieadmin-", "");
156 cookieadmin_accepted_categories.push(key);
157 }
158 });
159
160 }else if(update.reject && update.reject == "true"){
161 return true;
162 }else{
163 for (var [key, value] of Object.entries(update)) {
164 if(key != "consent"){
165 cookieadmin_accepted_categories.push(key);
166 }
167 }
168 }
169
170
171 for(cookie in cookieadmin_allcookies){
172 document.cookie = cookieadmin_allcookies[cookie].string;
173 };
174
175 cookieadmin_accepted_categories.forEach(function(category) {
176
177 document.querySelectorAll(
178 'script[type="text/plain"][data-cookieadmin-category="' + category + '"]'
179 ).forEach(function(el) {
180 var newScript = document.createElement('script');
181
182 // Copy attributes
183 if (el.src) {
184 newScript.src = el.src;
185 } else {
186 newScript.text = el.textContent;
187 }
188
189 if (el.defer) newScript.defer = true;
190 if (el.async) newScript.async = true;
191
192 // Copy other attributes if needed
193 ['id', 'class', 'data-name'].forEach(attr => {
194 if (el.hasAttribute(attr)) {
195 newScript.setAttribute(attr, el.getAttribute(attr));
196 }
197 });
198
199 el.parentNode.replaceChild(newScript, el);
200 });
201 });
202 }
203
204 function cookieadmin_set_cookie(name, value, days = 365, domain = "") {
205 if (!name || !value) return false;
206
207 if((cookieadmin_policy.is_pro != 0) && (cookieadmin_pro_vars !== 'undefined')){
208 if(cookieadmin_pro_vars.shared_subdomain_consent && cookieadmin_pro_vars.base_domain){
209 domain = cookieadmin_pro_vars.base_domain;
210 }
211 }
212
213 var date = new Date();
214 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); // default 1 year
215
216 var cookieString = `${encodeURIComponent(name)}=${JSON.stringify(value)};`;
217 cookieString += ` expires=${date.toUTCString()};`;
218 cookieString += ` path=${!domain ? cookieadmin_policy.base_path : '/'};`;
219 cookieString += ` SameSite=Lax;`;
220 if(cookieadmin_policy.is_ssl || window.location.protocol === 'https:'){
221 cookieString += ` Secure;`;
222 }
223
224 // Add domain if explicitly passed
225 if (domain) {
226 cookieString += ` domain=${domain};`;
227 }
228
229 document.cookie = cookieString;
230 return true;
231 }
232
233 //Populates modal with consent if selected & adds found cookies
234 function cookieadmin_populate_preference(){
235
236 consent = cookieadmin_is_consent.action;
237
238 if(!!consent){
239
240 if(consent.accept){
241 document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){
242 e.children[0].checked = true;
243 });
244 }
245 else if(consent.reject){
246 document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){
247 e.children[0].checked = false;
248 });
249 }
250 else{
251 for(btn in consent){
252 if(btn_ele = document.querySelector("#cookieadmin-" + btn)){
253 btn_ele.checked = true;
254 }
255 }
256 }
257 //Load as per preloaded categories selected by admin
258 }else if(cookieadmin_policy['preload'] && cookieadmin_policy['preload'].length > 0){
259
260 cookieadmin_policy['preload'].forEach(function(val){
261 if(btn_ele = document.querySelector("#cookieadmin-" + val)){
262 btn_ele.checked = true;
263 }
264 });
265 }
266
267 var cookieadmin_shown = (typeof cookieadmin_shown !== "undefined") ? cookieadmin_shown : [];
268
269 if(cookieadmin_allcookies){
270
271 var cookieadmin_filtrd = Object.keys(cookieadmin_allcookies).filter(e => !cookieadmin_shown.includes(e));
272
273 for(c_info of cookieadmin_filtrd){
274
275 var category_var = cookieadmin_allcookies[c_info].category;
276
277 if(!category_var){
278 continue;
279 }
280 var card_container = document.querySelector(".cookieadmin-" + category_var.toLowerCase());
281
282 if(!card_container){
283 continue;
284 }
285 card_container.innerHTML = (card_container.innerHTML == 'None') ? '' : card_container.innerHTML;
286
287 var cookieadmin_exp = cookieadmin_policy.lang.session;
288
289 if(
290 !!cookieadmin_allcookies[c_info].expires
291 && cookieadmin_allcookies[c_info].expires !== "0000-00-00 00:00:00"
292 ){
293
294 var expDate = new Date(cookieadmin_allcookies[c_info].expires.replace(' ', 'T'));
295
296 if (!isNaN(expDate.getTime())) {
297 var daysLeft = Math.ceil((expDate.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
298
299 if (daysLeft > 0) {
300 cookieadmin_exp = daysLeft +' '+ cookieadmin_policy.lang.days;
301 }
302 }
303 }
304
305 card_container.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> '+ cookieadmin_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>';
306 cookieadmin_shown.push(c_info);
307 }
308 }
309
310 }
311
312 function cookieadmin_toggle_overlay(){
313
314 if(window.getComputedStyle(document.getElementsByClassName("cookieadmin_modal_overlay")[0]).display == "none"){
315 document.getElementsByClassName("cookieadmin_modal_overlay")[0].style.display = "block";
316 }else{
317 document.getElementsByClassName("cookieadmin_modal_overlay")[0].style.display = "none";
318 }
319
320 }
321
322 function cookieadmin_categorize_cookies(){
323
324 if(!cookieadmin_allcookies){
325 return;
326 }
327
328 var cookieadmin_chk_cookies = {};
329 var cookieadmin_consent_chng = [];
330
331 for(a_cookie in cookieadmin_allcookies){
332 if(!cookieadmin_allcookies[a_cookie].category){
333 cookieadmin_chk_cookies[a_cookie] = cookieadmin_allcookies[a_cookie];
334 }else if(cookieadmin_is_consent.old_action !== cookieadmin_is_consent.action && a_cookie !== "cookieadmin_consent"){
335 document.cookie = cookieadmin_allcookies[a_cookie].string;
336 }
337 }
338
339 if(!cookieadmin_is_obj(cookieadmin_chk_cookies)){
340 return;
341 }
342
343 /* var xhttp2 = new XMLHttpRequest();
344
345 var data = 'action=cookieadmin_ajax_handler&cookieadmin_act=categorize_cookies&cookieadmin_security=' + cookieadmin_policy.nonce + "&cookieadmin_cookies=" + JSON.stringify(cookieadmin_chk_cookies);
346
347 xhttp2.onload = function() {
348 parsd = JSON.parse(this.responseText);
349
350 if(parsd.success){
351 cookies = parsd.data;
352 for(coki in cookies){
353 cookieadmin_chk_cookies[coki].name = coki;
354 if(cookies[coki].category === "un_c"){
355 cookieadmin_chk_cookies[coki].source = "unknown";
356 cookieadmin_chk_cookies[coki].description = "unknown";
357 }
358 cookieadmin_allcookies[coki] = cookieadmin_chk_cookies[coki];
359 document.cookie = cookieadmin_chk_cookies[coki].string;
360 }
361 }
362 }
363
364 xhttp2.open("POST", cookieadmin_policy.ajax_url, true);
365 xhttp2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
366 xhttp2.send(data); */
367 }
368
369
370 document.addEventListener("DOMContentLoaded", function() {
371
372 var cookieadmin_show_reconsent = 0;
373 if(cookieadmin_policy.is_pro != 0 && cookieadmin_pro_vars !== 'undefined' && cookieadmin_pro_vars.reconsent != 0){
374 var cookieadmin_show_reconsent = 1;
375 }
376
377 //Create overlay
378 var cookieadmin_ovrlay = document.createElement("div");
379 cookieadmin_ovrlay.className = "cookieadmin_modal_overlay";
380 document.body.appendChild(cookieadmin_ovrlay);
381
382 var before_consent_dispaly = new CustomEvent('cookieadmin_before_consent_display');
383
384 // For anything that needs to be done before disaplying consent.
385 cookieadmin_policy.hide_banner = false; // initializing
386 window.dispatchEvent(before_consent_dispaly);
387
388 //Show notice or re-consent icon as needed
389 if(!cookieadmin_is_obj(cookieadmin_is_consent) && !cookieadmin_policy.hide_banner){
390
391 if(cookieadmin_policy.cookieadmin_layout !== "popup"){
392 document.getElementsByClassName("cookieadmin_law_container")[0].style.display = "block";
393 }else{
394 cookieadmin_toggle_overlay();
395 document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "flex";
396 }
397
398 /* //block cookie scripts
399 var cookieadmin_blockedScripts = [
400 'https://www.google-analytics.com/analytics.js',
401 'https://connect.facebook.net/en_US/fbevents.js',
402 'https://www.youtube.com/iframe_api'
403 ];
404
405 cookieadmin_blockedScripts.forEach(function(scriptUrl) {
406 var scriptTag = document.querySelector(`script[src='${scriptUrl}']`);
407 if (scriptTag) {
408 scriptTag.remove(); // Remove script if already loaded
409 }
410 }); */
411
412 }else if(cookieadmin_show_reconsent){
413 document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "block";
414
415 }
416
417 //Edit Notice and Modal contents
418
419 cookieadmin_populate_preference();
420
421 for(data in cookieadmin_policy){
422
423 typ = 0;
424 if(data.includes("_bg_color")){
425 d_ele = data.replace("_bg_color", "");
426 typ = 1;
427 }else if(data.includes("_border_color")){
428 d_ele = data.replace("_border_color", "");
429 typ = 2;
430 }else if(data.includes("_color")){
431 d_ele = data.replace("_color", "");
432 typ = 3;
433 }else{
434 d_ele = data;
435 }
436
437 d_eles = [];
438 if(document.getElementById(d_ele)){
439 d_eles = [document.getElementById(d_ele)];
440 }
441 if(document.getElementsByClassName(d_ele).length){
442 d_eles = (document.getElementsByClassName(d_ele).length > 1) ? document.getElementsByClassName(d_ele) : [document.getElementsByClassName(d_ele)[0]];
443 }
444
445 if(!!d_eles){
446 i = 0;
447 while(i < d_eles.length){
448 d_ele = d_eles[i];
449 if(typ == 3){
450 d_ele.style.color = cookieadmin_policy[data];
451 }else if(typ == 2){
452 d_ele.style.borderColor = cookieadmin_policy[data];
453 }else if(typ == 1){
454 d_ele.style.backgroundColor = cookieadmin_policy[data];
455 }else{
456 d_ele.innerHTML = cookieadmin_policy[data];
457 }
458 i++;
459 }
460 }
461 }
462
463 //Add layout as class
464 if(!!cookieadmin_policy.cookieadmin_position && cookieadmin_policy.cookieadmin_layout !== "popup"){
465 cookieadmin_policy.cookieadmin_position.split("_").forEach(function(clas){
466 clas = "cookieadmin_" + clas;
467 document.getElementsByClassName("cookieadmin_law_container")[0].classList.add(clas);
468 });
469 }
470
471 // Change consent layout dynamically
472 // TODO: There is a operator called optional chaining operator ?. something like this users?.[0]?.name; wont use it now just for reference
473 var cookieadmin_law_container_var = document.getElementsByClassName("cookieadmin_law_container")[0];
474 if (!!cookieadmin_law_container_var){
475 cookieadmin_law_container_var.classList.add("cookieadmin_" + cookieadmin_policy.cookieadmin_layout);
476 }
477
478 // Change Modal layout dynamically
479 document.getElementsByClassName("cookieadmin_cookie_modal")[0].classList.add("cookieadmin_" + cookieadmin_policy.cookieadmin_modal);
480
481 /*if(cookieadmin_policy.layout == "footer"){
482
483 }*/
484
485 if(cookieadmin_policy.cookieadmin_modal == "side"){
486 document.getElementsByClassName("cookieadmin_modal_footer")[0].style.flexDirection = "column";
487 }
488
489 // Remove modal close Button
490 if(cookieadmin_policy.cookieadmin_layout == "popup"){
491 document.getElementsByClassName("cookieadmin_close_pref")[0].style.display = "none";
492 }
493
494 //show preference modal
495 cookieadmin_show_modal_elemnts = document.querySelectorAll(".cookieadmin_re_consent, .cookieadmin_customize_btn");
496 cookieadmin_show_modal_elemnts.forEach(function(e){
497
498 e.addEventListener("click", function(e){
499
500 /*cookieadmin_is_cookie("all").forEach(function(e){
501 c_name = e.split("=")[0].trim();
502 if(!!cookieadmin_allcookies[c_name]){
503 console.log(JSON.stringify(cookieadmin_allcookies[c_name]));
504 }
505 });*/
506
507 cookieadmin_toggle_overlay();
508 document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "flex";
509 var cookieadmin_re_consent = document.getElementsByClassName("cookieadmin_re_consent")[0];
510 if(cookieadmin_re_consent){
511 cookieadmin_re_consent.style.display = "none";
512 }
513
514 var cookieadmin_law_container = document.getElementsByClassName("cookieadmin_law_container")[0];
515 if(cookieadmin_law_container){
516 cookieadmin_law_container.style.display = "none";
517 }
518
519 if(cookieadmin_policy["cookieadmin_modal"] == "side"){
520 document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "grid";
521 }
522
523 if(e.target.className == "cookieadmin_re_consent"){
524 document.getElementsByClassName("cookieadmin_close_pref")[0].id = "cookieadmin_re_consent";
525 }else{
526 document.getElementsByClassName("cookieadmin_close_pref")[0].id = "cookieadmin_law_container";
527 }
528 });
529 });
530
531 //Save preference
532 document.querySelector(".cookieadmin_save_btn").addEventListener("click", function(){
533
534 document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none";
535 if(cookieadmin_show_reconsent){
536 document.getElementsByClassName("cookieadmin_re_consent")[0].style.display = "block";
537 }
538
539 var prefer = {};
540
541 document.querySelectorAll(".cookieadmin_toggle").forEach(function(e){
542 if(!!e.children[0].checked){
543 prefer[e.children[0].id.replace("cookieadmin-","")] = 'true';
544 }
545 });
546
547 if(Object.keys(prefer).length !== 0){
548 var override_gpc = document.getElementById('cookieadmin-override_gpc');
549 var is_override_gpc = false;
550 if(override_gpc && override_gpc.checked){
551 is_override_gpc = true;
552 }
553
554 if(Object.keys(prefer).length === 3 && !is_override_gpc){
555 let accept_btn = document.querySelectorAll(".cookieadmin_accept_btn");
556
557 if(accept_btn.length > 0){
558 accept_btn[accept_btn.length-1].click();
559 }
560
561 return;
562 }
563 }else{
564 let reject_btn = document.querySelectorAll(".cookieadmin_reject_btn");
565
566 if(reject_btn.length > 0){
567 reject_btn[reject_btn.length-1].click();
568 }
569
570 return;
571 }
572
573 cookieadmin_toggle_overlay();
574
575 cookieadmin_set_consent(prefer, days);
576 });
577
578
579 //Accept or reject all cookies
580 cookieadmin_save_all_cookie_elemnts = document.querySelectorAll(".cookieadmin_accept_btn, .cookieadmin_reject_btn");
581
582 cookieadmin_save_all_cookie_elemnts.forEach(function(e){
583
584 e.addEventListener("click", function(){
585 // console.log(e);
586
587 document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none";
588 var cookieadmin_law_container = document.getElementsByClassName("cookieadmin_law_container")[0];
589 if(cookieadmin_law_container){
590 cookieadmin_law_container.style.display = "none";
591 }
592
593 var cookieadmin_re_consent = document.getElementsByClassName("cookieadmin_re_consent")[0];
594 if(cookieadmin_re_consent){
595 cookieadmin_re_consent.style.display = "block";
596 }
597
598 if(e.id.includes("modal")){
599 cookieadmin_toggle_overlay();
600 }
601
602 var prefer2 = e.classList.contains("cookieadmin_reject_btn") ? {reject: "true"} : {accept: "true"};
603
604 cookieadmin_set_consent(prefer2, days);
605 });
606 });
607
608 document.querySelectorAll(".cookieadmin_show_pref_cookies").forEach(function(e){
609 e.addEventListener("click", function(el){
610
611 var tgt = el.target.id;
612 tgt = tgt.replace(/-container$/, "");
613
614 if(el.target.classList.contains("dwn")){
615 el.target.innerHTML = "&#9658;";
616 el.target.classList.remove("dwn");
617 document.querySelector("."+tgt).style.display = "none";
618 }else{
619 el.target.innerHTML = "&#9660;";
620 el.target.classList.add("dwn");
621 document.querySelector("."+tgt).style.display = "block";
622 }
623 });
624 });
625
626 document.getElementsByClassName("cookieadmin_close_pref")[0].addEventListener("click", function(e){
627 document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none";
628 cookieadmin_toggle_overlay();
629 if(!cookieadmin_is_obj(cookieadmin_is_consent)){
630 var cookieadmin_law_container = document.getElementsByClassName("cookieadmin_law_container")[0];
631 if(cookieadmin_law_container){
632 cookieadmin_law_container.style.display = "block";
633 }
634 }else if(cookieadmin_show_reconsent){
635 var cookieadmin_re_consent = document.getElementsByClassName("cookieadmin_re_consent")[0];
636 if(cookieadmin_re_consent){
637 cookieadmin_re_consent.style.display = "block";
638 }
639 }
640 });
641
642 });
643
644 function cookieadmin_set_consent(prefrenc, days){
645
646 if (typeof cookieadmin_pro_set_consent === "function") {
647 return cookieadmin_pro_set_consent(prefrenc, days);
648 }else{
649 return cookieadmin_save_consent_cookie(prefrenc, days);
650 }
651 }
652
653 function cookieadmin_save_consent_cookie(prefrenc, days, consent_id){
654
655 var cookieadmin_consent = prefrenc;
656
657 if(consent_id){
658 cookieadmin_is_consent.consent = consent_id;
659 cookieadmin_consent['consent'] = consent_id;
660 }
661
662 if(!cookieadmin_is_consent.consent){
663 cookieadmin_is_consent.consent = "";
664 }
665
666 cookieadmin_is_consent["old_action"] = cookieadmin_is_consent.action ? cookieadmin_is_consent.action : {};
667 cookieadmin_is_consent.action = prefrenc;
668 cookieadmin_populate_preference();
669 cookieadmin_set_cookie('cookieadmin_consent', cookieadmin_consent, days);
670
671 if (typeof cookieadmin_update_gcm === "function") {
672 cookieadmin_update_gcm(1);
673 }
674
675 if (typeof cookieadmin_pro_update_clarity_cookie === "function") {
676 cookieadmin_pro_update_clarity_cookie();
677 }
678
679 if(!!cookieadmin_policy.reload_on_consent){
680 location.reload();
681 }else{
682 cookieadmin_restore_cookies(prefrenc);
683 }
684 }
685
686