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