1/*! 2* MyAgilePrivacy (https://www.myagileprivacy.com/) 3* plain version 4*/ 5 6var MAP_SYS = { 7 'plugin_version' : null, 8 'internal_version' : "2.0016", 9 'cookie_shield_version' : null, 10 'technology' : "plain", 11 'maplog' : "\x1b[40m\x1b[37m[MyAgilePrivacy]\x1b[0m ", 12 'map_initted' : false, 13 'map_document_load' : false, 14 'map_debug' : false, 15 'map_cookie_expire' : 180, 16 'map_skip_regexp' : [/.*oxygen_iframe=true.*$/, /.*ct_builder=true.*$/], 17 'map_missing_cookie_shield' : null, 18 'map_detectableKeys' : null, 19 'map_detectedKeys' : null, 20 'map_notify_title' : false, 21 'map_first_layer_branded' : false, 22 'enforce_youtube_privacy_v2' : false, 23 'in_iab_context' : false, 24 'dependencies' : [], 25 'cmode_v2' : null, 26 'cmode_v2_implementation_type' : null, 27 'cmode_v2_forced_off_ga4_advanced' : null, 28 'cmode_v2_js_on_error' : null, 29 'starting_gconsent' : [], 30 'current_gconsent' : [], 31 'map_accept_all_button' : null, 32 'map_reject_all_button' : null, 33 'user_uuid' : null, 34 'last_consent_modify_date' : null, 35 'some_positive_consent_given' : false, 36}; 37 38if( !( typeof MAP_JSCOOKIE_SHIELD !== 'undefined' && MAP_JSCOOKIE_SHIELD ) ) 39{ 40 MAP_POSTFIX = ''; 41 MAP_ACCEPTED_ALL_COOKIE_NAME = 'map_accepted_all_cookie_policy'; 42 MAP_ACCEPTED_SOMETHING_COOKIE_NAME = 'map_accepted_something_cookie_policy'; 43 MAP_CONSENT_STATUS = 'map_consent_status'; 44 MAP_USER_UUID = 'map_user_uuid'; 45 MAP_LAST_CONSENT_MODIFY_DATE = 'map_last_c_m_date'; 46 47 console.debug( MAP_SYS.maplog + 'MAP_POSTFIX=' + MAP_POSTFIX ); 48} 49 50if( typeof MAP_Cookie === 'undefined' ) 51{ 52 if( typeof MAP_UA_NO_COOKIE_SET === 'undefined' ) 53 { 54 var MAP_UA_NO_COOKIE_SET = ["Cookiebot", "cookiebot.com", "CookieHubVerify", "TermlyBot"]; 55 } 56 57 var MAP_Cookie = { 58 _isUserAgentNoCookieSet: function () { 59 var userAgent = navigator?.userAgent; 60 61 return MAP_UA_NO_COOKIE_SET.some( function( forbidden ){ 62 return userAgent.includes( forbidden ); 63 }); 64 }, 65 set: function (name, value, days) { 66 67 if( this._isUserAgentNoCookieSet() ) 68 { 69 return null; 70 } 71 72 try { 73 if (days) { 74 var date = new Date(); 75 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 76 var expires = "; expires=" + date.toGMTString(); 77 } else 78 var expires = ""; 79 document.cookie = name + "=" + value + expires + "; path=/"; 80 } 81 catch( e ) 82 { 83 console.debug( e ); 84 return null; 85 } 86 }, 87 setGMTString: function (name, value, GMTString) { 88 89 if( this._isUserAgentNoCookieSet() ) 90 { 91 return null; 92 } 93 94 try { 95 96 var expires = "; expires=" + GMTString; 97 document.cookie = name + "=" + value + expires + "; path=/"; 98 } 99 catch( e ) 100 { 101 console.debug( e ); 102 return null; 103 } 104 }, 105 read: function (name) { 106 try { 107 var nameEQ = name + "="; 108 var ca = document.cookie.split(';'); 109 for (var i = 0; i < ca.length; i++) { 110 var c = ca[i]; 111 while (c.charAt(0) == ' ') { 112 c = c.substring(1, c.length); 113 } 114 if (c.indexOf(nameEQ) === 0) { 115 return c.substring(nameEQ.length, c.length); 116 } 117 } 118 return null; 119 } 120 catch( e ) 121 { 122 console.debug( e ); 123 return null; 124 } 125 }, 126 exists: function (name) { 127 return (this.read(name) !== null); 128 } 129 }; 130} 131 132var MAP = 133{ 134 set: function( args ) 135 { 136 try { 137 138 if( this.initted ) 139 { 140 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'MAP already initted: exiting' ); 141 return; 142 } 143 144 var current_url = window.location.href; 145 146 var isMatch = MAP_SYS.map_skip_regexp.some( function( rx ) { 147 return rx.test( current_url ); 148 }); 149 150 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'calling MAP set function' ); 151 152 if( typeof JSON.parse !== "function" ) 153 { 154 console.error( MAP_SYS.maplog + 'Error: My Agile Privacy requires JSON.parse but your browser lacks this support' ); 155 return; 156 } 157 if( typeof args.settings !== 'object' ) 158 { 159 this.settings = JSON.parse( args.settings ); 160 } 161 else 162 { 163 this.settings = args.settings; 164 } 165 166 if( !!this?.settings?.plugin_version ) 167 { 168 MAP_SYS.plugin_version = this?.settings?.plugin_version; 169 } 170 171 if( !!this?.settings?.map_notify_title ) 172 { 173 MAP_SYS.map_notify_title = this?.settings?.map_notify_title; 174 } 175 176 if( !!this?.settings?.map_first_layer_branded ) 177 { 178 MAP_SYS.map_first_layer_branded = this?.settings?.map_first_layer_branded; 179 } 180 181 if( typeof map_full_config !== 'undefined' && 182 typeof map_full_config.enforce_youtube_privacy_v2 !== 'undefined' 183 ) 184 { 185 MAP_SYS.enforce_youtube_privacy_v2 = map_full_config.enforce_youtube_privacy_v2; 186 } 187 188 if( typeof CookieShield !== 'undefined' && 189 CookieShield 190 ) 191 { 192 MAP_SYS.cookie_shield_version = CookieShield.getVersion(); 193 } 194 195 if( ( !!this?.settings?.scan_mode && 196 this.settings.scan_mode == 'learning_mode' ) || 197 ( !!this?.settings?.verbose_remote_log && 198 this.settings.verbose_remote_log ) 199 ) 200 { 201 MAP_SYS.map_debug = true; 202 } 203 204 if( !!this?.settings?.cookie_reset_timestamp && 205 this.settings.cookie_reset_timestamp ) 206 { 207 if(!( typeof MAP_JSCOOKIE_SHIELD !== 'undefined' && MAP_JSCOOKIE_SHIELD ) ) 208 { 209 MAP_POSTFIX = '_' + this.settings.cookie_reset_timestamp; 210 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'MAP_POSTFIX=' + MAP_POSTFIX ); 211 } 212 } 213 214 if(!( typeof MAP_JSCOOKIE_SHIELD !== 'undefined' && MAP_JSCOOKIE_SHIELD ) ) 215 { 216 MAP_ACCEPTED_ALL_COOKIE_NAME = MAP_ACCEPTED_ALL_COOKIE_NAME + MAP_POSTFIX; 217 MAP_ACCEPTED_SOMETHING_COOKIE_NAME = MAP_ACCEPTED_SOMETHING_COOKIE_NAME + MAP_POSTFIX; 218 219 MAP_USER_UUID = MAP_USER_UUID + MAP_POSTFIX; 220 MAP_LAST_CONSENT_MODIFY_DATE = MAP_LAST_CONSENT_MODIFY_DATE + MAP_POSTFIX; 221 } 222 223 if( MAP_SYS?.map_debug && !!this?.settings.cookie_reset_timestamp && 224 this.settings.cookie_reset_timestamp ) 225 { 226 console.debug( MAP_SYS.maplog + 'using alt_accepted_all_cookie_name=' + MAP_ACCEPTED_ALL_COOKIE_NAME ); 227 console.debug( MAP_SYS.maplog + 'using alt_accepted_something_cookie_name=' + MAP_ACCEPTED_SOMETHING_COOKIE_NAME ); 228 console.debug( MAP_SYS.maplog + 'using alt_user_uuid_cookie_name=' + MAP_USER_UUID ); 229 console.debug( MAP_SYS.maplog + 'using alt_last_consent_modify_date_cookie_name=' + MAP_LAST_CONSENT_MODIFY_DATE ); 230 } 231 232 this.blocked_friendly_name_string = null; 233 234 this.blocked_content_notification_shown = false;
235 236 this.bar_open = false; 237 238 this.settings = args.settings; 239 240 this.bar_elm = document.querySelector( this.settings.notify_div_id ); 241 this.showagain_elm = document.querySelector( "#" + this.settings.showagain_div_id ); 242 this.settingsModal = document.querySelector( '#mapSettingsPopup' ); 243 this.blocked_content_notification = document.querySelector( '#map-blocked-content-notification-area' ); 244 245 if( this.blocked_content_notification ) 246 { 247 this.map_blocked_elems_desc = this.blocked_content_notification.querySelector('.map_blocked_elems_desc'); 248 } 249 250 this.map_notification_message = this.bar_elm.querySelector( '.map_notification-message' ); 251 252 /* buttons */ 253 this.accept_button = this.bar_elm.querySelector( '.map-accept-button' ); 254 this.reject_button = this.bar_elm.querySelectorAll( '.map-reject-button' ); 255 this.customize_button = this.bar_elm.querySelector( '.map-customize-button' ); 256 257 MAP_SYS.map_accept_all_button = this.accept_button; 258 MAP_SYS.map_reject_all_button = this.reject_button[0]; 259 260 if( MAP_SYS?.map_debug ) 261 { 262 console.groupCollapsed( MAP_SYS.maplog + 'settings:' ); 263 console.debug( this.settings ); 264 console.groupEnd(); 265 } 266 267 this.retrieveLastConsentDate(); 268 this.retrieveLastConsentUUID(); 269 this.loadDependencies(); 270 this.toggleBar(); 271 this.createInlineNotify(); 272 this.attachEvents(); 273 274 this.attachAnimations(); 275 276 this.initted = true; 277 278 this.optimizeMobile(); 279 280 //for preserving scope 281 var that = this; 282 283 window.addEventListener('resize', function() { 284 that.optimizeMobile(); 285 }); 286 287 this.setupIabTCF(); 288 this.updateSomeConsentGivenStatus(); 289 290 } 291 catch( error ) 292 { 293 console.error( error ); 294 } 295 }, 296 297 //inject code async 298 injectCode: function( src=null, callback=null ) 299 { 300 //for preserving scope 301 var that = this; 302 303 try { 304 305 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function injectCode src=' + src ); 306 307 if( src ) 308 { 309 const script = document.createElement( 'script' ); 310 script.async = true; 311 script.src = src; 312 script.onload = function() { 313 314 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'loaded script src=' + src ); 315 316 if( callback ) 317 { 318 callback(); 319 } 320 }; 321 322 document.body.append( script ); 323 } 324 325 } 326 catch( error ) 327 { 328 console.error( error ); 329 } 330 }, 331 332 //load dependencies 333 loadDependencies: function() 334 { 335 //for preserving scope 336 var that = this; 337 338 try { 339 340 var something_to_do = false; 341 342 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function loadDependencies' ); 343 344 //js shield 345 if( !( typeof MAP_JSCOOKIE_SHIELD !== 'undefined' && MAP_JSCOOKIE_SHIELD ) && 346 typeof map_full_config !== 'undefined' && typeof map_full_config?.js_shield_url !== 'undefined' && map_full_config?.js_shield_url ) 347 { 348 that.injectCode( map_full_config?.js_shield_url, function() { 349 } ); 350 351 something_to_do = true; 352 MAP_SYS.dependencies.push( map_full_config?.js_shield_url ); 353 } 354 355 //IabTCF 356 if( typeof map_full_config !== 'undefined' && typeof map_full_config?.load_iab_tcf !== 'undefined' && map_full_config?.load_iab_tcf && 357 typeof map_full_config?.iab_tcf_script_url !== 'undefined' && 358 typeof window?.initMyAgilePrivacyIabTCF === 'undefined' ) 359 { 360 that.injectCode( map_full_config?.iab_tcf_script_url, function() { 361 } ); 362 363 something_to_do = true; 364 MAP_SYS.dependencies.push( map_full_config?.iab_tcf_script_url ); 365 } 366 367 if( something_to_do ) 368 { 369 if( MAP_SYS?.map_debug ) 370 { 371 console.groupCollapsed( MAP_SYS.maplog + ' tried to load the following dependencies:' ); 372 console.log( MAP_SYS.dependencies ); 373 } 374 } 375 else 376 { 377 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + ' no depen
377dencies to load.' ); 378 } 379 380 console.groupEnd(); 381 382 } 383 catch( error ) 384 { 385 console.error( error ); 386 } 387 }, 388 389 //get consent status for consent mode 390 getGoogleConsentStatus: function( key ) 391 { 392 try { 393 394 return MAP_SYS?.current_gconsent[ key ]; 395 } 396 catch( error ) 397 { 398 console.error( error ); 399 } 400 }, 401 402 //f for updating given consent 403 updateGoogleConsent: function( key, value, updateStatusCookie = false) 404 { 405 //for preserving scope 406 var that = this; 407 408 try { 409 410 if( MAP_SYS?.cmode_v2 ) 411 { 412 if( MAP_SYS?.cmode_v2_implementation_type === 'native' ) 413 { 414 var newConsent = {}; 415 newConsent[key] = value; 416 417 gtag('consent', 'update', newConsent ); 418 } 419 420 if( MAP_SYS?.cmode_v2_implementation_type === 'gtm' ) 421 { 422 var newConsent = {}; 423 newConsent[key] = value; 424 425 gTagManagerConsentListeners.forEach( ( callback ) => { 426 callback( newConsent ); 427 }); 428 } 429 430 var currentGConsent = {...MAP_SYS?.current_gconsent}; 431 currentGConsent[key] = value; 432 MAP_SYS.current_gconsent = currentGConsent; 433 434 if( updateStatusCookie ) 435 { 436 that.saveGoogleConsentStatusToCookie( MAP_SYS?.current_gconsent ); 437 } 438 439 that.updateLastConsentRecords(); 440 441 return true; 442 } 443 444 return false; 445 446 } 447 catch( error ) 448 { 449 console.error( error ); 450 } 451 452 }, 453 454 //from cookie value to object 455 parseGoogleConsentStatus: function( consentStatusValue ) 456 { 457 try { 458 459 // Split the encoded string into individual key-value pairs 460 var keyValuePairs = consentStatusValue.split('|'); 461 462 // Create an empty object to store the decoded values 463 var decodedObject = {}; 464 465 // Iterate over the key-value pairs 466 keyValuePairs.forEach( function( pair ) { 467 // Split each pair into key and value 468 var parts = pair.split(':'); 469 470 // Extract key and convert value to boolean 471 var key = parts[0]; 472 var value = ( parts[1] === 'true' ) ? 'granted' : 'denied'; 473
474 decodedObject[key] = value; 475 }); 476 477 return decodedObject; 478 479 } 480 catch( error ) 481 { 482 console.error( error ); 483 } 484 }, 485 486 //from consent object to cookie 487 saveGoogleConsentStatusToCookie : function( consentObject ) 488 { 489 try { 490 491 // Convert object values to a string 492 var encodedString = Object.keys( consentObject ) 493 .map(function( key ) { 494 return key + ':' + ( consentObject[key] === 'granted' ); 495 }) 496 .join('|'); 497 498 499 MAP_Cookie.set( MAP_CONSENT_STATUS, encodedString, MAP_SYS.map_cookie_expire ); 500 501 return true; 502 503 } 504 catch( error ) 505 { 506 console.error( error ); 507 } 508 }, 509 510 //for google tag manager cookie parsing (gtm) 511 exportGoogleConsentObjectFromCookie: function() 512 { 513 //for preserving scope 514 var that = this; 515 516 try { 517 518 var cookieValue = MAP_Cookie.read( MAP_CONSENT_STATUS ); 519 520 if( cookieValue ) 521 { 522 var this_gconsent = that.parseGoogleConsentStatus( cookieValue ); 523 524 return this_gconsent; 525 } 526 527 return null; 528 529 } 530 catch( error ) 531 { 532 console.error( error ); 533 } 534 }, 535 536 //set initial consent from google tag manager (gtm) 537 setFromGoogleTagManagerInitialConsent: function( gconsent ) 538 { 539 //for preserving scope 540 var that = this; 541 542 try { 543 544 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function setFromGoogleTagManagerInitialConsent' ); 545 546 if( gconsent ) 547 { 548 //save starting consent 549 MAP_SYS.starting_gconsent = {...gconsent}; 550 MAP_SYS.current_gconsent = {...gconsent}; 551 552 that.saveGoogleConsentStatusToCookie( gconsent ); 553 554 //init only status, not events 555 that.userPreferenceInit( true ); 556 } 557 558 } 559 catch( error ) 560 { 561 console.error( error ); 562 } 563 }, 564 565 //consent listener for google tag manager (gtm) 566 googleTagManagerConsentListener: function( callback ) 567 { 568 try { 569 570 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function googleTagManagerConsentListener' ); 571 572 if( typeof gTagManagerConsentListeners !== 'undefined' ) 573 { 574 gTagManagerConsentListeners.push( callback ); 575 } 576 577 } 578 catch( error ) 579 { 580 console.error( error ); 581 } 582 }, 583 584 //init data for consent mode 585 setupConsentModeV2 : function() 586 { 587 //for preserving scope 588 var that = this; 589 590 try { 591 592 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function setupConsentModeV2' ); 593 594 if( typeof map_full_config === 'undefined' ) 595 { 596 return false; 597 } 598 599 MAP_SYS.cmode_v2 = map_full_config?.enable_cmode_v2; 600 MAP_SYS.cmode_v2_implementation_type = map_full_config?.cmode_v2_implementation_type; 601 MAP_SYS.cmode_v2_forced_off_ga4_advanced = map_full_config?.cmode_v2_forced_off_ga4_advanced; 602 MAP_SYS.cmode_v2_js_on_error = map_full_config?.cmode_v2_js_on_error; 603 604 if( MAP_SYS.cmode_v2 && MAP_SYS.cmode_v2_implementation_type == 'gtm' ) 605 { 606 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting default value for consent mode (gtm)' ); 607 608 var cookieValue = MAP_Cookie.read( MAP_CONSENT_STATUS ); 609 610 if( cookieValue ) 611 { 612 var this_gconsent = that.parseGoogleConsentStatus( cookieValue ); 613 //setting initial current_gconsent value (deep copy using spread operator) 614 MAP_SYS.current_gconsent = {...this_gconsent}; 615 } 616 } 617 618 if( MAP_SYS.cmode_v2 && MAP_SYS.cmode_v2_implementation_type == 'native' ) 619 { 620 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting default value for consent mode (native)' ); 621 622 //save starting consent 623 MAP_SYS.starting_gconsent = map_full_config?.cmode_v2_default_consent_obj; 624 625 var cookieValue = MAP_Cookie.read( MAP_CONSENT_STATUS ); 626 627 if( cookieValue ) 628 { 629 var this_gconsent = that.parseGoogleConsentStatus( cookieValue ); 630 631 //setting initial current_gconsent value (deep copy using spread operator) 632 MAP_SYS.current_gconsent = { ...this_gconsent }; 633 634 try { 635 gtag( 'consent', 'default', { ...MAP_SYS.current_gconsent } ); 636 } 637 catch( error ) 638 { 639 console.error( error ); 640 } 641 } 642 else 643 { 644 //no cookie value case 645 646 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting default consent (native)' ); 647 648 //setting initial current_gconsent value (deep copy using spread operator) 649 MAP_SYS.current_gconsent = { ...MAP_SYS.starting_gconsent }; 650 651 try { 652 gtag( 'consent', 'default', { ...MAP_SYS.starting_gconsent } ); 653 } 654 catch( error ) 655 { 656 console.error( error ); 657 } 658 659 that.saveGoogleConsentStatusToCookie( MAP_SYS.current_gconsent ); 660 } 661 } 662 663 return true; 664 665 } 666 catch( error ) 667 {
668 console.error( error ); 669 } 670 }, 671 672 //memorize last consent modification date, uuid generation eventually 673 updateLastConsentRecords : function() 674 { 675 //for preserving scope 676 var that = this; 677 678 try { 679 680 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'updateLastConsentRecords' ); 681 682 let date = new Date(); 683 let dateString = date.toISOString(); 684 685 MAP_SYS.last_consent_modify_date = date; 686 687 MAP_Cookie.set( MAP_LAST_CONSENT_MODIFY_DATE, dateString, MAP_SYS.map_cookie_expire ); 688 689 if( !MAP_Cookie.exists( MAP_USER_UUID ) ) 690 { 691 let uuid = that.generateUUID(); 692 693 if( uuid ) 694 { 695 MAP_SYS.user_uuid = uuid; 696 697 MAP_Cookie.set( MAP_USER_UUID, uuid, MAP_SYS.map_cookie_expire ); 698 } 699 } 700 701 return true; 702 } 703 catch( error ) 704 { 705 console.error( error ); 706 } 707 }, 708 709 //used on init 710 retrieveLastConsentDate : function() 711 { 712 //for preserving scope 713 var that = this; 714 715 try { 716 717 if( MAP_Cookie.exists( MAP_LAST_CONSENT_MODIFY_DATE ) ) 718 { 719 let dateStringFromCookie = MAP_Cookie.read( MAP_LAST_CONSENT_MODIFY_DATE ); 720 let dateFromCookie = new Date (dateStringFromCookie ); 721 722 MAP_SYS.last_consent_modify_date = dateFromCookie; 723 724 return dateFromCookie; 725 } 726 727 return null; 728 } 729 catch( error ) 730 { 731 console.error( error ); 732 } 733 }, 734 735 //used on init 736 retrieveLastConsentUUID : function() 737 { 738 //for preserving scope 739 var that = this; 740 741 try { 742 743 if( MAP_Cookie.exists( MAP_USER_UUID ) ) 744 { 745 let value = MAP_Cookie.read( MAP_USER_UUID ); 746 747 MAP_SYS.user_uuid = value; 748 749 return value; 750 } 751 752 return null; 753 } 754 catch( error ) 755 { 756 console.error( error ); 757 } 758 }, 759 760 761 //uuid generation 762 generateUUID : function() 763 { 764 try { 765 766 if( window.crypto && window.crypto.getRandomValues ) 767 { 768 return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => 769 (c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) 770 ); 771 } 772 773 return null; 774 } 775 catch( error ) 776 { 777 console.error( error ); 778 } 779 }, 780 781 toggleBar: function() 782 { 783 //for preserving scope 784 var that = this; 785 786 try { 787 788 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function toggleBar' ); 789 790 if( !MAP_Cookie.exists( MAP_ACCEPTED_ALL_COOKIE_NAME ) && 791 !MAP_Cookie.exists( MAP_ACCEPTED_SOMETHING_COOKIE_NAME ) 792 ) 793 { 794 if( MAP_SYS.in_iab_context ) 795 { 796 (async() => { 797 798 while( !MAP_SYS.map_document_load ) 799 { 800 //console.log( 'not defined yet' ); 801 await new Promise( resolve => setTimeout( resolve, 10 ) ); 802 } 803 804 (async() => { 805 //console.log("waiting for variable"); 806 while( typeof window.MAPIABTCF_brief_html_initted == 'function' && 807 !window.MAPIABTCF_brief_html_initted() ) 808 { 809 //console.log( 'not defined yet' ); 810 await new Promise( resolve => setTimeout( resolve, 10 ) ); 811 } 812 //console.log("variable is defined"); 813 that.displayBar(); 814 815 setTimeout( function() { 816 var scroll_to_top = document.querySelector( '.map_notification-message.map-iab-context' ); 817 if( scroll_to_top ) { 818 scroll_to_top.scrollIntoView( { behavior: 'smooth' } ); 819 } 820 }, 400); 821 822 })(); 823 824 })(); 825 } 826 else 827 { 828 that.displayBar(); 829 } 830 } 831 else 832 { 833 that.hideBar(); 834 } 835 836 this.showagain_elm.querySelectorAll( 'a.showConsent' ).forEach(function( $this ) { 837 $this.addEventListener('click', function(e) { 838 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered showConsent' ); 839 840 e.preventDefault(); 841 e.stopImmediatePropagation(); 842 843 //animation 844 var that_animation = MAP.bar_elm.getAttribute( 'data-animation' ); 845 var that_id_selector = '#' + MAP.bar_elm.getAttribute( 'id' ); 846 847 var animation_params = { 848 targets: that_id_selector, 849 easing: 'easeInOutQuad', 850 duration: 1000 851 }; 852 853 setTimeout( function() { 854 MAP.showagain_elm.style.display = 'none'; 855 }, 150 ); 856 857 anime( { 858 targets: MAP.showagain_elm, 859 easing: 'easeInOutQuad', 860 duration: 150, 861 opacity: 0, 862 complete: function( anim ) { 863 MAP.showagain_elm.style.display = 'none'; 864 } 865 } ); 866 867 setTimeout( function() { 868 869 try { 870 871 switch( that_animation ) 872 { 873 case 'slide': 874 875 var y_value = '0vh'; 876 var x_value = '0vw'; 877 878 if( MAP.bar_elm.classList.contains( 'map_floating_banner' ) ) 879 { 880 y_value = '3vh'; 881 x_value = '3vw'; 882 } 883 884 var $this = MAP.bar_elm; 885 886 if( MAP.bar_elm.className.includes( 'mapPositionBottom' ) ) { 887 $this.style.bottom = '-100vh'; 888 animation_params['bottom'] = y_value; 889 } 890 else if( MAP.bar_elm.className.includes( 'mapPositionTop' ) ) { 891 $this.style.top = '-100vh'; 892 animation_params['top'] = y_value; 893 } 894 else if( MAP.bar_elm.className.includes( 'mapPositionCenterLeft' ) ) { 895 $this.style.left = '-100vw'; 896 animation_params['left'] = x_value; 897 } 898 else if( MAP.bar_elm.className.includes( 'mapPositionCenterCenter' ) ) { 899 $this.style.top = '-100%'; 900 animation_params['top'] = '50%'; 901 } 902 else if( MAP.bar_elm.className.includes( 'mapPositionCenterRight' ) ) { 903 $this.style.right = '-100vw'; 904 animation_params['right'] = x_value; 905 } 906 907 MAP.bar_elm.style.display = 'block'; 908 anime( animation_params ); 909 break; 910 911 case 'fade': 912 document.querySelector( that_id_selector ).style.opacity = '0'; 913 MAP.bar_elm.style.display = 'block'; 914 915 animation_params['opacity'] = '1'; 916 animation_params['duration'] = '500'; 917 918 anime( animation_params ); 919 920 break; 921 922 case 'zoom': 923 document.querySelector( that_id_selector ).style.transform = 'scale(0)'; 924 MAP.bar_elm.style.display = 'block'; 925 926 animation_params['scale'] = '1'; 927 anime( animation_params ); 928 929 break; 930 931 default: // no animation -> value = "none" 932 MAP.bar_elm.style.display = 'block'; 933 break; 934 } 935 936 that.bar_open = true; 937 that.optimizeMobile(); 938 939 } 940 catch( error ) 941 { 942 console.error( error ); 943 } 944 945 },100 ); 946 947 948 }); 949 }); 950 951 //bof user consent review trigger 952 953 that.bar_elm.addEventListener( 'triggerShowAgainDisplay', function(e) { 954 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered triggerShowAgainDisplay' ); 955 956 e.preventDefault(); 957 e.stopImmediatePropagation(); 958 959 //animation 960 var that_animation = MAP.bar_elm.getAttribute('data-animation'); 961 var that_id_selector = '#' + MAP.bar_elm.getAttribute('id'); 962 963 var animation_params = { 964 targets: that_id_selector, 965 easing: 'easeInOutQuad', 966 duration: 1000 967 }; 968 969 setTimeout( function() { 970 MAP.showagain_elm.style.display = 'none'; 971 }, 150 ); 972 973 anime( { 974 targets: MAP.showagain_elm, 975 easing: 'easeInOutQuad', 976 duration: 150, 977 opacity: 0, 978 complete: function(anim) { 979 MAP.showagain_elm.style.display = 'none'; 980 } 981 } ); 982 983 setTimeout( function() { 984 985 try { 986 987 switch( that_animation ) 988 { 989 case 'slide': 990 991 var y_value = '0vh'; 992 var x_value = '0vw'; 993 994 if( MAP.bar_elm.classList.contains( 'map_floating_banner' ) ) 995 { 996 y_value = '3vh'; 997 x_value = '3vw'; 998 } 999 1000 var element = document.querySelector( that_id_selector ); 1001 1002 if( MAP.bar_elm.className.includes( 'mapPositionBottom' ) ) { 1003 element.style.bottom = '-100vh'; 1004 animation_params['bottom'] = y_value; 1005 } 1006 else if( MAP.bar_elm.className.includes( 'mapPositionTop' ) ) { 1007 element.style.top = '-100vh'; 1008 animation_params['top'] = y_value; 1009 } 1010 else if( MAP.bar_elm.className.includes( 'mapPositionCenterLeft' ) ) { 1011 element.style.left = '-100vw'; 1012 animation_params['left'] = x_value; 1013 } 1014 else if( MAP.bar_elm.className.includes( 'mapPositionCenterCenter' ) ) { 1015 element.style.top = '-100%'; 1016 animation_params['top'] = '50%'; 1017 } 1018 else if( MAP.bar_elm.className.includes( 'mapPositionCenterRight') ) { 1019 element.style.right = '-100vw'; 1020 animation_params['right'] = x_value; 1021 } 1022 1023 MAP.bar_elm.style.display = 'block'; 1024 anime( animation_params ); 1025 break; 1026 1027 case 'fade': 1028 document.querySelector( that_id_selector ).style.opacity = '0'; 1029 MAP.bar_elm.style.display = 'block'; 1030 1031 animation_params['opacity'] = '1'; 1032 animation_params['duration'] = '500'; 1033 1034 anime( animation_params ); 1035 1036 break; 1037 1038 case 'zoom': 1039 document.querySelector( that_id_selector ).style.transform = 'scale(0)'; 1040 MAP.bar_elm.style.display = 'block'; 1041 1042 animation_params['scale'] = '1'; 1043 anime( animation_params ); 1044 break; 1045 1046 default: // no animation -> value = "none" 1047 MAP.bar_elm.style.display = 'block'; 1048 break; 1049 } 1050 1051 that.bar_open = true; 1052 that.optimizeMobile(); 1053 } 1054 catch( error ) 1055 { 1056 console.error( error ); 1057 } 1058 1059 }, 100 ); 1060 }); 1061 1062 document.body.addEventListener('click', function(e) { 1063 1064 var targetElement = e.target; 1065 var matchFound = false;
1066 var levelsToCheck = 2; 1067 1068 while( levelsToCheck > 0 && targetElement ) 1069 { 1070 if (targetElement.matches('.showConsentAgain')) { 1071 matchFound = true; 1072 break; 1073 } 1074 targetElement = targetElement.parentElement; 1075 levelsToCheck--; 1076 } 1077 1078 if( matchFound ) 1079 { 1080 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered showConsentAgain' ); 1081 e.preventDefault(); 1082 e.stopImmediatePropagation(); 1083 1084 var event = new CustomEvent('triggerShowAgainDisplay'); 1085 that.bar_elm.dispatchEvent( event ); 1086 } 1087 }); 1088 1089 1090 //eof user consent review trigger 1091 } 1092 catch( error ) 1093 { 1094 console.error( error ); 1095 } 1096 }, 1097 1098 createInlineNotify: function() 1099 { 1100 try { 1101 1102 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function createInlineNotify' ); 1103 1104 //for preserving scope 1105 var that = this; 1106 1107 if( typeof CookieShield !== 'undefined' && 1108 CookieShield ) 1109 { 1110 var detectedKeys = CookieShield.getDetectedKeys(); 1111 1112 Object.keys( detectedKeys ).forEach( function( key ) { 1113 1114 var api_key = detectedKeys[key]; 1115 1116 var $custom_ref = document.querySelector('.map_custom_notify.map_api_key_' + api_key); 1117 1118 if( $custom_ref ) 1119 { 1120 $custom_ref.style.display = 'block'; 1121 } 1122 }); 1123 } 1124 1125 var $map_blocked_content = document.querySelectorAll( '.map_blocked_content' ); 1126 1127 $map_blocked_content.forEach( function( $this) { 1128 1129 var api_key = $this.getAttribute( 'data-cookie-api-key' ); 1130 1131 var $custom_ref = document.querySelectorAll( '.map_custom_notify.map_api_key_' + api_key ); 1132 1133 $custom_ref.forEach(function( customRef ) { 1134 if( customRef ) 1135 { 1136 customRef.style.display = 'block'; 1137 } 1138 }); 1139 1140 }); 1141 1142 var $show_inline_notify = document.querySelectorAll( '.iframe_src_blocked.map_show_inline_notify' ); 1143
1144 $show_inline_notify.forEach( function( $this ) { 1145 1146 var height = $this.offsetHeight; 1147 1148 var width = $this.offsetWidth; 1149 1150 var api_key = $this.getAttribute('data-cookie-api-key'); 1151 1152 var the_friendly_name = ''; 1153 var friendly_name = $this.getAttribute('data-friendly-name'); 1154 1155 if( friendly_name ) 1156 { 1157 the_friendly_name = friendly_name; 1158 } 1159 1160 $this.style.display = 'none'; 1161 1162 var html = "<div class='map_inline_notify showConsentAgain' data-cookie-api-key='"+api_key+"'>"+that.settings.blocked_content_text+"<br>"+the_friendly_name+"</div>"; 1163 1164 //temp div for inject via vanilla js 1165 var tempDiv = document.createElement( 'div' ); 1166 tempDiv.innerHTML = html; 1167 1168 var $injected = tempDiv.firstChild; 1169 $this.parentNode.insertBefore( $injected, $this.nextSibling ); 1170 1171 if( height > 0 ) 1172 { 1173 $injected.style.height = height + 'px'; 1174 } 1175 1176 if( width > 0 ) 1177 { 1178 $injected.style.width = width + 'px'; 1179 } 1180 1181 if( that.settings.inline_notify_color ) 1182 { 1183 $injected.style.color = that.settings.inline_notify_color; 1184 } 1185 1186 if( that.settings.inline_notify_background ) 1187 { 1188 $injected.style.backgroundColor = that.settings.inline_notify_background; 1189 } 1190 1191 }); 1192 1193 } 1194 catch( error ) 1195 { 1196 console.error( error ); 1197 } 1198 }, 1199 1200 setupIabTCF: function() 1201 { 1202 //for preserving scope 1203 var that = this; 1204 1205 try { 1206 1207 var $map_consent_extrawrapper = that.settingsModal.querySelector( '.map-consent-extrawrapper' ); 1208 1209 if( !!$map_consent_extrawrapper ) 1210 { 1211 MAP_SYS.in_iab_context = true; 1212 1213 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function setupIabTCF' ); 1214 1215 //first layer 1216 that.bar_elm.querySelectorAll( '.map-triggerGotoIABTCF' ).forEach( function( $this ) { 1217 $this.addEventListener( 'click', function( e ) { 1218 1219 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-triggerGotoIABTCF click' ); 1220 1221 e.preventDefault(); 1222 e.stopImmediatePropagation(); 1223 1224 MAP.settingsModal.classList.add( 'map-show' ); 1225 MAP.settingsModal.style.opacity = 0; 1226 MAP.settingsModal.offsetWidth; // Trigger a reflow to ensure the transition starts 1227 MAP.settingsModal.style.transition = 'opacity 1s'; 1228 MAP.settingsModal.style.opacity = 1; 1229 1230 MAP.settingsModal.classList.remove( 'map-blowup', 'map-out' ); 1231 MAP.settingsModal.classList.add( 'map-blowup' ); 1232 1233 document.body.classList.add( 'map-modal-open' ); 1234 1235 document.querySelector( '.map-settings-overlay' ).classList.add( 'map-show' ); 1236 1237 if( !document.querySelector( '.map-settings-mobile' ).offsetWidth ) 1238 { 1239 // MAP.settingsModal.find( '.map-nav-link:eq(0)' ).click(); 1240 MAP.settingsModal.querySelector('.map-nav-link').click(); 1241 } 1242 1243 $map_consent_extrawrapper.querySelectorAll( '.map-wrappertab-navigation li a[href="#map-privacy-iab-tcf-wrapper"]' ).forEach( function( $_this ) { 1244 $_this.click(); 1245 }); 1246 1247 }); 1248 }); 1249 1250 that.bar_elm.querySelectorAll( '.map-triggerGotoIABTCFVendors' ).forEach( function( $this ) { 1251 $this.addEventListener('click', function(e) { 1252 1253 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-triggerGotoIABTCFVendors click' ); 1254 1255 e.preventDefault(); 1256 e.stopImmediatePropagation(); 1257 1258 MAP.settingsModal.classList.add('map-show'); 1259 MAP.settingsModal.style.opacity = 0; 1260 1261 MAP.settingsModal.offsetWidth; // Trigger a reflow to ensure the transition starts 1262 MAP.settingsModal.style.transition = 'opacity 1s'; 1263 MAP.settingsModal.style.opacity = 1; 1264 1265 MAP.settingsModal.classList.remove( 'map-blowup', 'map-out' ); 1266 MAP.settingsModal.classList.add( 'map-blowup' ); 1267 1268 document.body.classList.add( 'map-modal-open' ); 1269 1270 document.querySelector( '.map-settings-overlay' ).classList.add( 'map-show' ); 1271 1272 var mapSettingsMobile = document.querySelector( '.map-settings-mobile' ); 1273 if( mapSettingsMobile && mapSettingsMobile.offsetWidth === 0 && mapSettingsMobile.offsetHeight === 0) 1274 { 1275 var firstNavLink = MAP.settingsModal.querySelector( '.map-nav-link' ); 1276 if( firstNavLink ) 1277 { 1278 firstNavLink.click(); 1279 } 1280 } 1281 1282 $map_consent_extrawrapper.querySelectorAll( '.map-wrappertab-navigation li a[href="#map-privacy-iab-tcf-wrapper"]' ).forEach( function( $_this ) { 1283 $_this.click(); 1284 }); 1285 1286 setTimeout( function() { 1287 1288 try { 1289
1290 var $vendor_list_button = document.querySelector( '#map-iab-tcf-vendor-list' ); 1291 1292 if( $vendor_list_button ) 1293 { 1294 $vendor_list_button.click(); 1295 1296 setTimeout( function() { 1297 var $vendor_list_scrollto = document.querySelector( '#map-iab-tcf-vendor-list-scroll-here' ); 1298 1299 if( $vendor_list_scrollto ) 1300 { 1301 $vendor_list_scrollto.scrollIntoView({ behavior: 'smooth' }); 1302 } 1303 }, 200 ); 1304 } 1305 } 1306 catch( error ) 1307 { 1308 console.error( error ); 1309 } 1310 1311 }, 200); 1312 }); 1313 }); 1314 1315 //bof nav part 1316 $map_consent_extrawrapper.querySelectorAll( '.map-wrappertab-navigation li a' ).forEach( function( $this ) { 1317 $this.addEventListener( 'click', function(e) { 1318 1319 e.preventDefault(); 1320 1321 var tabHref = $this.getAttribute( 'href' ); 1322 var lastIndex = tabHref.lastIndexOf('#'); 1323 if( lastIndex !== -1 ) 1324 { 1325 tabHref = tabHref.substring( lastIndex )?.replace( '#', '' ); 1326 } 1327 else 1328 { 1329 tabHref = 'map-privacy-iab-tcf-wrapper'; 1330 } 1331 1332 if( tabHref == 'map-privacy-iab-tcf-wrapper') 1333 { 1334 (async() => { 1335 1336 while( !MAP_SYS.map_document_load ) 1337 { 1338 //console.log( 'not defined yet' ); 1339 await new Promise( resolve => setTimeout( resolve, 10 ) ); 1340 } 1341 1342 if( typeof window.MAPIABTCF_showCMPUI === 'function' ) 1343 { 1344 window.MAPIABTCF_showCMPUI(); 1345 } 1346 1347 })(); 1348 } 1349 else 1350 { 1351 (async() => { 1352 1353 while( !MAP_SYS.map_document_load ) 1354 { 1355 //console.log( 'not defined yet' ); 1356 await new Promise( resolve => setTimeout( resolve, 10 ) ); 1357 } 1358 1359 if( typeof window.MAPIABTCF_hideCMPUI === 'function' ) 1360 { 1361 window.MAPIABTCF_hideCMPUI(); 1362 } 1363 1364 })(); 1365 1366 } 1367 1368 $map_consent_extrawrapper.querySelectorAll( '.map-wrappertab-navigation li a' ).forEach( function( $_this ) { 1369 $_this.classList.remove( 'active-wrappertab-nav' ); 1370 }); 1371 1372 $this.classList.add( 'active-wrappertab-nav' ); 1373 1374 $map_consent_extrawrapper.querySelectorAll( '.map-wrappertab' ).forEach( function( $_this ) { 1375 $_this.classList.remove( 'map-wrappertab-active' ); 1376 }); 1377 1378 var activeTab = $map_consent_extrawrapper.querySelector( '.map-wrappertab.' + tabHref ); 1379 if( activeTab ) 1380 { 1381 activeTab.classList.add( 'map-wrappertab-active' ); 1382 } 1383 1384 }); 1385 }); 1386 1387 //eof nav part 1388 1389 //bof IAB TCF init and events 1390 (async() => { 1391 1392 while( !MAP_SYS.map_document_load ) 1393 { 1394 //console.log( 'not defined yet' ); 1395 await new Promise( resolve => setTimeout( resolve, 10 ) ); 1396 } 1397 1398 if( typeof window.initMyAgilePrivacyIabTCF === 'function' ) 1399 { 1400 var this_lang_code = null; 1401 1402 if( typeof map_lang_code !== 'undefined' ) 1403 { 1404 this_lang_code = map_lang_code; 1405 } 1406 1407 if( typeof map_full_config?.map_lang_code !== 'undefined' ) 1408 { 1409 this_lang_code = map_full_config?.map_lang_code; 1410 } 1411 1412 window.initMyAgilePrivacyIabTCF( this_lang_code ); 1413 } 1414 1415 })(); 1416 //eof IAB TCF init and events 1417 } 1418 1419 } 1420 catch( error ) 1421 { 1422 console.error( error ); 1423 } 1424 }, 1425 1426 //returns vendor list 1427 returnVendorsList: function() 1428 { 1429 //for preserving scope 1430 var that = this; 1431 1432 try { 1433 1434 var standard_vendors = []; 1435 var other_iab_and_google_vendors = []; 1436 var vendors_all = []; 1437 1438 for ( const [key, value] of Object.entries( map_full_config?.cookie_api_key_remote_id_map_active ) ) 1439 { 1440 let item = { 1441 name: key, 1442 iabId: null 1443 } 1444 1445 standard_vendors.push( item ); 1446 } 1447 1448 if( typeof window.MAPIABTCF_getVendorsList === 'function' ) 1449 { 1450 other_iab_and_google_vendors = window.MAPIABTCF_getVendorsList(); 1451 } 1452 1453 vendors_all = [ ...standard_vendors, ...other_iab_and_google_vendors ]; 1454 1455 return vendors_all; 1456 } 1457 catch( error ) 1458 { 1459 console.error( error ); 1460 } 1461 }, 1462 1463 //updating SYS_MAP some positive consent status 1464 updateSomeConsentGivenStatus: function() 1465 { 1466 //for preserving scope 1467 var that = this; 1468 1469 try { 1470 1471 let acceptedAll_status = MAP_Cookie.read( MAP_ACCEPTED_ALL_COOKIE_NAME ); 1472 const atLeastSomeCModeV2ConsentGranted = Object.values( MAP_SYS?.current_gconsent ).some( value => value === 'granted' ); 1473 1474 if( acceptedAll_status == '1' ) 1475 { 1476 MAP_SYS.some_positive_consent_given = true; 1477 } 1478 else if( atLeastSomeCModeV2ConsentGranted ) 1479 { 1480 MAP_SYS.some_positive_consent_given = true; 1481 } 1482 else 1483 {
1484 let counter = 0; 1485 1486 Object.entries( map_full_config.cookie_api_key_remote_id_map_active ).forEach( ([key, value] ) => { 1487 1488 if( MAP_Cookie.read( value ) == '1') 1489 { 1490 counter++; 1491 } 1492 }); 1493 1494 if( typeof window.MAPIABTCF_getSomePositiveConsentStatus === 'function' ) 1495 { 1496 if( window.MAPIABTCF_getSomePositiveConsentStatus() ) 1497 { 1498 counter++; 1499 } 1500 } 1501 1502 if( counter == 0 ) 1503 { 1504 MAP_SYS.some_positive_consent_given = false; 1505 } 1506 else 1507 { 1508 MAP_SYS.some_positive_consent_given = true; 1509 } 1510 } 1511 } 1512 catch( error ) 1513 { 1514 console.error( error ); 1515 } 1516 1517 }, 1518 1519 attachEvents: function() 1520 { 1521 try { 1522 1523 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function attachEvents' ); 1524 1525 //for preserving scope 1526 1527 var that = this; 1528 1529 that.accept_button.addEventListener( 'click', function( e ) { 1530 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-accept-button click' ); 1531 1532 e.preventDefault(); 1533 e.stopImmediatePropagation(); 1534 1535 var $this = this; 1536 1537 that.updateLastConsentRecords(); 1538 1539 //check consent-mode checkbox 1540 that.settingsModal.querySelectorAll( '.map-consent-mode-preference-checkbox' ).forEach( function( elem ) { 1541 elem.checked = true; 1542 1543 var consent_key = elem.getAttribute( 'data-consent-key' ); 1544 1545 that.updateGoogleConsent( consent_key, 'granted', true ); 1546 }); 1547 1548 //check user-preference checkbox 1549 that.settingsModal.querySelectorAll( '.map-user-preference-checkbox' ).forEach(function( elem ) { 1550 1551 var cookieName = 'map_cookie_' + elem.getAttribute( 'data-cookie-baseindex' ) + MAP_POSTFIX; 1552 1553 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting 1 to cookieName=' + cookieName ); 1554 1555 MAP_Cookie.set( cookieName, '1', MAP_SYS.map_cookie_expire ); 1556 1557 elem.checked = true; 1558 }); 1559 1560 //check iab-preference checkbox 1561 that.settingsModal.querySelectorAll( '.map-user-iab-preference-checkbox' ).forEach( function( elem ) { 1562 elem.checked = true; 1563 }); 1564 1565 (async() => { 1566 1567 while( !MAP_SYS.map_document_load ) 1568 { 1569 //console.log( 'not defined yet' ); 1570 await new Promise( resolve => setTimeout( resolve, 10 ) ); 1571 } 1572 1573 if( typeof window.MAPIABTCF_acceptAllConsent === 'function' ) 1574 { 1575 window.MAPIABTCF_doSetUserInteraction(); 1576 window.MAPIABTCF_acceptAllConsent( true ); 1577 1578 that.updateSomeConsentGivenStatus(); 1579 } 1580 1581 })(); 1582 1583 MAP.accept_close(); 1584 }); 1585 1586 1587 that.reject_button.forEach(function( button ) { 1588 button.addEventListener('click', function(e) { 1589 1590 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-reject-button click' ); 1591 1592 e.preventDefault(); 1593 e.stopImmediatePropagation(); 1594 1595 var $this = this; 1596 1597 that.updateLastConsentRecords(); 1598 1599 //uncheck consent-mode checkbox 1600 that.settingsModal.querySelectorAll( '.map-consent-mode-preference-checkbox' ).forEach( function( elem ) { 1601 elem.checked = false; 1602 1603 var consent_key = elem.getAttribute( 'data-consent-key' ); 1604 1605 that.updateGoogleConsent( consent_key, 'denied', true ); 1606 }); 1607 1608 //uncheck user-preference checkbox 1609 that.settingsModal.querySelectorAll( '.map-user-preference-checkbox' ).forEach( function( elem ) { 1610 1611 var cookieName = 'map_cookie_' + elem.getAttribute( 'data-cookie-baseindex' ) + MAP_POSTFIX; 1612 1613 MAP_Cookie.set( cookieName, '-1', MAP_SYS.map_cookie_expire ); 1614 1615 elem.checked = false; 1616 }); 1617 1618 //uncheck iab-preference checkbox 1619 that.settingsModal.querySelectorAll( '.map-user-iab-preference-checkbox' ).forEach( function( elem ) { 1620 elem.checked = false; 1621 }); 1622 1623 (async() => { 1624 1625 while( !MAP_SYS.map_document_load ) 1626 { 1627 //console.log( 'not defined yet' ); 1628 await new Promise( resolve => setTimeout( resolve, 10 ) ); 1629 } 1630 1631 if( typeof window.MAPIABTCF_denyAllConsent === 'function' ) 1632 { 1633 window.MAPIABTCF_doSetUserInteraction(); 1634 window.MAPIABTCF_denyAllConsent( true ); 1635 1636 that.updateSomeConsentGivenStatus(); 1637 } 1638 1639 })(); 1640 1641 MAP.reject_close(); 1642 }); 1643 }); 1644 1645 1646 that.customize_button.addEventListener( 'click', function(e) { 1647 1648 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-customize-button click' ); 1649 1650 e.preventDefault(); 1651 e.stopImmediatePropagation(); 1652 1653 MAP.settingsModal.classList.add( 'map-show' ); 1654 MAP.settingsModal.style.opacity = 0; 1655 MAP.settingsModal.offsetWidth; // Trigger a reflow to ensure the transition starts 1656 MAP.settingsModal.style.transition = 'opacity 1s'; 1657 MAP.settingsModal.style.opacity = 1; 1658 1659 MAP.settingsModal.classList.remove( 'map-blowup', 'map-out' ); 1660 MAP.settingsModal.classList.add( 'map-blowup' ); 1661 1662 document.body.classList.add( 'map-modal-open' ); 1663 1664 document.querySelector( '.map-settings-overlay' ).classList.add( 'map-show' ); 1665 1666 var mapSettingsMobile = document.querySelector( '.map-settings-mobile' ); 1667 1668 if( mapSettingsMobile && mapSettingsMobile.offsetWidth === 0 && mapSettingsMobile.offsetHeight === 0 ) 1669 { 1670 var firstNavLink = MAP.settingsModal.querySelector( '.map-nav-link' ); 1671 if( firstNavLink ) 1672 { 1673 firstNavLink.click(); 1674 } 1675 } 1676 1677 var $map_consent_extrawrapper = that.settingsModal.querySelectorAll( '.map-consent-extrawrapper' ); 1678 1679 if( !!$map_consent_extrawrapper && $map_consent_extrawrapper?.length ) 1680 { 1681 var triggerElement = $map_consent_extrawrapper[0].querySelector( '.map-wrappertab-navigation li a[href="#map-privacy-cookie-thirdypart-wrapper"]' ); 1682 if( triggerElement ) 1683 { 1684 triggerElement.click(); 1685 } 1686 } 1687 1688 }); 1689 1690 document.querySelector('#mapModalClose').addEventListener('click', function(e) { 1691 1692 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered mapModalClose click' ); 1693 1694 e.preventDefault(); 1695 e.stopImmediatePropagation(); 1696 1697 MAP.closeSettingsPopup(); 1698 MAP.hideBar(); 1699 1700 }); 1701 1702 that.setupAccordion(); 1703 1704 if( typeof map_ajax !== 'undefined' && 1705 typeof map_ajax.cookie_process_delayed_mode !== 'undefined' && 1706 map_ajax.cookie_process_delayed_mode == 1 1707 ) 1708 { 1709 //wait for page load 1710 1711 (async() => { 1712 1713 while( !MAP_SYS.map_document_load ) 1714 { 1715 //console.log( 'not defined yet' ); 1716 await new Promise( resolve => setTimeout( resolve, 10 ) ); 1717 } 1718 1719 that.userPreferenceInit( false ); 1720 1721 })(); 1722 1723 } 1724 else 1725 {
1726 that.userPreferenceInit( false ); 1727 } 1728 1729 } 1730 catch( error ) 1731 { 1732 console.error( error ); 1733 } 1734 }, 1735 1736 1737 attachAnimations: function() 1738 { 1739 try { 1740 1741 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function attachAnimations' ); 1742 1743 //for preserving scope 1744 var that = this; 1745 1746 if( that.bar_elm.querySelector( '#map-accept-button' ).getAttribute( 'data-animate' ) == 'true' ) 1747 { 1748 var acceptButton = document.querySelector( '#map-accept-button' ); 1749 1750 var animation = acceptButton.getAttribute( 'data-animation-effect' ); 1751 1752 var delay = parseInt(acceptButton.getAttribute( 'data-animation-delay') ) * 1000; 1753 1754 var repeat = parseInt(acceptButton.getAttribute( 'data-animation-repeat' ) ); 1755 1756 var all_animation_classes = ['animate__animated', animation] ; 1757 1758 var iteration_counter = 0; 1759 1760 var animInterval = setInterval( function() { 1761 if(iteration_counter == repeat) 1762 { 1763 clearInterval( animInterval ); 1764 } 1765 else 1766 { 1767 acceptButton.classList.add( ...all_animation_classes ); 1768 1769 setTimeout( function() { 1770 1771 acceptButton.classList.remove( ...all_animation_classes ); 1772 iteration_counter ++; 1773 1774 }, 900 ); 1775 } 1776 1777 }, delay ); 1778 1779 } 1780 1781 } 1782 catch( error ) 1783 { 1784 console.error( error ); 1785 } 1786 }, 1787 1788 checkBlockedContent: function() 1789 { 1790 try { 1791 1792 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function checkBlockedContent' ); 1793 1794 //for preserving scope 1795 var that = this; 1796 1797 var $map_blocked_content = document.querySelectorAll( '.map_blocked_content:not(._is_activated)' ); 1798 1799 if( !!$map_blocked_content && $map_blocked_content?.length ) 1800 { 1801 //calc data 1802 var blocked_friendly_name = []; 1803 1804 $map_blocked_content.forEach( function( $this ) { 1805 1806 var this_friendly_name = $this.getAttribute('data-friendly_name'); 1807 1808 if( this_friendly_name ) 1809 { 1810 blocked_friendly_name.push( this_friendly_name ); 1811 } 1812 1813 }); 1814 1815 if( typeof CookieShield !== 'undefined' && 1816 CookieShield && 1817 typeof CookieShield.getDetectedFriendlyNames !== 'undefined' ) 1818 { 1819 var other_names = CookieShield.getDetectedFriendlyNames(); 1820 1821 other_names.forEach( function( v ) { 1822 1823 if( v ) 1824 { 1825 if( v?.desc ) 1826 { 1827 blocked_friendly_name.push( v.desc ); 1828 } 1829 else 1830 { 1831 blocked_friendly_name.push( v ); 1832 } 1833 1834 } 1835 }); 1836 } 1837 1838 var blocked_friendly_name_unique = blocked_friendly_name.filter((v, i, a) => a.indexOf(v) === i); 1839 1840 that.blocked_friendly_name_string = blocked_friendly_name_unique.join( ', ' ); 1841 1842 //check if to show 1843 if( blocked_friendly_name_unique.length && 1844 ( !that.bar_open || that.settings.show_ntf_bar_on_not_yet_consent_choice ) ) 1845 { 1846 if( that.blocked_content_notification && that.blocked_content_notification ) 1847 { 1848 if( that.blocked_friendly_name_string ) 1849 { 1850 that.map_blocked_elems_desc.innerHTML = that.blocked_friendly_name_string; 1851 } 1852 else 1853 { 1854 that.map_blocked_elems_desc.style.opacity = 0; 1855 that.map_blocked_elems_desc.style.display = 'block'; 1856 1857 anime( { 1858 targets: that.map_blocked_elems_desc, 1859 easing: 'easeInOutQuad', 1860 duration: 150, 1861 opacity: 1, 1862 complete: function(anim) { 1863 } 1864 } ); 1865 1866 } 1867 1868 that.blocked_content_notification_shown = true; 1869 1870 var blocked_content_notify_auto_shutdown_time = 3000; 1871 1872 if( that.settings.blocked_content_notify_auto_shutdown_time ) 1873 { 1874 blocked_content_notify_auto_shutdown_time = that.settings.blocked_content_notify_auto_shutdown_time; 1875 } 1876 1877 setTimeout( function() { 1878 1879 try { 1880 1881 that.blocked_content_notification.style.opacity = 0; 1882 that.blocked_content_notification.style.display = 'block'; 1883 1884 anime( { 1885 targets: that.blocked_content_notification, 1886 easing: 'easeInOutQuad', 1887 duration: 150, 1888 opacity: 1, 1889 complete: function(anim) { 1890 } 1891 } ); 1892 1893 if( that.blocked_content_notification.classList.contains( 'autoShutDown' ) ) 1894 { 1895 setTimeout( function() { 1896 1897 1898 setTimeout( function() { 1899 that.blocked_content_notification.style.display = 'none'; 1900 }, 150 ); 1901 1902 anime( { 1903 targets: that.blocked_content_notification, 1904 easing: 'easeInOutQuad', 1905 duration: 150, 1906 opacity: 0, 1907 complete: function(anim) { 1908 that.blocked_content_notification.style.display = 'none'; 1909 } 1910 } ); 1911 1912 }, blocked_content_notify_auto_shutdown_time ); 1913 } 1914 } 1915 catch( error ) 1916 { 1917 console.error( error ); 1918 } 1919 1920 }, 1000 ); 1921 } 1922 } 1923 } 1924 else 1925 {
1926 if( that.blocked_content_notification ) 1927 { 1928 1929 setTimeout( function() { 1930 that.blocked_content_notification.style.display = 'none'; 1931 }, 150 ); 1932 1933 anime( { 1934 targets: that.blocked_content_notification, 1935 easing: 'easeInOutQuad', 1936 duration: 150, 1937 opacity: 0, 1938 complete: function(anim) { 1939 that.blocked_content_notification.style.display = 'none'; 1940 } 1941 } ); 1942 } 1943 } 1944 1945 this.administratorNotices(); 1946 1947 } 1948 catch( error ) 1949 { 1950 console.error( error ); 1951 } 1952 }, 1953 1954 displayBar: function() 1955 { 1956 try { 1957 1958 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function displayBar' ); 1959 1960 //for preserving scope 1961 var that = this; 1962 1963 //animation 1964 var that_animation = that.bar_elm.getAttribute( 'data-animation' ); 1965 1966 var that_id_selector = '#' + that.bar_elm.getAttribute( 'id' ); 1967 1968 var animation_params = { 1969 targets: that_id_selector, 1970 easing: 'easeInOutQuad', 1971 duration: 1000 1972 }; 1973 1974 var y_value = '0vh'; 1975 var x_value = '0vw'; 1976 1977 if( that.bar_elm.classList.contains( 'map_floating_banner' ) ) 1978 { 1979 y_value = '3vh'; 1980 x_value = '3vw'; 1981 } 1982 1983 var element = document.querySelector( that_id_selector ); 1984 1985 switch( that_animation ) 1986 { 1987 case 'slide': 1988 1989 if( element.className.includes( 'mapPositionBottom' ) ) 1990 { 1991 element.style.bottom = '-100vh'; 1992 animation_params['bottom'] = y_value; 1993 } 1994 else if( element.className.includes( 'mapPositionTop' ) ) 1995 { 1996 element.style.top = '-100vh'; 1997 animation_params['top'] = y_value; 1998 } 1999 else if( element.className.includes( 'mapPositionCenterLeft' ) ) 2000 { 2001 element.style.left = '-100vw'; 2002 animation_params['left'] = x_value; 2003 } 2004 else if( element.className.includes( 'mapPositionCenterCenter' ) ) 2005 { 2006 element.style.top = '-100%'; 2007 animation_params['top'] = '50%'; 2008 } 2009 else if( element.className.includes( 'mapPositionCenterRight' ) ) 2010 { 2011 element.style.right = '-100vw'; 2012 animation_params['right'] = x_value; 2013 } 2014 2015 element.style.display = 'block'; 2016 2017 anime( animation_params ); 2018 break; 2019 2020 case 'fade': 2021 element.style.opacity = '0'; 2022 2023 element.style.display = 'block'; 2024 2025 animation_params['opacity'] = '1'; 2026 animation_params['duration'] = '500'; 2027 2028 anime( animation_params ); 2029 2030 break; 2031 2032 case 'zoom': 2033 element.style.transform = 'scale(0)'; 2034 2035 element.style.display = 'block'; 2036 2037 animation_params['scale'] = '1'; 2038 anime( animation_params ); 2039 2040 break; 2041 2042 default: // no animation -> value = "none" 2043 element.style.display = 'block'; 2044 2045 break; 2046 } 2047 2048 setTimeout( function() { 2049 that.showagain_elm.style.display = 'none'; 2050 }, 150 ); 2051 2052 anime( { 2053 targets: that.showagain_elm, 2054 easing: 'easeInOutQuad', 2055 duration: 150, 2056 opacity: 0, 2057 complete: function( anim ) { 2058 that.showagain_elm.style.display = 'none'; 2059 } 2060 } ); 2061 2062 that.bar_open = true; 2063 2064 that.optimizeMobile(); 2065 2066 } 2067 catch( error ) 2068 { 2069 console.error( error ); 2070 } 2071 2072 }, 2073 2074 hideBar: function() 2075 { 2076 try { 2077 2078 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function hideBar' ); 2079 2080 //for preserving scope 2081 var that = this; 2082 2083 if( Boolean( this.settings.showagain_tab ) ) 2084 { 2085 //show 2086 that.showagain_elm.style.opacity = 0; 2087 that.showagain_elm.style.display = 'block'; 2088 2089 anime( { 2090 targets: this.showagain_elm, 2091 easing: 'easeInOutQuad', 2092 duration: 150, 2093 opacity: 1, 2094 complete: function(anim) { 2095 } 2096 } ); 2097 } 2098 else 2099 { 2100 setTimeout( function() { 2101 that.showagain_elm.style.display = 'none'; 2102 }, 150 ); 2103 2104 //hide 2105 anime( { 2106 targets: this.showagain_elm, 2107 easing: 'easeInOutQuad', 2108 duration: 150, 2109 opacity: 0, 2110 complete: function(anim) { 2111 that.showagain_elm.style.display = 'none'; 2112 } 2113 }); 2114 } 2115 2116 //hide 2117 //animation 2118 var that_animation = this.bar_elm.getAttribute( 'data-animation' ); 2119 2120 var that_id_selector = '#' + this.bar_elm.getAttribute( 'id' ); 2121 2122 setTimeout( function() { 2123 MAP.bar_elm.style.display = 'none'; 2124 }, 150 ); 2125 2126 var animation_params = { 2127 targets: that_id_selector, 2128 easing: 'easeInOutQuad', 2129 duration: 700, 2130 complete: function( anim ) { 2131 MAP.bar_elm.style.display = 'none'; 2132 } 2133 }; 2134 2135 switch( that_animation ) 2136 { 2137 case 'slide': 2138 2139 if( this.bar_elm.className.includes( 'mapPositionBottom' ) ) 2140 { 2141 animation_params['bottom'] = '-100vh'; 2142 } 2143 else if( this.bar_elm.className.includes( 'mapPositionTop' ) ) 2144 { 2145 animation_params['top'] = '-100vh'; 2146 } 2147 else if( this.bar_elm.className.includes( 'mapPositionCenterLeft' ) ) 2148 { 2149 animation_params['left'] = '-100vw'; 2150 } 2151 else if( this.bar_elm.className.includes( 'mapPositionCenterCenter' ) ) 2152 { 2153 animation_params['top'] = '-100%'; 2154 } 2155 else if( this.bar_elm.className.includes( 'mapPositionCenterRight' ) ) 2156 { 2157 animation_params['right'] = '-100vw'; 2158 } 2159 2160 anime( animation_params ); 2161 break; 2162
2163 case 'fade': 2164 2165 animation_params['opacity'] = '0'; 2166 animation_params['duration'] = '500'; 2167 2168 anime( animation_params ); 2169 2170 break; 2171 2172 case 'zoom': 2173 2174 animation_params['scale'] = '0'; 2175 anime( animation_params ); 2176 2177 2178 break; 2179 2180 default: // no animation -> value = "none" 2181 this.bar_elm.style.display = 'none'; 2182 2183 break; 2184 } 2185 2186 this.bar_open = false; 2187 2188 (async() => { 2189 2190 while( !MAP_SYS.map_document_load ) 2191 { 2192 //console.log( 'not defined yet' ); 2193 await new Promise( resolve => setTimeout( resolve, 10 ) ); 2194 } 2195 2196 if( typeof window.MAPIABTCF_hideCMPUI === 'function' ) 2197 { 2198 window.MAPIABTCF_hideCMPUI(); 2199 } 2200 2201 })(); 2202 2203 } 2204 catch( error ) 2205 { 2206 console.error( error ); 2207 } 2208 }, 2209 2210 optimizeMobile: function() 2211 { 2212 //for preserving scope 2213 var that = this; 2214 2215 setTimeout( function() { 2216 2217 try { 2218 2219 if( that.bar_open ) 2220 { 2221 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'optimizing for mobile view' ); 2222 2223 var viewport_width = window.innerWidth; 2224 2225 if( viewport_width <= 450 ) 2226 { 2227 var coeff = 250; 2228 2229 if( MAP_SYS?.map_notify_title == 1 ) 2230 { 2231 coeff += 50; 2232 } 2233 2234 if( MAP_SYS?.map_first_layer_branded == 1 ) 2235 { 2236 coeff += 60; 2237 } 2238 2239 var viewport_height = window.innerHeight; 2240 var internal_height = viewport_height - coeff; 2241 2242 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'map mobile optimizing: viewport_width=' + viewport_width + ' , internal_height=' + internal_height ); 2243 2244 that.map_notification_message.classList.add( 'extraNarrow' ); 2245 that.map_notification_message.style.maxHeight = internal_height + 'px'; 2246 } 2247 else 2248 { 2249 that.map_notification_message.classList.remove( 'extraNarrow' ); 2250 that.map_notification_message.style.maxHeight = ''; 2251 } 2252 } 2253 2254 that.setOverflowMaxHeight(); 2255 2256 } 2257 catch( error ) 2258 { 2259 console.error( error ); 2260 } 2261 2262 }, 400 ); 2263 }, 2264 2265 accept_close: function() 2266 { 2267 //for preserving scope 2268 var that = this; 2269 2270 try { 2271 2272 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function accept_close' ); 2273 2274 MAP_Cookie.set( MAP_ACCEPTED_ALL_COOKIE_NAME, '1', MAP_SYS.map_cookie_expire ); 2275 2276 that.updateSomeConsentGivenStatus(); 2277 2278 //animation 2279 var that_animation = this.bar_elm.getAttribute( 'data-animation' ); 2280 2281 var that_id_selector = '#' + this.bar_elm.getAttribute( 'id' ); 2282 2283 var animation_params = { 2284 targets: that_id_selector, 2285 easing: 'easeInOutQuad', 2286 duration: 700, 2287 complete: function( anim ) { 2288 MAP.bar_elm.style.display = 'none'; 2289 2290 } 2291 }; 2292 2293 switch( that_animation ) 2294 { 2295 case 'slide': 2296 if( this.bar_elm.className.includes( 'mapPositionBottom' ) ) { 2297 animation_params['bottom'] = '-100vh'; 2298 } 2299 else if( this.bar_elm.className.includes( 'mapPositionTop' ) ) { 2300 animation_params['top'] = '-100vh'; 2301 } 2302 else if( this.bar_elm.className.includes( 'mapPositionCenterLeft' ) ) { 2303 animation_params['left'] = '-100vw'; 2304 } 2305 else if( this.bar_elm.className.includes( 'mapPositionCenterCenter' ) ) { 2306 animation_params['top'] = '-100%'; 2307 } 2308 else if( this.bar_elm.className.includes( 'mapPositionCenterRight' ) ) { 2309 animation_params['right'] = '-100vw'; 2310 } 2311 2312 anime( animation_params ); 2313 break; 2314 2315 case 'fade': 2316 2317 animation_params['opacity'] = '0'; 2318 animation_params['duration'] = '500'; 2319 2320 anime( animation_params ); 2321 2322 break; 2323 2324 case 'zoom': 2325 2326 animation_params['scale'] = '0'; 2327 anime( animation_params ); 2328 2329 break; 2330 2331 default: // no animation -> value = "none" 2332 this.bar_elm.style.display = 'none'; 2333 break; 2334 } 2335 2336 if( Boolean( that.settings.showagain_tab ) ) 2337 { 2338 that.showagain_elm.style.opacity = 0; 2339 that.showagain_elm.style.display = 'block'; 2340 2341 anime( { 2342 targets: that.showagain_elm, 2343 easing: 'easeInOutQuad', 2344 duration: 150, 2345 opacity: 1, 2346 complete: function(anim) { 2347 } 2348 } ); 2349 } 2350 2351 that.tryToUnblockScripts( true, null ); 2352 2353 (async() => { 2354 2355 while( !MAP_SYS.map_document_load ) 2356 { 2357 //console.log( 'not defined yet' ); 2358 await new Promise( resolve => setTimeout( resolve, 10 ) ); 2359 } 2360 2361 if( typeof window.MAPIABTCF_hideCMPUI === 'function' ) 2362 { 2363 window.MAPIABTCF_hideCMPUI(); 2364 } 2365 2366 })(); 2367 2368 return false;
2369 2370 } 2371 catch( error ) 2372 { 2373 console.error( error ); 2374 } 2375 }, 2376 2377 reject_close: function() 2378 { 2379 //for preserving scope 2380 var that = this; 2381 2382 try { 2383 2384 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function reject_close' ); 2385 2386 MAP_Cookie.set( MAP_ACCEPTED_ALL_COOKIE_NAME, '-1', MAP_SYS.map_cookie_expire ); 2387 MAP_Cookie.set( MAP_ACCEPTED_SOMETHING_COOKIE_NAME, '-1', MAP_SYS.map_cookie_expire ); 2388 2389 that.updateSomeConsentGivenStatus(); 2390 2391 //animation 2392 var that_animation = that.bar_elm.getAttribute( 'data-animation' ); 2393 2394 var that_id_selector = '#' + that.bar_elm.getAttribute( 'id' ); 2395 2396 var animation_params = { 2397 targets: that_id_selector, 2398 easing: 'easeInOutQuad', 2399 duration: 700, 2400 complete: function( anim ) { 2401 MAP.bar_elm.style.display = 'none'; 2402 } 2403 }; 2404 2405 switch( that_animation ) 2406 { 2407 case 'slide': 2408 2409 if( that.bar_elm.className.includes( 'mapPositionBottom' ) ) 2410 { 2411 animation_params['bottom'] = '-100vh'; 2412 } 2413 else if( that.bar_elm.className.includes( 'mapPositionTop' ) ) 2414 { 2415 animation_params['top'] = '-100vh'; 2416 } 2417 else if( that.bar_elm.className.includes( 'mapPositionCenterLeft' ) ) 2418 { 2419 animation_params['left'] = '-100vw'; 2420 } 2421 else if( that.bar_elm.className.includes( 'mapPositionCenterRight' ) ) 2422 { 2423 animation_params['right'] = '-100vw'; 2424 } 2425 2426 anime( animation_params ); 2427 break; 2428 2429 case 'fade': 2430 2431 animation_params['opacity'] = '0'; 2432 animation_params['duration'] = '500'; 2433 2434 anime( animation_params ); 2435 2436 break; 2437 2438 case 'zoom': 2439 2440 animation_params['scale'] = '0'; 2441 anime( animation_params ); 2442 2443 2444 break; 2445 2446 default: // no animation -> value = "none" 2447 that.bar_elm.style.display = 'none'; 2448 2449 break; 2450 } 2451 2452 that.bar_open = false; 2453 2454 if( Boolean( that.settings.showagain_tab ) ) 2455 { 2456 that.showagain_elm.style.opacity = 0; 2457 that.showagain_elm.style.display = 'block'; 2458 2459 anime( { 2460 targets: that.showagain_elm, 2461 easing: 'easeInOutQuad', 2462 duration: 150, 2463 opacity: 1, 2464 complete: function(anim) { 2465 } 2466 } ); 2467 } 2468 2469 that.tryToUnblockScripts( true, null ); 2470 2471 setTimeout( function() { 2472 that.checkBlockedContent(); 2473 }, 200 ); 2474 2475 (async() => { 2476 2477 while( !MAP_SYS.map_document_load ) 2478 { 2479 //console.log( 'not defined yet' ); 2480 await new Promise( resolve => setTimeout( resolve, 10 ) ); 2481 } 2482 2483 if( typeof window.MAPIABTCF_hideCMPUI === 'function' ) 2484 { 2485 window.MAPIABTCF_hideCMPUI(); 2486 } 2487 2488 })(); 2489 2490 return false; 2491 2492 } 2493 catch( error ) 2494 { 2495 console.error( error ); 2496 } 2497 }, 2498 2499 tryToUnblockScripts: function( from_user_interaction = false, cookieNameReference = null ) 2500 { 2501 try { 2502 2503 let need_reload = false; 2504 let do_calc_need_reload = false; 2505 2506 if( from_user_interaction ) 2507 { 2508 do_calc_need_reload = true; 2509 } 2510 2511 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + `tryToUnblockScripts from_user_interaction=${from_user_interaction}` ); 2512 2513 //for preserving scope 2514 var that = this; 2515 2516 var once_functions_to_execute = []; 2517 2518 var $map_cookie_description_wrapper = that.settingsModal.querySelectorAll( '.map_cookie_description_wrapper' ); 2519 2520 $map_cookie_description_wrapper.forEach( function( $this ) { 2521 2522 var baseIndex = $this.getAttribute('data-cookie-baseindex'); 2523 var cookieName = 'map_cookie_' + baseIndex + MAP_POSTFIX; 2524 var api_key = $this.getAttribute('data-cookie-api-key'); 2525 2526 var cookieValue = MAP_Cookie.read( cookieName ); 2527 2528 if( $this.classList && 2529 do_calc_need_reload && 2530 $this.classList.contains( 'map_page_reload_on_user_consent' ) && 2531 cookieName == cookieNameReference && 2532 MAP_Cookie.read( cookieName ) == '1' ) 2533 { 2534 need_reload = true; 2535 } 2536 2537 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'debug ' + api_key + ' ' + cookieName + ' ' + cookieValue ); 2538 2539 var always_on = false; 2540 var activate_anyway = false; 2541 2542 if( $this.classList.contains( '_always_on' ) ) 2543 { 2544 always_on = true; 2545 } 2546 2547 //advanced consent mode ga4 2548 if( api_key == 'google_analytics' && 2549 typeof map_full_config !== 'undefined' && 2550 typeof map_full_config.cookie_api_key_not_to_block !== 'undefined' 2551 && map_full_config?.cookie_api_key_not_to_block?.includes( 'google_analytics' ) 2552 ) 2553 { 2554 activate_anyway = true; 2555 } 2556 2557 var accepted_all = false;
2558 2559 if( ( MAP_Cookie.exists( MAP_ACCEPTED_ALL_COOKIE_NAME ) && MAP_Cookie.read( cookieName ) == '1' ) ) 2560 { 2561 accepted_all = true; 2562 } 2563 2564 if( cookieValue == "1" || 2565 always_on || 2566 activate_anyway || 2567 accepted_all ) 2568 { 2569 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + '-->activating api_key=' + api_key + ' cookieName=' + cookieName + ' cookieValue=' + cookieValue + ' always_on=' + always_on + ' accepted_all=' + accepted_all ); 2570 2571 if( activate_anyway ) 2572 { 2573 $this.classList.add( '_is_activated_anyway' ); 2574 } 2575 else 2576 { 2577 $this.classList.add( '_is_activated' ); 2578 } 2579 2580 if( $this.classList.contains( '_with_code' ) ) 2581 { 2582 var $the_script = document.querySelector( 'script.my_agile_privacy_activate._js_noscript_type_mode[data-cookie-baseindex="'+baseIndex+'"]' ); 2583 2584 var $the_raw_script = document.querySelector( 'textarea.my_agile_privacy_activate._raw_type_mode[data-cookie-baseindex="'+baseIndex+'"]' ); 2585 2586 if( $the_script ) 2587 { 2588 if( !$the_script.classList.contains( '_is_activated' ) ) 2589 { 2590 $the_script.classList.add( '_is_activated' ); 2591 2592 var script = document.createElement( 'script' ); 2593 script.className = '_is_activated'; 2594 script.innerHTML = $the_script.innerHTML; 2595 2596 if( MAP_SYS?.map_debug ) console.debug( script.innerHTML ); 2597 2598 document.head.appendChild( script ); 2599 } 2600 } 2601 2602 if( $the_raw_script ) 2603 { 2604 if( !$the_raw_script.classList.contains( '_is_activated' ) ) 2605 { 2606 $the_raw_script.classList.add( '_is_activated' ); 2607 2608 var the_raw_script = $the_raw_script.value; 2609 2610 if( MAP_SYS?.map_debug ) console.debug( the_raw_script ); 2611 2612 var range = document.createRange(); 2613 range.selectNode( document.getElementsByTagName("body")[0] ); 2614 var documentFragment = range.createContextualFragment( the_raw_script ); 2615 document.body.appendChild( documentFragment ); 2616 } 2617 2618 } 2619 } 2620 2621 if( !!api_key ) 2622 { 2623 //bof custom notify 2624 var $custom_ref = document.querySelectorAll( '.map_custom_notify.map_api_key_' + api_key ); 2625 2626 $custom_ref.forEach(function( $_this ){ 2627 2628 if( $_this ) 2629 { 2630 var on_unblock_remove_class = $_this.getAttribute( 'data-on-unblock-remove-class' ); 2631 2632 if( on_unblock_remove_class ) 2633 { 2634 var $the_blocked_content = document.querySelectorAll( '.my_agile_privacy_activate[data-cookie-api-key="' + api_key + '"]' ); 2635 2636 $the_blocked_content.forEach( $thisent => $thisent.classList.remove( on_unblock_remove_class ) ); 2637 } 2638 2639 $_this.remove(); 2640 } 2641 }); 2642 2643 //eof custom notify 2644 2645 var $map_src_script_blocked = document.querySelectorAll( 'script.my_agile_privacy_activate.autoscan_mode.map_src_script_blocked[data-cookie-api-key="'+api_key+'"]' ); 2646 2647 var $map_inline_script_blocked = document.querySelectorAll( 'script.my_agile_privacy_activate.autoscan_mode.map_inline_script_blocked[data-cookie-api-key="'+api_key+'"]' ); 2648 2649 var $iframe_src_blocked = document.querySelectorAll( 'iframe.my_agile_privacy_activate.autoscan_mode.iframe_src_blocked[data-cookie-api-key="'+api_key+'"]' ); 2650 2651 var $css_href_blocked = document.querySelectorAll( 'link.my_agile_privacy_activate.autoscan_mode.css_href_blocked[data-cookie-api-key="'+api_key+'"]' ); 2652 2653 var $img_src_blocked = document.querySelectorAll( 'img.my_agile_privacy_activate.autoscan_mode.img_src_blocked[data-cookie-api-key="'+api_key+'"]' ); 2654 2655 if( !!$map_src_script_blocked && $map_src_script_blocked?.length ) 2656 { 2657 $map_src_script_blocked.forEach( function( $_this ) { 2658 2659 2660 let old_script_type = $_this.getAttribute( 'type' ); 2661 let new_script_type = 'text/javascript'; 2662 2663 if( typeof old_script_type !== 'undefined' && 2664 old_script_type && 2665 old_script_type == 'module' ) 2666 { 2667 new_script_type = 'module'; 2668 } 2669 2670 2671 2672 if( !$_this.classList.contains( '_is_activated' ) ) 2673 { 2674 if( !$_this.classList.contains( 'mapWait' ) ) 2675 { 2676 $_this.classList.add( '_is_activated' ); 2677 } 2678 2679 if( $_this.classList.contains( 'custom_patch_apply' ) ) 2680 { 2681 var classes = $_this.className.split(' '); 2682
2683 classes.forEach(function(v) { 2684 if(v && v != '' && v.startsWith('map_trigger_custom_patch_') && typeof window[v] === 'function') { 2685 setTimeout( function() { 2686 window[v](); 2687 }, 4000 ); 2688 } 2689 }); 2690 } 2691 2692 if( $_this.classList.contains( 'once_custom_patch_apply' ) ) 2693 { 2694 var classes = $_this.className.split(' '); 2695 2696 classes.forEach(function(v) { 2697 if(v && v != '' && v.startsWith('map_trigger_custom_patch_') && typeof window[v] === 'function') { 2698 if( !once_functions_to_execute.includes( v )) { 2699 once_functions_to_execute.push( v ); 2700 } 2701 } 2702 }); 2703 } 2704 2705 if( $_this.classList.contains( 'mapWait' ) ) 2706 { 2707 setTimeout( function() { 2708 2709 //prevent block using createElementBackup 2710 var script = document.createElementBackup( 'script' ); 2711 script.className = '_is_activated'; 2712 script.setAttribute( 'type',new_script_type ); 2713 2714 script = cloneNodeAttributeToAnother( $_this, script ); 2715 2716 var blocked_src = $_this.getAttribute( 'unblocked_src' ); 2717 2718 if( blocked_src ) 2719 { 2720 script.src = blocked_src; 2721 } 2722 2723 $_this.insertAdjacentElement( 'afterend', script ); 2724 2725 $_this.classList.add( '_is_activated' ); 2726 2727 }, 2000); 2728 } 2729 else 2730 { 2731 //prevent block using createElementBackup 2732 var script = document.createElementBackup( 'script' ); 2733 script.className = '_is_activated'; 2734 script.setAttribute( 'type',new_script_type ); 2735 2736 script = cloneNodeAttributeToAnother( $_this, script ); 2737 2738 var blocked_src = $_this.getAttribute( 'unblocked_src' ); 2739 2740 if( blocked_src ) 2741 { 2742 script.src = blocked_src; 2743 } 2744 2745 $_this.insertAdjacentElement( 'afterend', script ); 2746 } 2747 } 2748 2749 }); 2750 2751 } 2752 2753 if( !!$map_inline_script_blocked && $map_inline_script_blocked?.length ) 2754 { 2755 $map_inline_script_blocked.forEach( function( $_this ) { 2756 2757 if( !$_this.classList.contains( '_is_activated' ) ) 2758 { 2759 if( !$_this.classList.contains('mapWait') ) 2760 { 2761 $_this.classList.add( '_is_activated' ); 2762 } 2763 2764 if( $_this.classList.contains( 'custom_patch_apply' ) ) 2765 { 2766 var classes = $_this.className.split(' '); 2767 2768 classes.forEach( function(v) { 2769 if( v && v != '' && v.startsWith('map_trigger_custom_patch_') && typeof window[v] === 'function' ) 2770 { 2771 setTimeout( function() { 2772 window[v](); 2773 }, 2200); 2774 } 2775 }); 2776 } 2777 2778 if( $_this.classList.contains( 'once_custom_patch_apply' ) ) 2779 { 2780 var classes = $_this.className.split(' '); 2781 2782 classes.forEach( function(v) { 2783 if( v && v != '' && v.startsWith('map_trigger_custom_patch_') && typeof window[v] === 'function' ) 2784 { 2785 if(!once_functions_to_execute.includes( v )) { 2786 once_functions_to_execute.push( v ); 2787 } 2788 } 2789 }); 2790 } 2791 2792 if( $_this.classList.contains( 'mapWait' ) ) 2793 { 2794 setTimeout( function() { 2795 var script = document.createElement( 'script' ); 2796 script.className = '_is_activated'; 2797 script.innerHTML = $_this.innerHTML; 2798 2799 if( MAP_SYS?.map_debug ) console.debug( script.innerHTML ); 2800 2801 document.head.appendChild( script ); 2802 2803 $_this.classList.add( '_is_activated' ); 2804 2805 }, 2200); 2806 } 2807 else 2808 { 2809 var script = document.createElement( 'script' ); 2810 script.className = '_is_activated'; 2811 script.innerHTML = $_this.innerHTML; 2812 2813 if( MAP_SYS?.map_debug ) console.debug( script.innerHTML ); 2814 2815 document.head.appendChild( script ); 2816 } 2817 } 2818 2819 }); 2820 2821 } 2822 2823 if( !!$iframe_src_blocked && $iframe_src_blocked?.length ) 2824 { 2825 $iframe_src_blocked.forEach( function( $_this ) { 2826 2827 if( !$_this.classList.contains( '_is_activated' ) ) 2828 { 2829 $_this.classList.add( '_is_activated' ); 2830 2831 $_this.setAttribute( 'src', $_this.getAttribute( 'unblocked_src' ) ); 2832 2833 $_this.style.display = 'block'; 2834 2835 var $ref = document.querySelectorAll( '.map_inline_notify[data-cookie-api-key="' + api_key + '"]'); 2836 2837 if( !!$ref && $ref?.length ) 2838 { 2839 $ref.forEach( function( $_ref ) { 2840 $_ref.remove(); 2841 }); 2842 } 2843 } 2844 }); 2845 } 2846 2847 if( !!$css_href_blocked && $css_href_blocked?.length ) 2848 { 2849 $css_href_blocked.forEach( function( $_this ) { 2850 2851 if( !$_this.classList.contains( '_is_activated' ) ) 2852 { 2853 $_this.classList.add( '_is_activated' ); 2854 2855 $_this.setAttribute( 'href', $_this.getAttribute( 'unblocked_href' ) ); 2856 } 2857 }); 2858 } 2859 2860 if( !!$img_src_blocked && $img_src_blocked?.length ) 2861 { 2862 $img_src_blocked.forEach( function( $_this ) { 2863 2864 if( !$_this.classList.contains( '_is_activated' ) ) 2865 { 2866 $_this.classList.add( '_is_activated' ); 2867 2868 $_this.setAttribute( 'src', $_this.getAttribute( 'unblocked_src' ) ); 2869 } 2870 }); 2871 } 2872 } 2873 } 2874 else 2875 { 2876 $this.classList.remove( '_is_activated' ); 2877 } 2878 2879 }); 2880 2881 if( need_reload ) 2882 { 2883 window.location.reload(); 2884 } 2885 2886 //execution of once custom patch functions 2887 once_functions_to_execute.forEach( function(v) { 2888 setTimeout( function() { 2889 window[v](); 2890 }, 1000 ); 2891 }); 2892 2893 setTimeout( function() { 2894 that.checkBlockedContent(); 2895 }, 500 ); 2896 2897 setTimeout( function() { 2898 var event = new Event('MAP_PRIVACY_CHANGE'); 2899 document.body.dispatchEvent(event); 2900 }, 100 ); 2901 2902 } 2903 catch( error ) 2904 {
2905 console.error( error ); 2906 } 2907 }, 2908 2909 //init user preferences and bind events 2910 //with only_init_status==true events are not binded 2911 userPreferenceInit: function( only_init_status = false ) 2912 { 2913 try { 2914 2915 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'userPreferenceInit only_init_status='+only_init_status ); 2916 2917 //for preserving scope 2918 var that = this; 2919 2920 //init part (cookie consent) 2921 that.settingsModal.querySelectorAll( '.map-user-preference-checkbox' ).forEach( function( $this ) { 2922 2923 var cookieName = 'map_cookie_' + $this.getAttribute('data-cookie-baseindex') + MAP_POSTFIX; 2924 2925 var cookieValue = MAP_Cookie.read( cookieName ); 2926 if( cookieValue == null ) 2927 { 2928 if( $this.checked ) 2929 { 2930 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting 1 to cookieName=' + cookieName ); 2931 2932 MAP_Cookie.set( cookieName, '1', MAP_SYS.map_cookie_expire ); 2933 } 2934 else 2935 { 2936 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting -1 to cookieName' + cookieName ); 2937 2938 MAP_Cookie.set( cookieName, '-1', MAP_SYS.map_cookie_expire ); 2939 } 2940 } 2941 else 2942 { 2943 if( cookieValue == "1" ) 2944 { 2945 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting checked for cookieName' + cookieName ); 2946 2947 $this.checked = true; 2948 } 2949 else 2950 { 2951 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting unchecked for cookieName' + cookieName ); 2952 2953 $this.checked = false; 2954 } 2955 } 2956 }); 2957 2958 //click event 2959 if( only_init_status == false ) 2960 { 2961 that.settingsModal.querySelectorAll( '.map-user-preference-checkbox' ).forEach(function($this) { 2962 $this.addEventListener('click', function(e) { 2963 2964 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-user-preference-checkbox click' ); 2965 2966 e.stopImmediatePropagation(); 2967 2968 that.updateLastConsentRecords(); 2969 2970 var cookieName = 'map_cookie_' + $this.getAttribute('data-cookie-baseindex') + MAP_POSTFIX; 2971 2972 var currentToggleElm = that.settingsModal.querySelectorAll( '.map-user-preference-checkbox[data-cookie-baseindex="'+$this.getAttribute('data-cookie-baseindex')+'"]' ); 2973 2974 if( $this.checked ) 2975 { 2976 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting 1 to cookieName=' + cookieName ); 2977 2978 MAP_Cookie.set( cookieName, '1', MAP_SYS.map_cookie_expire ); 2979 currentToggleElm.forEach( elm => elm.checked = true ); 2980 } 2981 else 2982 { 2983 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting -1 to cookieName' + cookieName ); 2984 2985 MAP_Cookie.set( cookieName, '-1', MAP_SYS.map_cookie_expire ); 2986 currentToggleElm.forEach( elm => elm.checked = false ); 2987 } 2988 2989 MAP_Cookie.set( MAP_ACCEPTED_SOMETHING_COOKIE_NAME, '1', MAP_SYS.map_cookie_expire ); 2990 MAP_Cookie.set( MAP_ACCEPTED_ALL_COOKIE_NAME, '-1', MAP_SYS.map_cookie_expire ); 2991 2992 that.updateSomeConsentGivenStatus(); 2993 2994 that.tryToUnblockScripts( true, cookieName ); 2995 2996 }); 2997 }); 2998 } 2999 3000 //bof init part ( consent mode) 3001 that.settingsModal.querySelectorAll( '.map-consent-mode-preference-checkbox' ).forEach( function( $this ) { 3002 3003 var consent_key = $this.getAttribute( 'data-consent-key' ); 3004 3005 var consentStatus = that.getGoogleConsentStatus( consent_key ); 3006 3007 if( consentStatus === 'granted' ) 3008 { 3009 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting checked for consent_key' + consent_key ); 3010 3011 $this.checked = true; 3012 } 3013 else if( consentStatus === 'denied' ) 3014 { 3015 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'setting unchecked for consent_key' + consent_key ); 3016 3017 $this.checked = false; 3018 } 3019 }); 3020 //eof init part ( consent mode) 3021 3022 //bof consent mode - click event 3023 if( only_init_status == false ) 3024 { 3025 that.settingsModal.querySelectorAll( '.map-consent-mode-preference-checkbox' ).forEach(function($this) { 3026 $this.addEventListener('click', function(e) { 3027 3028 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-consent-mode-preference-checkbox click' ); 3029 3030 e.stopImmediatePropagation(); 3031 3032 var consent_key = $this.getAttribute( 'data-consent-key' ); 3033 3034 var currentToggleElm = that.settingsModal.querySelectorAll( '.map-consent-mode-preference-checkbox[data-consent-key="' + consent_key + '"]' ); 3035 3036 if( $this.checked ) 3037 { 3038 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + `setting granted to consent_key=${consent_key}` ); 3039 3040 that.updateGoogleConsent( consent_key, 'granted', true ); 3041 3042 currentToggleElm.forEach( elm => elm.checked = true ); 3043 } 3044 else 3045 { 3046 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + `setting denied to consent_key=${consent_key}` ); 3047 3048 that.updateGoogleConsent( consent_key, 'denied', true ); 3049 3050 currentToggleElm.forEach( elm => elm.checked = false ); 3051 } 3052 3053 MAP_Cookie.set( MAP_ACCEPTED_SOMETHING_COOKIE_NAME, '1', MAP_SYS.map_cookie_expire ); 3054 MAP_Cookie.set( MAP_ACCEPTED_ALL_COOKIE_NAME, '-1', MAP_SYS.map_cookie_expire ); 3055 3056 that.updateSomeConsentGivenStatus(); 3057 3058 }); 3059 }); 3060 } 3061 //eof consent mode - click event 3062 3063 if( only_init_status == false ) 3064 { 3065 //bof iab part - click event 3066 that.settingsModal.addEventListener( 'click', function( e ) { 3067 3068 var $this = e.target; 3069 3070 if( $this.matches( '.map-user-iab-preference-checkbox' ) ) 3071 { 3072 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-u
3072ser-iab-preference-checkbox click' ); 3073 3074 e.stopImmediatePropagation(); 3075 3076 that.updateLastConsentRecords(); 3077 3078 var iab_category = $this.getAttribute( 'data-iab-category' ); 3079 var iab_key = $this.getAttribute( 'data-iab-key' ); 3080 3081 if( $this.checked ) 3082 { 3083 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + `setting 1 to iab_category=${iab_category} , iab_key=${iab_key}` ); 3084 3085 (async() => { 3086 while (!MAP_SYS.map_document_load) { 3087 // console.log( 'not defined yet' ); 3088 await new Promise(resolve => setTimeout(resolve, 10)); 3089 } 3090 3091 if( typeof window.MAPIABTCF_updateConsent === 'function' ) 3092 { 3093 let updateHtml = false; 3094 if( iab_category === 'googleVendors' ) updateHtml = true; 3095 3096 window.MAPIABTCF_doSetUserInteraction(); 3097 window.MAPIABTCF_updateConsent( iab_category, parseInt( iab_key ), true, true, updateHtml ); 3098 3099 that.updateSomeConsentGivenStatus(); 3100 } 3101 3102 })(); 3103 } 3104 else 3105 { 3106 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + `setting 0 to iab_category=${iab_category} , iab_key=${iab_key}` ); 3107 3108 (async() => { 3109 while (!MAP_SYS.map_document_load) { 3110 // console.log( 'not defined yet' ); 3111 await new Promise(resolve => setTimeout(resolve, 10)); 3112 } 3113 3114 if( typeof window.MAPIABTCF_updateConsent === 'function' ) 3115 { 3116 let updateHtml = false; 3117 if( iab_category === 'googleVendors' ) updateHtml = true; 3118 3119 window.MAPIABTCF_doSetUserInteraction(); 3120 window.MAPIABTCF_updateConsent( iab_category, parseInt( iab_key ), false, true, updateHtml ); 3121 3122 that.updateSomeConsentGivenStatus(); 3123 } 3124 3125 })(); 3126 } 3127 3128 /**/ 3129 } 3130 3131 }); 3132 //eof iab part - click event 3133 3134 //bof iab part - deny all / accept all event 3135 that.settingsModal.addEventListener( 'click', function( e ) { 3136 var target = e.target; 3137 if( target.matches( '.map-privacy-iab-tcf-accept-all-button' ) ) 3138 { 3139 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-privacy-iab-tcf-accept-all-button click' ); 3140 3141 e.preventDefault(); 3142 e.stopImmediatePropagation(); 3143 3144 that.updateLastConsentRecords(); 3145 3146 that.settingsModal.querySelectorAll( '.map-user-iab-preference-checkbox ').forEach(function( $_this ) { 3147 $_this.checked = true; 3148 }); 3149 3150 (async() => { 3151 while (!MAP_SYS.map_document_load) { 3152 // console.log( 'not defined yet' ); 3153 await new Promise(resolve => setTimeout( resolve, 10 )); 3154 } 3155 3156 if( typeof window.MAPIABTCF_acceptAllConsent === 'function' ) 3157 { 3158 window.MAPIABTCF_doSetUserInteraction(); 3159 window.MAPIABTCF_acceptAllConsent( true ); 3160 3161 that.updateSomeConsentGivenStatus(); 3162 } 3163 3164 })(); 3165 } 3166 }); 3167 3168 that.settingsModal.addEventListener( 'click', function( e ) { 3169 var target = e.target; 3170 if( target.matches( '.map-privacy-iab-tcf-deny-all-button' ) ) { 3171 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map-privacy-iab-tcf-deny-all-button' ); 3172 3173 e.preventDefault(); 3174 e.stopImmediatePropagation(); 3175 3176 that.updateLastConsentRecords(); 3177 3178 that.settingsModal.querySelectorAll( '.map-user-iab-preference-checkbox' ).forEach( function( $elem ) { 3179 $elem.checked = false; 3180 }); 3181 3182 (async() => { 3183 while (!MAP_SYS.map_document_load) { 3184 // console.log( 'not defined yet' ); 3185 await new Promise(resolve => setTimeout(resolve, 10)); 3186 } 3187 3188 if( typeof window.MAPIABTCF_denyAllConsent === 'function' ) 3189 { 3190 window.MAPIABTCF_doSetUserInteraction(); 3191 window.MAPIABTCF_denyAllConsent( true ); 3192 3193 that.updateSomeConsentGivenStatus(); 3194 } 3195 3196 })(); 3197 } 3198 }); 3199 //eof iab part - deny all / accept all event 3200 } 3201 3202 if( only_init_status == false ) 3203 { 3204 that.tryToUnblockScripts( false, null ); 3205 } 3206 3207 } 3208 catch( error ) 3209 { 3210 console.error( error ); 3211 } 3212 }, 3213 3214 showNotificationBar: function( message = null, success = null ) 3215 { 3216 try { 3217 3218 var body = document.querySelector( 'body' ); 3219 var bar = document.querySelector( '#mapx_notification_bar' ); 3220 3221 var prev_message = "<span class='mapx_close_notification_bar'>Close</span>"; 3222 3223 if( bar ) 3224 { 3225 prev_message = bar.innerHTML + "<br>"; 3226 } 3227 else 3228 {
3229 bar = document.createElement( 'div' ); 3230 bar.setAttribute( 'id','mapx_notification_bar' ); 3231 body.append( bar ); 3232 3233 3234 document.addEventListener( 'click', function (event) { 3235 if(!event.target.matches( '.mapx_close_notification_bar' )) return; 3236 3237 event.preventDefault(); 3238 3239 bar.parentNode.removeChild( bar ); 3240 3241 }, false); 3242 } 3243 3244 var final_message = prev_message + '<b>[MyAgilePrivacy admin-only notification]</b> ' + message; 3245 3246 if( success == 1 ) 3247 { 3248 final_message = final_message + ' <span class="mapx_proxification_success_true">OK!</span>'; 3249 } 3250 3251 if( success == 2 ) 3252 { 3253 final_message = final_message + ' <span class="mapx_proxification_success_false">ERROR!</span>'; 3254 } 3255 3256 if( success == null ) 3257 { 3258 final_message = final_message; 3259 } 3260 3261 bar.innerHTML = final_message; 3262 3263 } 3264 catch( error ) 3265 { 3266 console.error( error ); 3267 } 3268 3269 }, 3270 3271 administratorNotices: function() 3272 { 3273 try { 3274 3275 if( typeof MAP.settings !== 'undefined' && 3276 MAP.settings.internal_debug 3277 ) 3278 { 3279 if( !!MAP?.settings.scan_mode && 3280 MAP.settings.scan_mode == 'learning_mode' ) 3281 { 3282 const this_blocked_friendly_name = []; 3283 3284 if( map_full_config?.cookie_api_key_remote_id_map_active && 3285 typeof map_full_config.cookie_api_key_remote_id_map_active === 'object') 3286 { 3287 Object.entries( map_full_config.cookie_api_key_remote_id_map_active). 3288 forEach( ([key, value] ) => { 3289 3290 const friendlyName = map_full_config?.cookie_api_key_friendly_name_map?.[key]; 3291 3292 if( friendlyName?.desc ) 3293 { 3294 this_blocked_friendly_name.push( friendlyName?.desc ); 3295 } 3296 }); 3297 } 3298 3299 const this_blocked_friendly_name_unique = this_blocked_friendly_name.filter((v, i, a) => a.indexOf(v) === i); 3300 3301 if( this_blocked_friendly_name_unique.length ) 3302 { 3303 this.showNotificationBar( 'The Cookie Shield has detected the following cookies so far: ' +this_blocked_friendly_name_unique.join( ', ' ) + '.', null ); 3304 } 3305 else 3306 { 3307 this.showNotificationBar( 'The Cookie Shield has not detected any cookies.', null ); 3308 } 3309 } 3310 3311 if( !!MAP?.settings.scan_mode && 3312 MAP.settings.scan_mode == 'turned_off' ) 3313 { 3314 this.showNotificationBar( 'Cookie Shield is turned off. Enable it in order to block cookies.', null ); 3315 } 3316 } 3317 3318 } 3319 catch( error ) 3320 { 3321 console.error( error ); 3322 } 3323 }, 3324 3325 //slideUp equivalent function (hide) 3326 slideUp: function( target, duration=500, callback=null ) 3327 { 3328 try { 3329 3330 target.style.transitionProperty = 'height, margin, padding'; 3331 target.style.transitionDuration = duration + 'ms'; 3332 target.style.boxSizing = 'border-box'; 3333 target.style.height = target.scrollHeight + 'px'; 3334 target.offsetHeight; 3335 target.style.overflow = 'hidden'; 3336 target.style.height = 0; 3337 target.style.paddingTop = 0; 3338 target.style.paddingBottom = 0; 3339 target.style.marginTop = 0; 3340 target.style.marginBottom = 0; 3341 3342 window.setTimeout( () => { 3343 3344 try { 3345 3346 target.style.display = 'none'; 3347 target.style.removeProperty('height'); 3348 target.style.removeProperty('padding-top'); 3349 target.style.removeProperty('padding-bottom'); 3350 target.style.removeProperty('margin-top'); 3351 target.style.removeProperty('margin-bottom'); 3352 target.style.removeProperty('overflow'); 3353 target.style.removeProperty('transition-duration'); 3354 target.style.removeProperty('transition-property'); 3355 3356 } 3357 catch( error ) 3358 { 3359 console.error( error ); 3360 } 3361 3362 }, duration); 3363 3364 if( callback ) 3365 { 3366 3367 } 3368 3369 } 3370 catch( error ) 3371 { 3372 console.error( error ); 3373 } 3374 3375 }, 3376 3377 //slideDown equivalent function (show) 3378 slideDown: function( target, duration=500, callback=null ) 3379 { 3380 try { 3381 3382 target.style.removeProperty('display'); 3383 let display = window.getComputedStyle(target).display; 3384 3385 if( display === 'none' ) 3386 { 3387 display = 'block'; 3388 } 3389 3390 target.style.display = display; 3391 let height = target.scrollHeight; 3392 3393 target.style.overflow = 'hidden'; 3394 target.style.height = 0; 3395 target.style.paddingTop = 0; 3396 target.style.paddingBottom = 0; 3397 target.style.marginTop = 0; 3398 target.style.marginBottom = 0; 3399 target.offsetHeight; 3400 target.style.boxSizing = 'border-box'; 3401 target.style.transitionProperty = "height, margin, padding"; 3402 target.style.transitionDuration = duration + 'ms'; 3403 target.style.height = height + 'px'; 3404 target.style.removeProperty('padding-top'); 3405 target.style.removeProperty('padding-bottom'); 3406 target.style.removeProperty('margin-top'); 3407 target.style.removeProperty('margin-bottom'); 3408 3409 window.setTimeout( () => { 3410 3411 try { 3412 3413 target.style.removeProperty('height'); 3414 target.style.removeProperty('overflow'); 3415 target.style.removeProperty('transition-duration'); 3416 target.style.removeProperty('transition-property'); 3417 3418 } 3419 catch( error ) 3420 { 3421 console.error( error ); 3422 } 3423 3424 }, duration); 3425 3426 } 3427 catch( error ) 3428 {
3429 console.error( error ); 3430 } 3431 }, 3432 3433 //set overflow height 3434 setOverflowMaxHeight: function() 3435 { 3436 var that = this; 3437 3438 try { 3439 3440 var $overflow_container = document.querySelector( '.map-cookielist-overflow-container' ); 3441 3442 if( $overflow_container ) 3443 { 3444 let $map_tab_container = $overflow_container.parentNode; 3445 let parentHeight = $map_tab_container.offsetHeight; 3446 3447 let cookie_list_height = 0; 3448 3449 Array.from( $overflow_container?.children ).forEach( child => { 3450 3451 var style = window.getComputedStyle( child ); 3452 var marginTop = parseInt( style.marginTop, 10 ); 3453 var marginBottom = parseInt( style.marginBottom, 10 ); 3454 cookie_list_height += child.offsetHeight + marginTop + marginBottom; 3455 3456 }); 3457 3458 //add the minimum height of one expanded item 3459 cookie_list_height += 150; 3460 3461 let siblingsHeight = 0; 3462 3463 Array.from( $map_tab_container?.children ).forEach( child => { 3464 3465 if( child !== $overflow_container ) 3466 { 3467 var style = window.getComputedStyle( child ); 3468 var marginTop = parseInt( style.marginTop, 10 ); 3469 var marginBottom = parseInt( style.marginBottom, 10 ); 3470 siblingsHeight += child.offsetHeight + marginTop + marginBottom; 3471 } 3472 3473 }); 3474 3475 if( parentHeight > cookie_list_height ) 3476 { 3477 // parent height is too high --> recalculate 3478 $map_tab_container.style.height = siblingsHeight + cookie_list_height + 'px'; 3479 3480 } 3481 else 3482 { 3483 // need overflow and cookie list height recalculate 3484 3485 // set calculated max-height to .overflow-cookielist-container 3486 let maxHeight = parentHeight - siblingsHeight; 3487 3488 $overflow_container.style.maxHeight = maxHeight + 'px'; 3489 } 3490 3491 } 3492 3493 } 3494 catch( error ) 3495 { 3496 console.error( error ); 3497 } 3498 }, 3499 3500 setupAccordion: function() 3501 { 3502 //for preserving scope 3503 var that = this; 3504 3505 try { 3506 3507 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function setupAccordion' ); 3508 3509 that.setOverflowMaxHeight(); 3510 3511 that.settingsModal.addEventListener ('click', function( e ) { 3512 var $this = e.target; 3513 if( $this.matches( '.map_expandItem' ) ) 3514 { 3515 var $parent = $this.parentElement; 3516 3517 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'triggered map_expandItem click' ); 3518 3519 e.preventDefault(); 3520 e.stopImmediatePropagation(); 3521 3522 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + '.map-tab-header click' ); 3523 3524 var $content = $parent.nextElementSibling; 3525 3526 if( $parent.classList.contains( 'map-tab-active' ) ) 3527 { 3528 $parent.classList.remove( 'map-tab-active' ); 3529 that.slideUp( $content, 500 ); 3530 } 3531 else 3532 { 3533 if( !$this.classList.contains( 'map-contextual-expansion' ) ) 3534 { 3535 document.querySelectorAll( '.map-tab-header' ).forEach( function( $_this ) { 3536 3537 $_this.classList.remove( 'map-tab-active' ); 3538 }); 3539 3540 document.querySelectorAll( '.map-tab-content' ).forEach( function( $_this ) { 3541 if( $_this !== $content ) 3542 { 3543 that.slideUp( $_this, 500 ); 3544 } 3545 }); 3546 } 3547 3548 $parent.classList.add( 'map-tab-active' ); 3549 that.slideDown( $content, 500 ); 3550 } 3551 } 3552 }); 3553 3554 } 3555 catch( error ) 3556 { 3557 console.error( error ); 3558 } 3559 }, 3560 3561 closeSettingsPopup: function() 3562 { 3563 try { 3564 3565 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'internal function closeSettingsPopup' ); 3566 3567 this.settingsModal.classList.remove( 'map-show' ); 3568 this.settingsModal.classList.add( 'map-out' ); 3569 document.body.classList.remove( 'map-modal-open' ); 3570 document.querySelectorAll( '.map-settings-overlay' ).forEach(function( $_this ) { 3571 $_this.classList.remove( 'map-show' ); 3572 }); 3573 3574 (async() => { 3575 3576 while( !MAP_SYS.map_document_load ) 3577 { 3578 //console.log( 'not defined yet' ); 3579 await new Promise( resolve => setTimeout( resolve, 10 ) ); 3580 } 3581 3582 if( typeof window.MAPIABTCF_hideCMPUI === 'function' ) 3583 { 3584 window.MAPIABTCF_hideCMPUI(); 3585 } 3586 3587 })(); 3588 3589 } 3590 catch( error ) 3591 { 3592 console.error( error ); 3593 } 3594 }, 3595 3596 checkJsShield: function() 3597 { 3598 try { 3599 3600 if( !( typeof map_ajax !== 'undefined' && map_ajax?.ajax_url ) ) 3601 { 3602 console.error( MAP_SYS.maplog + 'Error: missing map_ajax variable running checkJsShield function' ); 3603 return; 3604 } 3605 3606 if( typeof CookieShield === 'undefined' || 3607 ( 3608 typeof cookie_api_key_remote_id_map_active === 'undefined' || 3609 typeof map_full_config?.cookie_api_key_remote_id_map_active === 'undefined' ) 3610 ) 3611 { 3612 var data = { 3613 action: 'map_missing_cookie_shield', 3614 detected: 0, 3615 }; 3616 3617 MAP_SYS.map_missing_cookie_shield = 1; 3618 } 3619 else 3620 {
3621 var data = { 3622 action: 'map_missing_cookie_shield', 3623 detected: 1, 3624 }; 3625 3626 MAP_SYS.map_missing_cookie_shield = 0; 3627 } 3628 3629 fetch( map_ajax.ajax_url, { 3630 method: 'POST', 3631 headers: { 3632 'Content-Type': 'application/x-www-form-urlencoded' 3633 }, 3634 body: new URLSearchParams( data ) 3635 }) 3636 .then( response => response.text() ) 3637 .then( responseText => { 3638 console.debug( MAP_SYS.maplog, responseText ); 3639 }) 3640 .catch( error => console.error( 'Error sending data running checkJsShield function:', error ) ); 3641 3642 } 3643 catch( error ) 3644 { 3645 console.error( error ); 3646 } 3647 }, 3648 3649 checkConsentModeStatus: function() 3650 { 3651 try { 3652 3653 if( !( typeof map_ajax !== 'undefined' && map_ajax?.ajax_url ) ) 3654 { 3655 console.error( MAP_SYS.maplog + 'Error: missing map_ajax variable running checkConsentModeStatus function' ); 3656 return; 3657 } 3658 3659 const googleTagRegex = /^(G-|UA-|AW-)/; 3660 let is_consent_valid = false; 3661 let has_valid_google_tag = false; 3662 let error_motivation = ''; 3663 let error_code = null; 3664 3665 // Check if Consent Mode is enabled 3666 if( !MAP_SYS?.cmode_v2 ) 3667 { 3668 error_motivation = 'Consent Mode V2 not enabled'; 3669 error_code = 10; 3670 } 3671 // Check if dataLayer is defined and not null 3672 else if( typeof dataLayer === 'undefined' || dataLayer === null ) 3673 { 3674 error_motivation = 'missing dataLayer'; 3675 error_code = 20; 3676 } 3677 else 3678 { 3679 for( let i = 0; i < dataLayer.length; i++ ) 3680 { 3681 const item = dataLayer[i]; 3682 3683 if( item && ( Array.isArray( item ) || typeof item === 'object' ) ) 3684 { 3685 const firstArg = item[0]; 3686 const secondArg = item[1]; 3687
3688 // Check for consent set 3689 if( firstArg === 'consent' && secondArg === 'default' ) 3690 { 3691 is_consent_valid = true; 3692 } 3693 3694 // Check for Google Tag config 3695 if( firstArg === 'config' && googleTagRegex.test( secondArg ) ) 3696 { 3697 has_valid_google_tag = true; 3698 } 3699 3700 // Validate that Google Tag configs aren't set before consent 3701 if( !is_consent_valid ) 3702 { 3703 if( ( firstArg === 'config' && googleTagRegex.test( secondArg ) ) || firstArg === 'event' ) 3704 { 3705 error_motivation = `Consent is set after Google tag ${secondArg} `; 3706 error_code = 30; 3707 break; 3708 } 3709 } 3710 } 3711 } 3712 3713 // Check if consent was never set 3714 if( !is_consent_valid && error_code === null && MAP_SYS?.cmode_v2_implementation_type != 'gtm' ) 3715 { 3716 error_motivation = 'No consent set before Google tags'; 3717 error_code = 40; 3718 } 3719 3720 // Check if no Google Tag was validated 3721 if( !has_valid_google_tag && MAP_SYS?.cmode_v2_implementation_type != 'gtm' ) 3722 { 3723 error_motivation = 'A valid Google Tag seems missing'; 3724 error_code = 50; 3725 } 3726 } 3727 3728 const result = { 3729 isValid: ( error_code === null ) ? true : false, 3730 reason: error_motivation, 3731 code: error_code 3732 }; 3733 3734 if( result.isValid ) 3735 { 3736 let the_message = 'The Consent Mode V2 is set up correctly.'; 3737 3738 console.log( MAP_SYS.maplog + the_message ); 3739 3740 //this.showNotificationBar( the_message, 1 ); 3741 } 3742 else 3743 { 3744 let the_message = 'The sending of consent is not set up correctly - ' + result.reason + '.'; 3745 3746 console.log( MAP_SYS.maplog + the_message ); 3747 3748 //this.showNotificationBar( the_message, 2 ); 3749 } 3750 3751 // Prepare data to be sent to the server 3752 const data = { 3753 action: 'map_check_consent_mode_status', 3754 is_consent_valid: ( result.isValid ) ? 1 : 0, 3755 error_motivation: result.reason, 3756 error_code: result.code 3757 }; 3758 3759 // Logic for sending data based on the conditions 3760 if( ( MAP_SYS.cmode_v2_js_on_error === true && result.isValid ) || 3761 ( MAP_SYS.cmode_v2_js_on_error === false && !result.isValid ) 3762 ) 3763 { 3764 fetch( map_ajax.ajax_url, { 3765 method: 'POST', 3766 headers: { 3767 'Content-Type': 'application/x-www-form-urlencoded' 3768 }, 3769 body: new URLSearchParams(data) 3770 }) 3771 .then(response => response.text()) 3772 .then(responseText => { 3773 console.debug( MAP_SYS.maplog, responseText ); 3774 }) 3775 .catch( error => console.error( 'Error sending data running checkConsentModeStatus function:', error ) ); 3776 } 3777 3778 } 3779 catch( error ) 3780 { 3781 console.error( error ); 3782 } 3783 }, 3784 3785 sendDetectedKeys: function( key ) 3786 { 3787 try { 3788 3789 if( !( typeof map_ajax !== 'undefined' && map_ajax?.ajax_url ) ) 3790 { 3791 console.error( MAP_SYS.maplog + 'Error: missing map_ajax variable running sendDetectedKeys function' ); 3792 return; 3793 } 3794 3795 if( typeof CookieShield !== 'undefined' && 3796 CookieShield ) 3797 { 3798 var detectableKeys = CookieShield.getDetectableKeys(); 3799 var detectedKeys = CookieShield.getDetectedKeys(); 3800 3801 MAP_SYS.map_detectableKeys = detectableKeys; 3802 MAP_SYS.map_detectedKeys = detectedKeys; 3803 3804 if( map_ajax ) 3805 { 3806 var detectableKeys_to_send = null; 3807 3808 if( detectableKeys && detectableKeys.length > 0 ) 3809 { 3810 detectableKeys_to_send = detectableKeys.join( ',' ); 3811 } 3812 3813 var detectedKeys_to_send = null; 3814 3815 if( detectedKeys && detectedKeys.length > 0 ) 3816 { 3817 detectedKeys_to_send = detectedKeys.join( ',' ); 3818 } 3819 3820 if( key ) 3821 { 3822 var data = { 3823 action: 'map_remote_save_detected_keys', 3824 key : key, 3825 detectableKeys: detectableKeys_to_send, 3826 detectedKeys: detectedKeys_to_send 3827 }; 3828 } 3829 else 3830 { 3831 var data = { 3832 action: 'map_save_detected_keys', 3833 detectableKeys: detectableKeys_to_send, 3834 detectedKeys: detectedKeys_to_send 3835 }; 3836 } 3837 3838 fetch(map_ajax.ajax_url, { 3839 method: 'POST', 3840 headers: { 3841 'Content-Type': 'application/x-www-form-urlencoded' 3842 }, 3843 body: new URLSearchParams( data ) 3844 }) 3845 .then( response => response.text() ) 3846 .then( responseText => { 3847 console.groupCollapsed( MAP_SYS.maplog + 'sendDetectedKeys detectableKeys=' + detectableKeys_to_send + ' , detectedKeys=' + detectedKeys_to_send + ' with response :' ); 3848 console.debug( MAP_SYS.maplog, responseText ); 3849 console.groupEnd(); 3850 }); 3851 } 3852 } 3853 3854 } 3855 catch( error ) 3856 {
3857 console.error( error ); 3858 } 3859 }, 3860 3861 //inspect cookie script configuration 3862 debugCookieScripts: function() 3863 { 3864 try { 3865 3866 var list = []; 3867 3868 var $scripts = document.querySelectorAll( 'script.my_agile_privacy_activate._js_noscript_type_mode, textarea.my_agile_privacy_activate._raw_type_mode'); 3869 3870 $scripts.forEach(function($this) { 3871 3872 var cookie_name = $this.getAttribute( 'data-cookie-name' ); 3873 var cookie_api_key = $this.getAttribute( 'data-cookie-api-key' ); 3874 3875 var code = null; 3876 var mode = null; 3877 3878 if( $this.classList.contains( '_js_noscript_type_mode' ) ) { 3879 mode = 'js_noscript'; 3880 code = $this.innerHTML; 3881 } 3882 3883 if( $this.classList.contains( '_raw_type_mode' ) ) { 3884 mode = 'raw'; 3885 code = $this.firstChild.nodeValue; 3886 } 3887 3888 var object = { 3889 'cookie_name': cookie_name, 3890 'cookie_api_key': cookie_api_key, 3891 'mode': mode, 3892 'code': code 3893 }; 3894 3895 list.push( object ); 3896 3897 }); 3898 3899 return list; 3900 3901 } 3902 catch( error ) 3903 { 3904 console.error( error ); 3905 } 3906 }, 3907 3908 //get list of available cookies 3909 getAvailableCookieList: function() 3910 { 3911 try { 3912 3913 var list = []; 3914 3915 var $my_agile_privacy_activated = document.querySelectorAll( '.map_cookie_description_wrapper' ); 3916 3917 $my_agile_privacy_activated.forEach( function( $this ) { 3918 3919 var cookie_name = $this.getAttribute( 'data-cookie-name' ); 3920 var cookie_api_key = $this.getAttribute( 'data-cookie-api-key' ); 3921 3922 if( cookie_api_key ) 3923 { 3924 list.push( cookie_api_key ); 3925 } 3926 else 3927 { 3928 list.push( cookie_name ); 3929 } 3930 3931 }); 3932 3933 return list; 3934 3935 } 3936 catch( error ) 3937 { 3938 console.error( error ); 3939 } 3940 }, 3941 3942 //get list of activated cookies 3943 getActivatedCookiesList: function() 3944 { 3945 try { 3946 3947 var list = []; 3948 3949 var $my_agile_privacy_activated = document.querySelectorAll( '.map_cookie_description_wrapper._is_activated' ); 3950 3951 $my_agile_privacy_activated.forEach(function( $this ) { 3952 3953 var cookie_name = $this.getAttribute( 'data-cookie-name' ); 3954 var cookie_api_key = $this.getAttribute( 'data-cookie-api-key' ); 3955 3956 if( cookie_api_key ) 3957 { 3958 list.push( cookie_api_key ); 3959 } 3960 else 3961 { 3962 list.push( cookie_name ); 3963 } 3964 3965 }); 3966 3967 return list; 3968 3969 } 3970 catch( error ) 3971 { 3972 console.error( error ); 3973 } 3974 }, 3975 3976 //get list of disactivated cookies 3977 getDisactivatedCookiesList: function() 3978 { 3979 try { 3980 3981 var list = []; 3982 3983 var $my_agile_privacy_activated = document.querySelectorAll( '.map_cookie_description_wrapper:not(._is_activated)' ); 3984 3985 $my_agile_privacy_activated.forEach( function( $this ) { 3986 3987 var cookie_name = $this.getAttribute( 'data-cookie-name' ); 3988 var cookie_api_key = $this.getAttribute( 'data-cookie-api-key' ); 3989 3990 if( cookie_api_key ) 3991 { 3992 list.push( cookie_api_key ); 3993 } 3994 else 3995 { 3996 list.push( cookie_name ); 3997 } 3998 3999 }); 4000 4001 return list; 4002 4003 } 4004 catch( error ) 4005 { 4006 console.error( error ); 4007 } 4008 } 4009} 4010 4011document.addEventListener('DOMContentLoaded', function() { 4012 4013 try { 4014 4015 if( window !== window.parent ) 4016 { 4017 console.debug( MAP_SYS.maplog + 'prevent run on iframe' ); 4018 return false; 4019 } 4020 4021 if( typeof map_cookiebar_settings !== 'undefined' ) 4022 { 4023 MAP_SYS.map_initted = true; 4024 4025 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'initting' ); 4026 4027 MAP.set({ 4028 settings : map_cookiebar_settings 4029 }); 4030 } 4031 4032 setTimeout( function() { 4033 4034 if( window !== window.parent ) 4035 { 4036 console.debug( MAP_SYS.maplog + 'prevent run on iframe' ); 4037 return false; 4038 } 4039 4040 if( !MAP_SYS.map_initted && 4041 typeof map_cookiebar_settings !== 'undefined' ) 4042 { 4043 try { 4044 4045 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'initting' ); 4046 4047 MAP.set({ 4048 settings : map_cookiebar_settings 4049 }); 4050 4051 MAP_SYS.map_initted = true; 4052 4053 } 4054 catch( error ) 4055 { 4056 console.error( error ); 4057 } 4058 } 4059 4060 }, 3000 ); 4061 4062 setTimeout( function() { 4063 4064 MAP_SYS.map_document_load = true; 4065 4066 }, 5000 ); 4067 4068 } 4069 catch( error ) 4070 { 4071 console.error( error ); 4072 } 4073 4074}); 4075 4076window.addEventListener('load', function() { 4077 4078 try { 4079 4080 MAP_SYS.map_document_load = true; 4081 4082 if( window !== window.parent ) 4083 { 4084 console.debug( MAP_SYS.maplog + 'prevent run on iframe' ); 4085 return false;
4086 } 4087 4088 if( !MAP_SYS.map_initted && 4089 typeof map_cookiebar_settings !== 'undefined' ) 4090 { 4091 4092 try { 4093 4094 if( MAP_SYS?.map_debug ) console.debug( MAP_SYS.maplog + 'initting' ); 4095 4096 MAP.set({ 4097 settings : map_cookiebar_settings 4098 }); 4099 4100 MAP_SYS.map_initted = true; 4101 4102 } 4103 catch( error ) 4104 { 4105 console.error( error ); 4106 } 4107 } 4108 4109 if( 4110 map_ajax && 4111 MAP.settings 4112 ) 4113 { 4114 MAP.checkJsShield(); 4115 4116 setTimeout( function() { 4117 MAP.checkConsentModeStatus(); 4118 }, 800 ); 4119 } 4120 4121 if( typeof CookieShield !== 'undefined' && 4122 CookieShield && 4123 MAP 4124 ) 4125 { 4126 if( 4127 map_ajax && 4128 MAP.settings && 4129 ( 4130 ( 4131 MAP.settings.scan_mode && 4132 MAP.settings.scan_mode == 'learning_mode' 4133 ) || 4134 ( 4135 map_ajax.force_js_learning_mode == 1 4136 ) 4137 ) 4138 ) 4139 { 4140 MAP.sendDetectedKeys( null ); 4141 } 4142 4143 if( typeof URLSearchParams !== 'undefined' && 4144 URLSearchParams ) 4145 { 4146 var queryString = window.location.search; 4147 4148 if( queryString ) 4149 { 4150 var urlParams = new URLSearchParams( queryString ); 4151 4152 var auto_activate_cookies_with_key = urlParams.get( 'auto_activate_cookies_with_key' ) 4153 if( auto_activate_cookies_with_key ) 4154 { 4155 MAP.sendDetectedKeys( auto_activate_cookies_with_key ); 4156 } 4157 } 4158 } 4159 } 4160 4161 } 4162 catch( error ) 4163 { 4164 console.error( error ); 4165 } 4166}); 4167 4168//f. for cloning node attribute to another (only valid attributes) 4169function cloneNodeAttributeToAnother( $source, dest ) 4170{ 4171 //console.log( $source ); 4172 //console.log( dest ); 4173 4174 var exclusion_list = [ 4175 'type', 4176 'src', 4177 'unblocked_src', 4178 'class', 4179 'data-cookie-api-key', 4180 'data-friendly_name' 4181 ]; 4182 4183 for( var att, i = 0, atts = $source.attributes, n = atts.length; i < n; i++ ) 4184 { 4185 att = atts[i]; 4186 4187 if( typeof att.nodeName !== 'undefined' && !exclusion_list.includes( att.nodeName ) ) 4188 { 4189 dest.setAttribute( att.nodeName, att.nodeValue ); 4190 } 4191 } 4192 4193 return dest; 4194} 4195 4196//f. for dom element recreating and previous event removal 4197function internalRecreateNode( el, withChildren ){ 4198 try { 4199 4200 if(withChildren) { 4201 el.parentNode.replaceChild(el.cloneNode(true), el); 4202 } 4203 else 4204 { 4205 var newEl = el.cloneNode(false); 4206 while (el.hasChildNodes()) newEl.appendChild(el.firstChild); 4207 el.parentNode.replaceChild(newEl, el); 4208 } 4209 } catch( e ) 4210 { 4211 console.debug( e ); 4212 } 4213} 4214 4215//wpcf7 4216function map_trigger_custom_patch_1() 4217{ 4218 console.debug( MAP_SYS.maplog + 'map_trigger_custom_patch_1' ); 4219 4220 try { 4221 internalRecreateNode( document.querySelector( 'form.wpcf7-form' ), true ); 4222 } 4223 catch (e) { 4224 console.debug( e ); 4225 } 4226 4227 const c = new CustomEvent("DOMContentLoaded", { 4228 }); 4229 document.dispatchEvent(c); 4230 4231 try { 4232 wpcf7.submit = null; 4233 } catch (e) { 4234 console.debug( e ); 4235 } 4236} 4237 4238//avia maps 4239function map_trigger_custom_patch_2() 4240{ 4241 console.debug( MAP_SYS.maplog + 'map_trigger_custom_patch_2' ); 4242 4243 document.querySelectorAll( '.av_gmaps_confirm_link.av_text_confirm_link.av_text_confirm_link_visible' ).forEach( function( element ) { 4244 element.click(); 4245 }); 4246 4247} 4248 4249//octorate 4250function map_trigger_custom_patch_3() 4251{ 4252 try { 4253 octorate.octobook.Widget.show(); 4254 } catch (e) { 4255 setTimeout( map_trigger_custom_patch_3, 100 ); 4256 console.debug( e ); 4257 } 4258} 4259 4260//consent mode early as possible initialization 4261if( typeof MAP !== 'undefined' && typeof MAP.setupConsentModeV2 !== 'undefined' ) 4262{ 4263 MAP.setupConsentModeV2(); 4264} 4265
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.