1function fupi_consb() { 2 3 'use strict'; 4 5 let notice = FP.findID('fupi_cookie_notice'), 6 toggler = FP.findID('fupi_notice_toggler'), 7 panel = {}, 8 setup_done = false, 9 cdb_cookie = []; 10 11 panel.welcome = FP.findID('fupi_welcome_panel'); 12 panel.settings = FP.findID('fupi_settings_panel'); 13 14 let activePanel = false, 15 priorFocus = false, 16 focusableElements = [], 17 firstTabStop = false, 18 lastTabStop = false, 19 a11y_buttons_ready = false; 20 21 function setup_notice(){ 22 23 // hidden 24 if ( fp.notice.mode == 'hide' ){ 25 26 actions_when_notif_is_hidden(); 27 28 // optin / optout 29 } else if ( fp.notice.mode == 'optin' || fp.notice.mode == 'optout' ) { 30 31 hide_popup_elements(); 32 show_popup_elements(); 33 add_events_to_notice_btns(); 34 35 if ( fpdata.cookies ) { 36 show_toggler(); 37 show_notice_on_link_click(true); // true == set switches 38 } else { 39 set_default_switches(); 40 if ( fp.main.track_current_user ) { 41 fp.notice.display_notice ? show_notice() : show_toggler(); 42 }; 43 show_notice_on_link_click(true); 44 }; 45 46 // notify 47 } else { 48 49 show_popup_elements(); 50 transform_notice_into_infobox(); 51 52 if ( fp.main.track_current_user && ! fpdata.cookies ) { 53 auto_agree_to_all_cookies(); 54 show_notice(); 55 }; 56 57 if ( FP.loadIframes ) FP.loadIframes(); // unblock iframes 58 59 add_events_to_ok_button(); 60 show_notice_on_link_click(); 61 } 62 63 setup_done = true; 64 } 65 66 // CDB 67 68 // Get a formatted date for display in the proof 69 function get_date() { 70 71 const now = new Date(); 72 73 // Get year, month, and day 74 const year = now.getFullYear();
75 const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed 76 const day = String(now.getDate()).padStart(2, '0'); 77 78 // Get hours, minutes, and seconds 79 const hours = String(now.getHours()).padStart(2, '0'); 80 const minutes = String(now.getMinutes()).padStart(2, '0'); 81 const seconds = String(now.getSeconds()).padStart(2, '0'); 82 83 // Format the date and time as YYYY-MM-DD HH:MM:SS 84 const formattedDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; 85 86 return formattedDateTime; 87 } 88 89 // Get timezone for display in the proof 90 function get_timezone(){ 91 let timezone_int = ( new Date().getTimezoneOffset() / 60 ) * -1; 92 return timezone_int >= 0 ? '+' + timezone_int : timezone_int + ''; 93 } 94 95 function get_timezoneName(){ 96 return Intl.DateTimeFormat().resolvedOptions().timeZone; 97 } 98 99 function can_save_consents(){ 100 if ( ! fp?.proofrec?.save_consent ) return false; 101 if ( ! fp?.proofrec?.save_all_consents && ( fpdata.is_robot || fpdata.activity.total == 0 ) ) return false; 102 return true; 103 } 104 105 function save_consent_id_in_cookie() { 106 107 // creates and saves cdb_id in a cookie 108 let cdb_id_cookie = FP.readCookie( 'cdb_id' ); 109 110 fp.notice.consent_times = [[fp.notice.consent_time, false]]; 111 fp.notice.cdb_id_confirmed = false; 112 113 // if is 1st consent 114 if ( ! cdb_id_cookie ) { 115 116 fp.notice.cdb_id = crypto && crypto.randomUUID ? crypto.randomUUID() : FP.getRandomStr(); 117 118 // if is consecutive consent 119 } else { 120 121 // if prev consent was prior to 8.5 122 // ( checks if cdb_id_cookie is not a stringified array ) 123 if ( cdb_id_cookie[0] != '[' ) { 124 fp.notice.cdb_id = cdb_id_cookie; 125 126 // if ver 8.5+, we add another consent time 127 } else { 128 cdb_id_cookie = JSON.parse( cdb_id_cookie ); 129 fp.notice.cdb_id = cdb_id_cookie[0]; 130 fp.notice.consent_times.push( ...cdb_id_cookie[1] ); 131 } 132 } 133 134 cdb_cookie = [ fp.notice.cdb_id, fp.notice.consent_times ]; 135 136 FP.setCookie( 'cdb_id', JSON.stringify( cdb_cookie ), 365 ); 137 }; 138 139 function mark_cdb_id_as_confirmed( server_response ){ 140 141 if ( typeof server_response == 'object' && server_response.CDB ) { 142 let cdb_response = JSON.parse(server_response.CDB); 143 if ( cdb_response.status == 'success' ) { 144 fp.notice.consent_times[0][1] = true; 145 FP.setCookie( 'cdb_id', JSON.stringify( [fp.notice.cdb_id, fp.notice.consent_times ] ), 365 ); 146 fp.notice.cdb_id_confirmed = true; 147 if ( fp.main.debug ) console.log('[FP] Consent saved in CDB'); 148 } 149 } 150 151 // Optionally reload page 152 if ( fp.notice.reload_page_after_saving_cdb ) { 153 if ( fp.main.debug ) console.log('[FP] Reloading page'); 154 location.reload(); 155 } 156 } 157 158 function save_preferences_in_cdb( prev_consents ) { 159 160 if ( ! can_save_consents() ) return; 161 162 if ( fp.main.debug ) console.log('[FP] Saving consent'); 163 164 let newCookieVal = fpdata.cookies; 165 166 fp.notice.consent_time = Date.now(); 167 fp.notice.cdb_waiting_for_response = true; 168 169 save_consent_id_in_cookie(); 170 171 let payload = newCookieVal; 172 173 payload['consentBannerMode'] = fp.notice.mode; 174 payload['previousConsents'] = prev_consents; 175 payload['geolocatedCountry'] = fp.main.geo && fpdata.country ? fpdata.country : 'Geolocation disabled'; 176 payload['cdbID'] = fp.notice.cdb_id; 177 payload['timestamp'] = fp.notice.consent_time; 178 179 if ( cdb_cookie.length > 0 ) { 180 181 let prev_cons_timestamps = []; 182 183 cdb_cookie[1].forEach( ( timestamp_arr, i ) => { 184 prev_cons_timestamps.push( timestamp_arr[0] ); 185 }); 186 187 if ( prev_cons_timestamps.length > 0 ) payload['previousConsentsTimestamps'] = prev_cons_timestamps; 188 } 189 190 // if ( prev_consents['statistics'] || prev_consents['marketing'] || prev_consents['personalisation'] ) payload['cookiesBeforeConsent'] = listCookies(); 191 192 let event_type = 'cdb', 193 event_id = false; 194 195 if ( fp?.proofrec?.storage_location == 'email' ) { 196 event_type = 'process'; 197 event_id = 'proofrec_db_save'; 198 } 199 200 FP.postToServer( [[ event_type, event_id, payload ]], mark_cdb_id_as_confirmed ); // if callback will not fire, then cdb_id will still be set by the fallback in maybe_wait_to_reload_page() 201 } 202 203 // SETUP CONSENT BANNER 204 205 // fire on load 206 if ( fp.ready ) setup_notice(); 207 208 // fire after each fp_load_event (can be also triggered by clicking "agree" buttons below) 209 document.addEventListener( 'fp_load_scripts', e=>{ 210 if ( ! setup_done && fp.ready ) setup_notice(); 211 // hide the notice if the user agreed or declined cookies in a different tab 212 if ( fpdata.cookies && notice.classList.contains('fupi_fadeInUp') ) { 213 show_toggler(); 214 hide_notice_wrapper(); 215 remove_blur(); 216 remove_scroll_lock(); 217 } 218 } ) 219 220 // FUNCTIONS 221 222 function update_tools_consents(){ 223 224 let permissions = {
225 'analytics_storage': fpdata.cookies.stats ? 'granted' : 'denied', 226 'personalization_storage' : fpdata.cookies.personalisation ? 'granted' : 'denied', 227 'ad_storage' : fpdata.cookies.marketing ? 'granted' : 'denied', 228 'ad_user_data' : fpdata.cookies.marketing ? 'granted' : 'denied', 229 'ad_personalization' : fpdata.cookies.marketing ? 'granted' : 'denied', 230 'functionality_storage' : fpdata.cookies.personalisation ? 'granted' : 'denied', 231 }; 232 233 fpdata.consents = { 234 'can_track_stats' : fpdata.cookies.stats || false, 235 'can_track_pers' : fpdata.cookies.personalisation || false, 236 'can_track_market' : fpdata.cookies.marketing || false, 237 } 238 239 // update in dataLayer 240 241 window.gtag( 'consent', 'update', permissions ); 242 window.dataLayer.push( { 243 'event' : 'fp_privacyPreferencesChanged', 244 'fp_visitorPrivacyPreferences' : fpdata.cookies, 245 } ); 246 247 // update in fupi_dataLayer 248 249 if ( window.fupi_gtm_gtag ) window.fupi_gtm_gtag( 'consent', 'update', permissions ); 250 251 if ( window.fupi_dataLayer ) { 252 window.fupi_dataLayer.push( { 253 'event' : 'fp_privacyPreferencesChanged', 254 'fp_visitorPrivacyPreferences' : fpdata.cookies, 255 } ); 256 } 257 258 // MS Ads 259 window.uetq.push( 'consent', 'update', {'ad_storage': permissions['ad_storage'] } ); 260 261 // MS CLARITY 262 if ( window.clarity ) { 263 fpdata.cookies.stats ? window.clarity('consent') : window.clarity('consent', false); 264 } 265 266 // Pixel Manager 267 if ( fp.notice.scrblk_auto_rules && fp.notice.scrblk_auto_rules.includes('pixelman') ){ 268 window._pmwq = window._pmwq || []; 269 window._pmwq.push(function() { 270 if ( fpdata.cookies && !! window?.pmw?.consent?.api?.updateSelectively ) { 271 pmw.consent.api.updateSelectively({ 272 statistics: fpdata.cookies.stats, 273 marketing: fpdata.cookies.marketing, 274 preferences: fpdata.cookies.personalisation, 275 necessary: true, 276 }); 277 console.log("[FP] Updated tracking consents for Pixel Manager"); 278 } 279 }); 280 } 281 282 if ( fp.main.debug ) console.log('[FP] Consents updated', permissions); 283 } 284 285 function hide_popup_elements(){ 286 if ( fp.notice.hidden.length > 0 ) { 287 fp.notice.hidden.forEach( el=> { 288 switch ( el ) { 289 290 case 'settings_btn': 291 FP.findID('fupi_cookie_settings_btn').style.display = 'none'; 292 break; 293 294 case 'decline_btn': 295 if ( ! fp.notice.auto_mode ) FP.findID('fupi_decline_cookies_btn').style.display = 'none'; 296 break; 297 298 case 'stats': 299 let stats_sect = FP.findID('fupi_stats_section'); 300 if (stats_sect) stats_sect.style.display = 'none'; 301 break; 302 303 case 'market': 304 let market_sect = FP.findID('fupi_market_section'); 305 if ( market_sect ) market_sect.style.display = 'none'; 306 break; 307 308 case 'pers': 309 let pers_sect = FP.findID('fupi_pers_section'); 310 if ( pers_sect ) pers_sect.style.display = 'none'; 311 break; 312 } 313 } ) 314 } 315 } 316 317 function show_popup_elements(){ 318 if ( fp.notice.shown.length > 0 ) { 319 fp.notice.shown.forEach( el=> { 320 switch ( el ) { 321 case 'powered_by': 322 FP.findAll('.fupi_poweredBy').forEach( el => el.style.display = 'block' ); 323 break; 324 case 'stats_only_btn': 325 if ( fp.notice.mode !== 'notify' ) FP.findID('fupi_stats_only_btn').style.display = 'block'; 326 break; 327 } 328 } ) 329 } 330 } 331 332 function transform_notice_into_infobox(){ 333 var html_el = document.getElementsByTagName( 'html' )[0]; 334 html_el.classList.add('fupi_infobox'); // removes blur and doesn't let scroll locking 335 notice.classList.add('fupi_notice_infobox'); 336 } 337 338 function remove_blur() { 339 setTimeout( function(){ 340 var html_el = document.getElementsByTagName( 'html' )[0]; 341 if( html_el.classList.contains('fupi_blur') ) { 342 html_el.classList.remove('fupi_blur'); 343 html_el.classList.add('fupi_blur_out'); 344 } 345 }, 300 ); 346 } 347 348 function lock_scroll() { 349 if ( fp.notice.scroll_lock ) { 350 var html_el = document.getElementsByTagName( 'html' )[0]; 351 if ( ! html_el.classList.contains('fupi_infobox') ) {
352 html_el.classList.add('fupi_scroll_lock'); 353 } 354 } 355 } 356 357 function remove_scroll_lock(){ 358 if ( fp.notice.scroll_lock ) { 359 var html_el = document.getElementsByTagName( 'html' )[0]; 360 html_el.classList.remove('fupi_scroll_lock'); 361 } 362 } 363 364 function show_notice_on_link_click( set_switches = false ){ 365 366 let show_notice_links = FP.findAll( fp.notice.toggle_selector ); 367 368 show_notice_links.forEach(function(link) { 369 370 link.addEventListener('click', function(e) { 371 372 e.preventDefault(); 373 374 hide_toggler(); 375 notice.classList.add( 'fupi_changing_preferences' ); // hides "return button" but shows the close button 376 377 priorFocus = document.activeElement; 378 379 if ( set_switches ) set_switches_state(); 380 381 add_consent_id_to_banner(); 382 383 show_notice_wrapper(); 384 385 if ( fp.notice.mode == 'notify' ){ 386 show_panel('welcome'); 387 } else { 388 panel.settings ? show_panel('settings') : show_panel('welcome'); 389 } 390 391 if ( ! a11y_buttons_ready ) a11y_buttons( true ); 392 }); 393 }); 394 } 395 396 function add_consent_id_to_banner(){ 397 398 let cookie_val = FP.readCookie( 'cdb_id' ), 399 cdb_id = false, 400 consent_info_boxes = FP.findAll('.fupi_consent_info'); // one on each CB panel 401 402 if ( ! ( fp?.proofrec?.save_consent && cookie_val && consent_info_boxes.length > 0 && fpdata.cookies && fpdata.cookies.time && fpdata.cookies.timezone ) ) return; 403 404 // if consent was prior to 8.5 405 // ( checks if cookie_val is not a STRINGified array ) 406 if ( cookie_val[0] != '[' ) { 407 408 cdb_id = cookie_val; 409 410 // fill in the HTML box 411 consent_info_boxes.forEach( box => { 412 413 let id_el = FP.findFirst( '.fupi_consent_id', box ); 414 if ( id_el ) id_el.innerHTML = cdb_id; 415 416 let date_el = FP.findFirst( '.fupi_consent_date', box ); 417 if ( date_el ) date_el.innerHTML = fpdata.cookies.time + ' (' + fpdata.cookies.timezone + ')'; 418 419 box.classList.remove('fupi_hidden'); 420 }); 421 422 // if ver 8.5+, we add another consent time 423 } else { 424 425 cookie_val = JSON.parse( cookie_val ); 426 cdb_id = cookie_val[0]; 427 428 let cons_times_a = cookie_val[1]; 429 430 // fill in the HTML box 431 432 consent_info_boxes.forEach( box => { 433 434 let id_el = FP.findFirst( '.fupi_consent_id', box ), 435 is_consent_saved = cons_times_a[0][1], 436 consentID = cdb_id + '_' + cons_times_a[0][0]; 437 438 if ( id_el ) { 439 440 // maybe add a link to ConsentsDB 441 id_el.innerHTML = fp?.proofrec?.consent_access && fp?.proofrec?.storage_location == 'cdb' && is_consent_saved ? '<a href="https://consentsdb.com/public/consent/' + consentID + '" target="_blank">' + consentID + '</a>' : consentID; 442 } 443 444 let date_el = FP.findFirst( '.fupi_consent_date', box ); 445 if ( date_el ) date_el.innerHTML = fpdata.cookies.time + ' (' + fpdata.cookies.timezone + ')'; 446 447 box.classList.remove('fupi_hidden'); 448 }); 449 } 450 } 451 452 function set_default_switches(){ 453 454 if ( fp.notice.preselected_switches.length > 0 && ( fp.notice.mode == 'optout' || fp.notice.optin_switches ) ){ 455 456 if ( fp.notice.preselected_switches.includes('stats') ){ 457 let stats_switch = FP.findFirst('#fupi_stats_section .fupi_switch'); 458 if ( stats_switch ) stats_switch.click(); 459 }; 460 461 if ( fp.notice.preselected_switches.includes('market') ){ 462 let market_switch = FP.findFirst('#fupi_market_section .fupi_switch'); 463 if ( market_switch ) market_switch.click(); 464 }; 465 466 if ( fp.notice.preselected_switches.includes('pers') ){ 467 let pers_switch = FP.findFirst('#fupi_pers_section .fupi_switch'); 468 if ( pers_switch ) pers_switch.click(); 469 }; 470 } 471 } 472 473 function set_switches_state() { 474 var switches = FP.findAll(".fupi_switch input"); 475 476 if(switches.length > 0) { 477 switches.forEach(function(the_switch) { 478 if( fpdata.cookies && fpdata.cookies[the_switch.value]) the_switch.checked = true; 479 }); 480 } 481 } 482 483 function add_events_to_notice_btns() { 484 485 let accept_all_btn = FP.findID('fupi_agree_to_all_cookies_btn'), 486 decline_btn = FP.findID('fupi_decline_cookies_btn'), 487 cookie_settings_btn = FP.findID('fupi_cookie_settings_btn'),
488 accept_stats_btn = FP.findID('fupi_stats_only_btn'), 489 accept_chosen_btn = FP.findID('fupi_agree_to_selected_cookies_btn'), 490 return_btn = FP.findID('fupi_return_btn'), 491 close_banner_btns = FP.findAll('.fupi_close_banner_btn'), 492 switches = FP.findAll('.fupi_switch'); 493 494 if ( accept_all_btn ) { 495 accept_all_btn.addEventListener('click', function(){ 496 497 // hide all 498 hide_panel('welcome'); 499 show_toggler(); 500 hide_notice_wrapper(); 501 remove_blur(); 502 remove_scroll_lock(); 503 504 // save cookies and fire events 505 if ( fp.main.track_current_user ) accept_all_cookies_and_fire_custom_event(); 506 if ( FP.loadIframes ) FP.loadIframes(); // unblock iframes 507 }); 508 } 509 510 if ( accept_stats_btn ) { 511 accept_stats_btn.addEventListener('click', function(){ 512 513 // hide all 514 hide_panel('welcome'); 515 show_toggler(); 516 hide_notice_wrapper(); 517 remove_blur(); 518 remove_scroll_lock(); 519 520 // save cookies and fire events 521 if ( fp.main.track_current_user ) accept_stats_cookies_and_fire_custom_event(); 522 if ( FP.loadIframes ) FP.loadIframes(); // unblock iframes 523 }) 524 } 525 526 if ( decline_btn ) { 527 decline_btn.addEventListener('click', function(){ 528 529 // hide all 530 hide_panel('welcome'); 531 show_toggler(); 532 hide_notice_wrapper(); 533 remove_blur(); 534 remove_scroll_lock(); 535 536 // save cookies and fire events 537 decline_all_cookies(); 538 }); 539 } 540 541 if ( accept_chosen_btn ) { 542 accept_chosen_btn.addEventListener('click', function(){ 543 544 // hide all 545 hide_panel('settings'); 546 show_toggler(); 547 hide_notice_wrapper(); 548 remove_blur(); 549 remove_scroll_lock(); 550 551 // save cookies and fire events 552 if ( fp.main.track_current_user ) accept_chosen_cookies_and_fire_custom_events(); 553 if ( FP.loadIframes ) FP.loadIframes(); 554 }); 555 } 556 557 if ( cookie_settings_btn ) { 558 cookie_settings_btn.addEventListener('click', function() { 559 hide_panel('welcome'); 560 show_panel('settings'); 561 }); 562 } 563 564 if ( return_btn ) { 565 return_btn.addEventListener('click', function() { 566 hide_panel('settings'); 567 show_panel('welcome'); 568 }); 569 } 570 571 close_banner_btns.forEach( btn => { 572 btn.addEventListener('click', function() { 573 hide_panel('welcome'); 574 hide_panel('settings'); 575 show_toggler(); 576 hide_notice_wrapper(); 577 remove_blur(); 578 remove_scroll_lock(); 579 }); 580 }) 581 582 switches.forEach(function(the_switch) { 583 the_switch.addEventListener('click', function(e) { 584 toggle_switch(e.target); 585 }, false); 586 }); 587 588 } 589 590 function get_prev_consents(){ 591 return { 592 'statistics' : fpdata?.cookies?.stats, 593 'marketing' : fpdata?.cookies?.marketing, 594 'personalisation' : fpdata?.cookies?.personalisation 595 } 596 } 597 598 function auto_agree_to_all_cookies(){ // auto triggered when the notice is in "notify" mode 599 600 fpdata.cookies = { 601 'stats': true, 602 'personalisation': true, 603 'marketing': true, 604 'disabled': false, 605 'pp_pub' : fp.notice.priv_policy_update, 606 'tools' : fp.tools, 607 'time' : get_date(), 608 'timezone' : get_timezone(), 609 'timezoneName' : get_timezoneName(), 610 }; 611 612 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 613 } 614 615 function add_events_to_ok_button(){ // triggered when consent banner only notifies 616 617 let agree_btn = FP.findID('fupi_agree_to_all_cookies_btn'); 618 619 if( agree_btn ) { 620 agree_btn.addEventListener('click', function(){ 621 622 hide_panel('welcome'); 623 hide_notice_wrapper(); 624 remove_blur(); 625 remove_scroll_lock(); 626 }); 627 } 628 } 629 630 function actions_when_notif_is_hidden(){ 631 632 // remove blur & scroll lock 633 634 var html_el = document.getElementsByTagName( 'html' )[0]; 635 636 html_el.classList.remove('fupi_blur'); 637 638 if ( fp.notice.scroll_lock ) { 639 html_el.classList.remove('fupi_scroll_lock'); 640 document.body.style.overflowY = 'auto'; 641 } 642 643 // save cookies 644 645 if ( ! fpdata.cookies ) { 646 647 fpdata.cookies = { 648 'stats': true, 649 'personalisation': true, 650 'marketing': true, 651 'disabled': false, 652 'pp_pub' : fp.notice.priv_policy_update, 653 'tools' : fp.tools, 654 'time' : get_date(), 655 'timezone' : get_timezone(), 656 'timezoneName' : get_timezoneName(), 657 }; 658 659 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 660 update_tools_consents(); 661 } 662 663 if ( FP.loadIframes ) FP.loadIframes(); // unblock iframes 664 } 665 666 // ACCESSIBLE SWITCH 667 // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Switch_role 668 669 function toggle_switch(target) { 670 if(target.getAttribute("aria-checked") == "true") { 671 target.setAttribute("aria-checked", "false"); 672 } else { 673 target.setAttribute("aria-checked", "true"); 674 } 675 } 676 677 function accept_all_cookies_and_fire_custom_event() { 678 679 let prev_consents = get_prev_consents(); 680 681 // this is the default when the settings panel is hidden (we set everything to true) 682 fpdata.cookies = { 683 'stats': true, 684 'personalisation': true, 685 'marketing': true, 686 'disabled': false, 687 'pp_pub' : fp.notice.priv_policy_update, 688 'tools' : fp.tools, 689 'time' : get_date(), 690 'timezone' : get_timezone(), 691 'timezoneName' : get_timezoneName(), 692 }; 693 694 if ( panel.settings ){ // when the settings panel is visible, we set to true only those cookies which settings are not hidden 695
696 let stats = !!FP.findID('fupi_stats_agree'), 697 perso = !!FP.findID('fupi_pers_agree'), 698 marke = !!FP.findID('fupi_marketing_agree'); 699 700 fpdata.cookies = { 701 'stats': stats, 702 'personalisation': perso, 703 'marketing': marke, 704 'disabled': false, 705 'pp_pub' : fp.notice.priv_policy_update, 706 'tools' : fp.tools, 707 'time' : get_date(), 708 'timezone' : get_timezone(), 709 'timezoneName' : get_timezoneName(), 710 }; 711 } 712 713 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 714 715 save_preferences_in_cdb( prev_consents ); 716 717 FP.updateSessionData(); 718 719 FP.sendEvt( 'fp_load_scripts' ); 720 FP.sendEvt( 'fupi_consents_changed', 'all accepted') ; 721 722 update_tools_consents(); 723 } 724 725 function accept_stats_cookies_and_fire_custom_event(){ 726 727 let prev_consents = get_prev_consents(); 728 729 // this is the default when the settings panel is hidden (we set everything to true) 730 fpdata.cookies = { 731 'stats': true, 732 'personalisation': false, 733 'marketing': false, 734 'disabled': false, 735 'pp_pub' : fp.notice.priv_policy_update, 736 'tools' : fp.tools, 737 'time' : get_date(), 738 'timezone' : get_timezone(), 739 'timezoneName' : get_timezoneName(), 740 }; 741 742 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 743 744 save_preferences_in_cdb( prev_consents ); 745 746 FP.updateSessionData(); 747 748 FP.sendEvt( 'fp_load_scripts' ); 749 FP.sendEvt( 'fupi_consents_changed', 'stats accepted') ; 750 751 update_tools_consents(); 752 } 753 754 function check_if_needs_a_reload(){ 755 return fp.loaded.some( el => el !== 'woo' && el !== 'gtm' && el !== 'gtg' && el !== 'ga41' && el !== 'ga42' && el !== 'gads'); 756 } 757 758 function accept_chosen_cookies_and_fire_custom_events() { 759 760 let stats_checkbox = FP.findID('fupi_stats_agree'), 761 perso_checkbox = FP.findID('fupi_pers_agree'), 762 marke_checkbox = FP.findID('fupi_marketing_agree'), 763 needs_a_reload = check_if_needs_a_reload(), // checks for scripts that do not adjust its behavior depending on consents 764 prev_consents = get_prev_consents(); 765 766 fp.notice.reload_page_after_saving_cdb = needs_a_reload; 767 768 fpdata.cookies = { 769 'stats': stats_checkbox ? stats_checkbox.checked : false, 770 'personalisation': perso_checkbox ? perso_checkbox.checked : false, 771 'marketing': marke_checkbox ? marke_checkbox.checked : false, 772 'disabled': false, 773 'pp_pub' : fp.notice.priv_policy_update, 774 'tools' : fp.tools, 775 'time' : get_date(), 776 'timezone' : get_timezone(), 777 'timezoneName' : get_timezoneName(), 778 }; 779 780 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 781 782 save_preferences_in_cdb( prev_consents ); 783 784 FP.updateSessionData(); 785 786 if ( needs_a_reload ) { 787 update_tools_consents(); 788 maybe_wait_to_reload_page(); 789 } else { 790 FP.sendEvt( 'fp_load_scripts' ); 791 FP.sendEvt( 'fupi_consents_changed', 'some accepted' ); 792 update_tools_consents(); 793 } 794 } 795 796 function decline_all_cookies() { 797 798 if ( ! fp.main.track_current_user ) return; 799 800 let needs_a_reload = check_if_needs_a_reload(), 801 prev_consents = get_prev_consents(); 802 803 fp.notice.reload_page_after_saving_cdb = needs_a_reload; 804 805 fpdata.cookies = { 806 'stats': false, 807 'personalisation': false, 808 'marketing': false, 809 'disabled': false, 810 'pp_pub' : fp.notice.priv_policy_update, 811 'tools' : fp.tools, 812 'time' : get_date(), 813 'timezone' : get_timezone(), 814 'timezoneName' : get_timezoneName(), 815 }; 816 817 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 818 819 save_preferences_in_cdb( prev_consents ); 820 821 FP.updateSessionData(); 822 823 FP.sendEvt('fupi_consents_changed', 'declined'); 824 update_tools_consents(); 825 826 if ( needs_a_reload ) { 827 maybe_wait_to_reload_page(); 828 } 829 } 830 831 function maybe_wait_to_reload_page(){ 832 // if we should wait for server response 833 if ( fp.notice.cdb_waiting_for_response ) { 834 setTimeout( function() { 835 if (fp.main.debug ) console.log('[FP] Waiting for CDB server response before reloading the page'); 836 if ( ! fp.notice.cdb_id_confirmed ) { 837 if ( fp.main.debug ) console.log('[FP] Reloading page after timeout'); 838 location.reload(); 839 } 840 }, 2000 ); // this is max wait time. The reload is also triggered by the FP.postToServer script 841 } else { 842 location.reload(); 843 } 844 } 845 846 function update_buttons_focus(){ 847 focusableElements = FP.findAll('a[href]:not(.fupi_poweredBy_link), input:not([disabled]), button:not([disabled]), [tabindex="0"], [contenteditable]', panel[activePanel] ),
848 firstTabStop = focusableElements[0]; 849 lastTabStop = focusableElements[focusableElements.length - 1]; 850 // focus first element 851 firstTabStop.focus(); 852 } 853 854 function show_panel(type) { 855 856 if ( panel[type] ) { 857 858 activePanel = type; 859 860 // focus on the first button 861 FP.findFirst('button', panel[type]).focus(); 862 863 panel[type].classList.remove('fupi_fadeOutDown'); 864 panel[type].classList.remove('fupi_hidden'); 865 panel[type].classList.add('fupi_animated'); 866 panel[type].classList.add('fupi_fadeInUp'); 867 868 update_buttons_focus( panel[type] ); 869 } 870 } 871 872 function hide_panel( type ) { 873 874 if ( ! panel[type] ) return; 875 876 panel[type].classList.remove('fupi_fadeInUp'); 877 panel[type].classList.add('fupi_animated'); 878 panel[type].classList.add('fupi_fadeOutDown'); 879 } 880 881 function show_toggler(){ 882 if ( toggler && fp.notice.mode !== 'hidden' && fp.notice.mode !== 'notify' ) { 883 toggler.setAttribute("style",""); 884 toggler.classList.add( 'fupi_active', 'fupi_fadeInUp' ); 885 toggler.classList.remove( 'fupi_fadeOutDown' ); 886 } 887 } 888 889 function hide_toggler(){ 890 if ( toggler && toggler.classList.contains('fupi_active') ) { 891 toggler.classList.remove( 'fupi_fadeInUp'); 892 toggler.classList.add( 'fupi_fadeOutDown' ); 893 } 894 } 895 896 function show_notice_wrapper() { 897 notice.setAttribute("style",""); 898 notice.classList.remove('fupi_fadeOutDown'); 899 notice.classList.remove('fupi_hidden'); 900 notice.classList.add('fupi_fadeInUp'); 901 notice.classList.add('fupi_animated'); 902 } 903 904 function hide_notice_wrapper() { 905 notice.classList.remove('fupi_fadeInUp'); 906 notice.classList.add('fupi_fadeOutDown'); 907 priorFocus.focus(); 908 } 909 910 function a11y_buttons( opened_with_link ){ // accessibility buttons 911 912 a11y_buttons_ready = true; 913 914 document.addEventListener("keydown", e => { 915 916 // Escape key returns to welcome panel or closes the modal 917 if ( e.keyCode === 27 || e.code === 27 || e.key === 27 ) { 918 if ( activePanel == 'welcome' ){ 919 hide_panel('welcome'); 920 show_toggler(); 921 hide_notice_wrapper(); 922 remove_blur(); 923 remove_scroll_lock(); 924 if ( fp.notice.mode != 'notify' && ! opened_with_link ) { 925 decline_all_cookies(); 926 } 927 } else if ( activePanel == 'settings' ) { 928 hide_panel('settings'); 929 show_panel('welcome'); 930 } 931 } 932 933 // Keeps focus within panels when tab is clicked 934 if ( activePanel && ( e.keyCode === 9 || e.code === 9 || e.key === 9 ) ) { 935 // if shift is clicked with tab (reverse tabbing) 936 if (e.shiftKey) { 937 // do not go any further back if we are on the first element 938 if ( firstTabStop && document.activeElement === firstTabStop) e.preventDefault(); 939 940 // if next element is to be focused 941 } else { 942 if ( lastTabStop && document.activeElement === lastTabStop) { 943 e.preventDefault(); 944 lastTabStop.focus(); 945 } 946 } 947 } 948 949 }); 950 } 951 952 function show_notice() { 953 954 priorFocus = document.activeElement; 955 956 lock_scroll(); 957 show_notice_wrapper(); 958 show_panel('welcome'); 959 960 if ( ! a11y_buttons_ready ) a11y_buttons(); 961 } 962 963 FP.loaded('cons_banner'); 964 965}; 966 967if ( fp.main.is_bricks_builder ) { 968 FP.load('cons_banner', 'fupi_consb', ['footer_helpers', 'consb_html']); 969} else { 970 FP.load('cons_banner', 'fupi_consb', ['footer_helpers', 'consb_html', 'iframes_blocker']); 971}
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.