1let pixConsent = { 2 consentKey: 'pix_consent_given', 3 consentDismissedKey: 'pix_consent_dismissed', 4 consentGiven: false, 5 consentDismissed: false, 6 gtmId: 'GTM-53S4NLF', 7 gtmWrapEl: null, 8 gtmBackupWrapEl: null, 9 consentBarEl: null, 10 consentBarAcceptEl: null, 11 consentBarRejectEl: null, 12 consentShowBannerLinks: null, 13 consentRejectLinks: null, 14 consentManageLink: null, 15 track: function(label) { 16 if ( typeof dataLayer !== 'undefined' ) { 17 dataLayer.push({ 18 'event': 'Privacy Consent Event', 19 'privacyConsentLabel': label 20 }); 21 } 22 }, 23 injectGTM: function() { 24 let that = this; 25 let gtmScript = document.createElement('script'); 26 let gtmScriptInline = document.createTextNode(` 27 // let dataLayer = window.dataLayer || []; 28 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 29 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 30 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 31 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 32 })(window,document,'script','dataLayer','${that.gtmId}'); 33 `); 34 gtmScript.appendChild(gtmScriptInline); 35 that.gtmWrapEl.appendChild(gtmScript); 36 let gtmBackupScript = document.createElement('noscript'); 37 let gtmBackupScriptInline = document.createTextNode(` 38 <iframe src="https://www.googletagmanager.com/ns.html?id=${that.gtmId}" 39 height="0" width="0" style="display:none;visibility:hidden"></iframe> 40 `); 41 gtmBackupScript.appendChild(gtmBackupScriptInline); 42 that.gtmBackupWrapEl.appendChild(gtmBackupScript); 43 }, 44 removeGTM: function() { 45 let that = this; 46 that.gtmWrapEl.innerHTML = ''; 47 that.gtmBackupWrapEl.innerHTML = ''; 48 }, 49 dismissConsentBar: function() { 50 let that = this; 51 localStorage.setItem(that.consentDismissedKey, true); 52 that.hideConsentBar(); 53 }, 54 hideConsentBar: function() { 55 let that = this; 56 that.consentBarEl.classList.add('is-hidden'); 57 }, 58 showConsentBar: function() { 59 let that = this; 60 localStorage.setItem(that.consentDismissedKey, false); 61 that.consentBarEl.classList.remove('is-hidden'); 62 }, 63 checkConsent: function() { 64 let that = this; 65 if ( typeof navigator.globalPrivacyControl === 'boolean' && navigator.globalPrivacyControl ) { 66 // the user has set their global privacy control to block tracking 67 that.consentGiven = false; 68 that.consentDismissed = true; 69 } else { 70 if ( typeof localStorage.getItem(that.consentKey) === 'string' && localStorage.getItem(that.consentKey) === 'false' ) { 71 that.consentGiven = false; 72 } else { 73 that.consentGiven = true; 74 }
75 if ( typeof localStorage.getItem(that.consentDismissedKey) === 'string' && localStorage.getItem(that.consentDismissedKey) === 'true' ) { 76 that.consentDismissed = true; 77 } 78 } 79 if ( that.consentDismissed ) that.hideConsentBar(); 80 if ( that.consentGiven ) that.injectGTM(); 81 that.updateConsentStatusBox(); 82 }, 83 giveConsent: function() { 84 let that = this; 85 that.consentGiven = true; 86 that.dismissConsentBar(); 87 localStorage.setItem(that.consentKey, true); 88 that.track('accept'); 89 that.updateConsentStatusBox(); 90 }, 91 rejectConsent: function() { 92 let that = this; 93 that.consentGiven = false; 94 that.dismissConsentBar(); 95 localStorage.setItem(that.consentKey, false); 96 that.track('reject'); 97 that.updateConsentStatusBox(); 98 }, 99 bindEvents: function() { 100 let that = this; 101 if ( that.consentBarAcceptEl ) { 102 that.consentBarAcceptEl.addEventListener('click', function() { 103 that.giveConsent(); 104 }); 105 } 106 if ( that.consentBarRejectEl ) { 107 that.consentBarRejectEl.addEventListener('click', function() { 108 that.rejectConsent(); 109 }); 110 } 111 if ( that.consentShowBannerLinks ) { 112 that.consentShowBannerLinks.forEach(function(link) { 113 link.addEventListener('click', function(e) { 114 e.preventDefault(); 115 that.showConsentBar(); 116 }); 117 }); 118 } 119 if ( that.consentRejectLinks ) { 120 that.consentRejectLinks.forEach(function(link) { 121 link.addEventListener('click', function(e) { 122 e.preventDefault(); 123 that.rejectConsent(); 124 }); 125 }); 126 } 127 if ( that.consentStatusBoxToggleEl ) { 128 that.consentStatusBoxToggleEl.addEventListener('click', function() { 129 if ( that.consentGiven ) { 130 that.rejectConsent(); 131 } else { 132 that.giveConsent(); 133 } 134 }); 135 } 136 if ( that.consentManageLink ) { 137 that.consentManageLink.addEventListener('click', function(e) { 138 that.dismissConsentBar(); 139 }); 140 } 141 }, 142 updateConsentStatusBox: function() { 143 let that = this; 144 if ( that.consentStatusBoxToggleEl && that.consentStatusBoxLabelAcceptedEl && that.consentStatusBoxLabelRejectedEl ) { 145 if ( that.consentGiven ) { 146 that.consentStatusBoxToggleEl.setAttribute('data-pix-consent', 'true'); 147 that.consentStatusBoxLabelAcceptedEl.classList.add('is-active'); 148 that.consentStatusBoxLabelRejectedEl.classList.remove('is-active'); 149 } else { 150 that.consentStatusBoxToggleEl.setAttribute('data-pix-consent', 'false'); 151 that.consentStatusBoxLabelAcceptedEl.classList.remove('is-active'); 152 that.consentStatusBoxLabelRejectedEl.classList.add('is-active'); 153 } 154 } 155 }, 156 init: function() { 157 let that = this; 158 document.addEventListener('DOMContentLoaded', function() { 159 that.gtmWrapEl = document.getElementById('js-pix_consent_main'), 160 that.gtmBackupWrapEl = document.getElementById('js-pix_consent_backup'), 161 that.consentBarEl = document.getElementById('js-pix_consent_bar'), 162 that.consentBarAcceptEl = document.getElementById('js-pix_consent_bar_accept'), 163 that.consentBarRejectEl = document.getElementById('js-pix_consent_bar_reject'), 164 that.consentShowBannerLinks = document.querySelectorAll('[href^="#showconsent"]'), 165 that.consentRejectLinks = document.querySelectorAll('[href^="#rejectconsent"]'), 166 that.consentStatusBoxToggleEl = document.getElementById('js-pix_consent_status_box_toggle'), 167 that.consentStatusBoxLabelAcceptedEl = document.getElementById('js-pix_consent_status_box_label_accepted'), 168 that.consentStatusBoxLabelRejectedEl = document.getElementById('js-pix_consent_status_box_label_rejected'), 169 that.consentManageLink = document.getElementById('js-pix_consent_bar_manage_link'), 170 that.checkConsent(); 171 that.bindEvents(); 172 }); 173 }, 174}; 175pixConsent.init();
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.