1(function() { 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.manageIframes ) FP.manageIframes(); // 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 dataLayer = window.dataLayer || window.fupi_dataLayer, 225 permissions = {
226 'analytics_storage': fpdata.cookies.stats ? 'granted' : 'denied', 227 'personalization_storage' : fpdata.cookies.personalisation ? 'granted' : 'denied', 228 'ad_storage' : fpdata.cookies.marketing ? 'granted' : 'denied', 229 'ad_user_data' : fpdata.cookies.marketing ? 'granted' : 'denied', 230 'ad_personalization' : fpdata.cookies.marketing ? 'granted' : 'denied', 231 'functionality_storage' : fpdata.cookies.personalisation ? 'granted' : 'denied', 232 }; 233 234 fpdata.consents = { 235 'can_track_stats' : fpdata.cookies.stats || false, 236 'can_track_pers' : fpdata.cookies.personalisation || false, 237 'can_track_market' : fpdata.cookies.marketing || false, 238 } 239 240 // Google 241 242 window.gtag( 'consent', 'update', permissions ); 243 if ( fp.gtm && fp.gtm.datalayer == 'fupi_dataLayer' && window.fupi_gtm_gtag ) window.fupi_gtm_gtag( 'consent', 'update', permissions ); 244 245 if ( dataLayer ) dataLayer.push( { 246 'event' : 'fp_privacyPreferencesChanged', 247 'fp_visitorPrivacyPreferences' : fpdata.cookies, 248 } ); 249 250 // MS Ads 251 window.uetq.push( 'consent', 'update', {'ad_storage': permissions['ad_storage'] } ); 252 253 // MS CLARITY 254 if ( window.clarity ) { 255 fpdata.cookies.stats ? window.clarity('consent') : window.clarity('consent', false); 256 } 257 258 if ( fp.main.debug ) console.log('[FP] Consents updated', permissions); 259 } 260 261 function hide_popup_elements(){ 262 if ( fp.notice.hidden.length > 0 ) { 263 fp.notice.hidden.forEach( el=> { 264 switch ( el ) { 265 266 case 'settings_btn': 267 FP.findID('fupi_cookie_settings_btn').style.display = 'none'; 268 break; 269 270 case 'decline_btn': 271 if ( ! fp.notice.auto_mode ) FP.findID('fupi_decline_cookies_btn').style.display = 'none'; 272 break; 273 274 case 'stats': 275 let stats_sect = FP.findID('fupi_stats_section'); 276 if (stats_sect) stats_sect.style.display = 'none'; 277 break; 278 279 case 'market': 280 let market_sect = FP.findID('fupi_market_section'); 281 if ( market_sect ) market_sect.style.display = 'none'; 282 break; 283 284 case 'pers': 285 let pers_sect = FP.findID('fupi_pers_section'); 286 if ( pers_sect ) pers_sect.style.display = 'none'; 287 break; 288 } 289 } ) 290 } 291 } 292 293 function show_popup_elements(){ 294 if ( fp.notice.shown.length > 0 ) { 295 fp.notice.shown.forEach( el=> { 296 switch ( el ) { 297 case 'powered_by': 298 FP.findAll('.fupi_poweredBy').forEach( el => el.style.display = 'block' ); 299 break; 300 case 'stats_only_btn': 301 if ( fp.notice.mode !== 'notify' ) FP.findID('fupi_stats_only_btn').style.display = 'block'; 302 break; 303 } 304 } ) 305 } 306 } 307 308 function transform_notice_into_infobox(){ 309 var html_el = document.getElementsByTagName( 'html' )[0]; 310 html_el.classList.add('fupi_infobox'); // removes blur and doesn't let scroll locking 311 notice.classList.add('fupi_notice_infobox'); 312 } 313 314 function remove_blur() { 315 setTimeout( function(){ 316 var html_el = document.getElementsByTagName( 'html' )[0]; 317 if( html_el.classList.contains('fupi_blur') ) { 318 html_el.classList.remove('fupi_blur'); 319 html_el.classList.add('fupi_blur_out'); 320 } 321 }, 300 ); 322 } 323 324 function lock_scroll() { 325 if ( fp.notice.scroll_lock ) { 326 var html_el = document.getElementsByTagName( 'html' )[0]; 327 if ( ! html_el.classList.contains('fupi_infobox') ) { 328 html_el.classList.add('fupi_scroll_lock'); 329 document.body.style.overflowY = 'hidden'; 330 } 331 } 332 } 333 334 function remove_scroll_lock(){ 335 if ( fp.notice.scroll_lock ) { 336 var html_el = document.getElementsByTagName( 'html' )[0]; 337 html_el.classList.remove('fupi_scroll_lock'); 338 document.body.style.overflowY = 'auto'; 339 } 340 } 341 342 function show_notice_on_link_click( set_switches = false ){ 343 344 let show_notice_links = FP.findAll( fp.notice.toggle_selector ); 345 346 show_notice_links.forEach(function(link) { 347 348 link.addEventListener('click', function(e) { 349 350 e.preventDefault(); 351 352 hide_toggler(); 353 notice.classList.add( 'fupi_changing_preferences' ); // hides "return button" but shows the close button 354 355 priorFocus = document.activeElement; 356 357 if ( set_switches ) set_switches_state(); 358 359 add_consent_id_to_banner(); 360 361 show_notice_wrapper(); 362 363 if ( fp.notice.mode == 'notify' ){ 364 show_panel('welcome'); 365 } else { 366 panel.settings ? show_panel('settings') : show_panel('welcome'); 367 } 368 369 if ( ! a11y_buttons_ready ) a11y_buttons( true ); 370 }); 371 }); 372 } 373 374 function add_consent_id_to_banner(){ 375 376 let cookie_val = FP.readCookie( 'cdb_id' ), 377 cdb_id = false, 378 consent_info_boxes = FP.findAll('.fupi_consent_info'); // one on each CB panel 379 380 if ( ! ( fp?.proofrec?.save_consent && cookie_val && consent_info_boxes.length > 0 && fpdata.cookies && fpdata.cookies.time && fpdata.cookies.timezone ) ) return; 381 382 // if consent was prior to 8.5 383 // ( checks if cookie_val is not a STRINGified array ) 384 if ( cookie_val[0] != '[' ) { 385 386 cdb_id = cookie_val; 387 388 // fill in the HTML box
389 consent_info_boxes.forEach( box => { 390 391 let id_el = FP.findFirst( '.fupi_consent_id', box ); 392 if ( id_el ) id_el.innerHTML = cdb_id; 393 394 let date_el = FP.findFirst( '.fupi_consent_date', box ); 395 if ( date_el ) date_el.innerHTML = fpdata.cookies.time + ' (' + fpdata.cookies.timezone + ')'; 396 397 box.classList.remove('fupi_hidden'); 398 }); 399 400 // if ver 8.5+, we add another consent time 401 } else { 402 403 cookie_val = JSON.parse( cookie_val ); 404 cdb_id = cookie_val[0]; 405 406 let cons_times_a = cookie_val[1]; 407 408 // fill in the HTML box 409 410 consent_info_boxes.forEach( box => { 411 412 let id_el = FP.findFirst( '.fupi_consent_id', box ), 413 is_consent_saved = cons_times_a[0][1], 414 consentID = cdb_id + '_' + cons_times_a[0][0]; 415 416 if ( id_el ) { 417 418 // maybe add a link to ConsentsDB 419 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; 420 } 421 422 let date_el = FP.findFirst( '.fupi_consent_date', box ); 423 if ( date_el ) date_el.innerHTML = fpdata.cookies.time + ' (' + fpdata.cookies.timezone + ')'; 424 425 box.classList.remove('fupi_hidden'); 426 }); 427 } 428 } 429 430 function set_default_switches(){ 431 432 if ( fp.notice.preselected_switches.length > 0 && ( fp.notice.mode == 'optout' || fp.notice.optin_switches ) ){ 433 434 if ( fp.notice.preselected_switches.includes('stats') ){ 435 let stats_switch = FP.findFirst('#fupi_stats_section .fupi_switch'); 436 if ( stats_switch ) stats_switch.click(); 437 }; 438 439 if ( fp.notice.preselected_switches.includes('market') ){ 440 let market_switch = FP.findFirst('#fupi_market_section .fupi_switch'); 441 if ( market_switch ) market_switch.click(); 442 }; 443 444 if ( fp.notice.preselected_switches.includes('pers') ){ 445 let pers_switch = FP.findFirst('#fupi_pers_section .fupi_switch'); 446 if ( pers_switch ) pers_switch.click(); 447 }; 448 } 449 } 450 451 function set_switches_state() { 452 var switches = FP.findAll(".fupi_switch input"); 453 454 if(switches.length > 0) { 455 switches.forEach(function(the_switch) { 456 if( fpdata.cookies && fpdata.cookies[the_switch.value]) the_switch.checked = true; 457 }); 458 } 459 } 460 461 function add_events_to_notice_btns() { 462 463 let accept_all_btn = FP.findID('fupi_agree_to_all_cookies_btn'), 464 decline_btn = FP.findID('fupi_decline_cookies_btn'), 465 cookie_settings_btn = FP.findID('fupi_cookie_settings_btn'), 466 accept_stats_btn = FP.findID('fupi_stats_only_btn'), 467 accept_chosen_btn = FP.findID('fupi_agree_to_selected_cookies_btn'), 468 return_btn = FP.findID('fupi_return_btn'), 469 close_banner_btns = FP.findAll('.fupi_close_banner_btn'), 470 switches = FP.findAll('.fupi_switch'); 471 472 if ( accept_all_btn ) { 473 accept_all_btn.addEventListener('click', function(){ 474 475 // hide all 476 hide_panel('welcome'); 477 show_toggler(); 478 hide_notice_wrapper(); 479 remove_blur(); 480 remove_scroll_lock(); 481 482 // save cookies and fire events 483 if ( fp.main.track_current_user ) accept_all_cookies_and_fire_custom_event(); 484 if ( FP.manageIframes ) FP.manageIframes(); // unblock iframes 485 }); 486 } 487 488 if ( accept_stats_btn ) { 489 accept_stats_btn.addEventListener('click', function(){ 490 491 // hide all 492 hide_panel('welcome'); 493 show_toggler(); 494 hide_notice_wrapper(); 495 remove_blur(); 496 remove_scroll_lock(); 497 498 // save cookies and fire events 499 if ( fp.main.track_current_user ) accept_stats_cookies_and_fire_custom_event(); 500 if ( FP.manageIframes ) FP.manageIframes(); // unblock iframes 501 }) 502 } 503 504 if ( decline_btn ) { 505 decline_btn.addEventListener('click', function(){ 506 507 // hide all 508 hide_panel('welcome'); 509 show_toggler(); 510 hide_notice_wrapper(); 511 remove_blur(); 512 remove_scroll_lock(); 513 514 // save cookies and fire events 515 decline_all_cookies(); 516 }); 517 } 518 519 if ( accept_chosen_btn ) { 520 accept_chosen_btn.addEventListener('click', function(){ 521 522 // hide all 523 hide_panel('settings'); 524 show_toggler(); 525 hide_notice_wrapper(); 526 remove_blur(); 527 remove_scroll_lock(); 528 529 // save cookies and fire events 530 if ( fp.main.track_current_user ) accept_chosen_cookies_and_fire_custom_events(); 531 if ( FP.manageIframes ) FP.manageIframes(); 532 }); 533 } 534 535 if ( cookie_settings_btn ) { 536 cookie_settings_btn.addEventListener('click', function() { 537 hide_panel('welcome'); 538 show_panel('settings'); 539 }); 540 } 541 542 if ( return_btn ) { 543 return_btn.addEventListener('click', function() { 544 hide_panel('settings'); 545 show_panel('welcome'); 546 }); 547 } 548 549 close_banner_btns.forEach( btn => { 550 btn.addEventListener('click', function() { 551 hide_panel('welcome'); 552 hide_panel('settings'); 553 show_toggler(); 554 hide_notice_wrapper(); 555 remove_blur(); 556 remove_scroll_lock(); 557 }); 558 }) 559
560 switches.forEach(function(the_switch) { 561 the_switch.addEventListener('click', function(e) { 562 toggle_switch(e.target); 563 }, false); 564 }); 565 566 } 567 568 function get_prev_consents(){ 569 return { 570 'statistics' : fpdata?.cookies?.stats, 571 'marketing' : fpdata?.cookies?.marketing, 572 'personalisation' : fpdata?.cookies?.personalisation 573 } 574 } 575 576 function auto_agree_to_all_cookies(){ // auto triggered when the notice is in "notify" mode 577 578 fpdata.cookies = { 579 'stats': true, 580 'personalisation': true, 581 'marketing': true, 582 'disabled': false, 583 'pp_pub' : fp.notice.priv_policy_update, 584 'tools' : fp.tools, 585 'time' : get_date(), 586 'timezone' : get_timezone(), 587 'timezoneName' : get_timezoneName(), 588 }; 589 590 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 591 } 592 593 function add_events_to_ok_button(){ // triggered when consent banner only notifies 594 595 let agree_btn = FP.findID('fupi_agree_to_all_cookies_btn'); 596 597 if( agree_btn ) { 598 agree_btn.addEventListener('click', function(){ 599 600 hide_panel('welcome'); 601 hide_notice_wrapper(); 602 remove_blur(); 603 remove_scroll_lock(); 604 }); 605 } 606 } 607 608 function actions_when_notif_is_hidden(){ 609 610 // remove blur & scroll lock 611 612 var html_el = document.getElementsByTagName( 'html' )[0]; 613 614 html_el.classList.remove('fupi_blur'); 615 616 if ( fp.notice.scroll_lock ) { 617 html_el.classList.remove('fupi_scroll_lock'); 618 document.body.style.overflowY = 'auto'; 619 } 620 621 // save cookies 622 623 if ( ! fpdata.cookies ) { 624 625 fpdata.cookies = { 626 'stats': true, 627 'personalisation': true, 628 'marketing': true, 629 'disabled': false, 630 'pp_pub' : fp.notice.priv_policy_update, 631 'tools' : fp.tools, 632 'time' : get_date(), 633 'timezone' : get_timezone(), 634 'timezoneName' : get_timezoneName(), 635 }; 636 637 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 638 update_tools_consents(); 639 } 640 641 if ( FP.manageIframes ) FP.manageIframes(); // unblock iframes 642 } 643 644 // ACCESSIBLE SWITCH 645 // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Switch_role 646 647 function toggle_switch(target) { 648 if(target.getAttribute("aria-checked") == "true") { 649 target.setAttribute("aria-checked", "false"); 650 } else { 651 target.setAttribute("aria-checked", "true"); 652 } 653 } 654 655 function accept_all_cookies_and_fire_custom_event() { 656 657 let prev_consents = get_prev_consents(); 658 659 // this is the default when the settings panel is hidden (we set everything to true) 660 fpdata.cookies = { 661 'stats': true, 662 'personalisation': true, 663 'marketing': true, 664 'disabled': false, 665 'pp_pub' : fp.notice.priv_policy_update, 666 'tools' : fp.tools, 667 'time' : get_date(), 668 'timezone' : get_timezone(), 669 'timezoneName' : get_timezoneName(), 670 }; 671 672 if ( panel.settings ){ // when the settings panel is visible, we set to true only those cookies which settings are not hidden 673 674 let stats = !!FP.findID('fupi_stats_agree'), 675 perso = !!FP.findID('fupi_pers_agree'), 676 marke = !!FP.findID('fupi_marketing_agree'); 677 678 fpdata.cookies = { 679 'stats': stats, 680 'personalisation': perso, 681 'marketing': marke, 682 'disabled': false, 683 'pp_pub' : fp.notice.priv_policy_update, 684 'tools' : fp.tools, 685 'time' : get_date(), 686 'timezone' : get_timezone(), 687 'timezoneName' : get_timezoneName(), 688 }; 689 } 690 691 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 692 693 save_preferences_in_cdb( prev_consents ); 694 695 FP.updateSessionData(); 696 697 FP.sendEvt( 'fp_load_scripts' ); 698 FP.sendEvt( 'fupi_consents_changed', 'all accepted') ; 699 700 update_tools_consents(); 701 } 702 703 function accept_stats_cookies_and_fire_custom_event(){ 704 705 let prev_consents = get_prev_consents(); 706 707 // this is the default when the settings panel is hidden (we set everything to true) 708 fpdata.cookies = { 709 'stats': true, 710 'personalisation': false, 711 'marketing': false, 712 'disabled': false, 713 'pp_pub' : fp.notice.priv_policy_update, 714 'tools' : fp.tools, 715 'time' : get_date(), 716 'timezone' : get_timezone(), 717 'timezoneName' : get_timezoneName(), 718 }; 719 720 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 721 722 save_preferences_in_cdb( prev_consents ); 723 724 FP.updateSessionData(); 725 726 FP.sendEvt( 'fp_load_scripts' ); 727 FP.sendEvt( 'fupi_consents_changed', 'stats accepted') ; 728 729 update_tools_consents(); 730 } 731 732 function check_if_needs_a_reload(){ 733 return fp.loaded.some( el => el !== 'woo' && el !== 'gtm' && el !== 'gtg' && el !== 'ga41' && el !== 'ga42' && el !== 'gads'); 734 } 735 736 function accept_chosen_cookies_and_fire_custom_events() { 737
738 let stats_checkbox = FP.findID('fupi_stats_agree'), 739 perso_checkbox = FP.findID('fupi_pers_agree'), 740 marke_checkbox = FP.findID('fupi_marketing_agree'), 741 needs_a_reload = check_if_needs_a_reload(), // checks for scripts that do not adjust its behavior depending on consents 742 prev_consents = get_prev_consents(); 743 744 fp.notice.reload_page_after_saving_cdb = needs_a_reload; 745 746 fpdata.cookies = { 747 'stats': stats_checkbox ? stats_checkbox.checked : false, 748 'personalisation': perso_checkbox ? perso_checkbox.checked : false, 749 'marketing': marke_checkbox ? marke_checkbox.checked : false, 750 'disabled': false, 751 'pp_pub' : fp.notice.priv_policy_update, 752 'tools' : fp.tools, 753 'time' : get_date(), 754 'timezone' : get_timezone(), 755 'timezoneName' : get_timezoneName(), 756 }; 757 758 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 759 760 save_preferences_in_cdb( prev_consents ); 761 762 FP.updateSessionData(); 763 764 if ( needs_a_reload ) { 765 maybe_wait_to_reload_page(); 766 } else { 767 FP.sendEvt( 'fp_load_scripts' ); 768 FP.sendEvt( 'fupi_consents_changed', 'some accepted' ); 769 update_tools_consents(); 770 } 771 } 772 773 function decline_all_cookies() { 774 775 if ( ! fp.main.track_current_user ) return; 776 777 let needs_a_reload = check_if_needs_a_reload(), 778 prev_consents = get_prev_consents(); 779 780 fp.notice.reload_page_after_saving_cdb = needs_a_reload; 781 782 fpdata.cookies = { 783 'stats': false, 784 'personalisation': false, 785 'marketing': false, 786 'disabled': false, 787 'pp_pub' : fp.notice.priv_policy_update, 788 'tools' : fp.tools, 789 'time' : get_date(), 790 'timezone' : get_timezone(), 791 'timezoneName' : get_timezoneName(), 792 }; 793 794 FP.setCookie('fp_cookie', JSON.stringify(fpdata.cookies), 182 ); 795 796 save_preferences_in_cdb( prev_consents ); 797 798 FP.updateSessionData(); 799 800 if ( needs_a_reload ) { 801 maybe_wait_to_reload_page(); 802 } else { 803 FP.sendEvt('fupi_consents_changed', 'declined'); 804 update_tools_consents(); 805 } 806 } 807 808 function maybe_wait_to_reload_page(){ 809 // if we should wait for server response 810 if ( fp.notice.cdb_waiting_for_response ) { 811 setTimeout( function() { 812 if (fp.main.debug ) console.log('[FP] Waiting for CDB server response before reloading the page'); 813 if ( ! fp.notice.cdb_id_confirmed ) { 814 if ( fp.main.debug ) console.log('[FP] Reloading page after timeout'); 815 location.reload(); 816 } 817 }, 2000 ); // this is max wait time. The reload is also triggered by the FP.postToServer script 818 } else { 819 location.reload(); 820 } 821 } 822 823 function update_buttons_focus(){ 824 focusableElements = FP.findAll('a[href]:not(.fupi_poweredBy_link), input:not([disabled]), button:not([disabled]), [tabindex="0"], [contenteditable]', panel[activePanel] ), 825 firstTabStop = focusableElements[0]; 826 lastTabStop = focusableElements[focusableElements.length - 1]; 827 // focus first element 828 firstTabStop.focus(); 829 } 830 831 function show_panel(type) { 832 833 if ( panel[type] ) { 834 835 activePanel = type; 836 837 // focus on the first button 838 FP.findFirst('button', panel[type]).focus(); 839 840 panel[type].classList.remove('fupi_fadeOutDown'); 841 panel[type].classList.remove('fupi_hidden'); 842 panel[type].classList.add('fupi_animated'); 843 panel[type].classList.add('fupi_fadeInUp'); 844 845 update_buttons_focus( panel[type] ); 846 } 847 } 848 849 function hide_panel( type ) { 850 851 if ( ! panel[type] ) return; 852 853 panel[type].classList.remove('fupi_fadeInUp'); 854 panel[type].classList.add('fupi_animated'); 855 panel[type].classList.add('fupi_fadeOutDown'); 856 } 857 858 function show_toggler(){ 859 if ( toggler && fp.notice.mode !== 'hidden' && fp.notice.mode !== 'notify' ) { 860 toggler.setAttribute("style",""); 861 toggler.classList.add( 'fupi_active', 'fupi_fadeInUp' ); 862 toggler.classList.remove( 'fupi_fadeOutDown' ); 863 } 864 } 865 866 function hide_toggler(){ 867 if ( toggler && toggler.classList.contains('fupi_active') ) { 868 toggler.classList.remove( 'fupi_fadeInUp'); 869 toggler.classList.add( 'fupi_fadeOutDown' ); 870 } 871 } 872 873 function show_notice_wrapper() { 874 notice.setAttribute("style",""); 875 notice.classList.remove('fupi_fadeOutDown'); 876 notice.classList.remove('fupi_hidden'); 877 notice.classList.add('fupi_fadeInUp'); 878 notice.classList.add('fupi_animated'); 879 } 880 881 function hide_notice_wrapper() { 882 notice.classList.remove('fupi_fadeInUp'); 883 notice.classList.add('fupi_fadeOutDown'); 884 priorFocus.focus(); 885 } 886
887 function a11y_buttons( opened_with_link ){ // accessibility buttons 888 889 a11y_buttons_ready = true; 890 891 document.addEventListener("keydown", e => { 892 893 // Escape key returns to welcome panel or closes the modal 894 if ( e.keyCode === 27 || e.code === 27 || e.key === 27 ) { 895 if ( activePanel == 'welcome' ){ 896 hide_panel('welcome'); 897 show_toggler(); 898 hide_notice_wrapper(); 899 remove_blur(); 900 remove_scroll_lock(); 901 if ( fp.notice.mode != 'notify' && ! opened_with_link ) { 902 decline_all_cookies(); 903 } 904 } else if ( activePanel == 'settings' ) { 905 hide_panel('settings'); 906 show_panel('welcome'); 907 } 908 } 909 910 // Keeps focus within panels when tab is clicked 911 if ( activePanel && ( e.keyCode === 9 || e.code === 9 || e.key === 9 ) ) { 912 // if shift is clicked with tab (reverse tabbing) 913 if (e.shiftKey) { 914 // do not go any further back if we are on the first element 915 if ( firstTabStop && document.activeElement === firstTabStop) e.preventDefault(); 916 917 // if next element is to be focused 918 } else { 919 if ( lastTabStop && document.activeElement === lastTabStop) { 920 e.preventDefault(); 921 lastTabStop.focus(); 922 } 923 } 924 } 925 926 }); 927 } 928 929 function show_notice() { 930 931 priorFocus = document.activeElement; 932 933 lock_scroll(); 934 show_notice_wrapper(); 935 show_panel('welcome'); 936 937 if ( ! a11y_buttons_ready ) a11y_buttons(); 938 } 939 940})();
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.