1SNIPPET_JS['COOKIE_LAW'] = { 2 CATEGORIES: { 3 NECESSARY: 'necessary', FUNCTIONAL: 'functional', ANALYTICS: 'analytics', MARKETING: 'marketing' 4 }, 5 DEFAULT_PREFERENCES: {}, 6 COOKIE_PREFERENCES: {}, 7 COOKIE_NAME: 't-cookie-law', 8 getItem(key) { 9 try { 10 return getCookie(key); 11 } catch (e) { 12 return null; 13 } 14 }, 15 setItem(key, value) { 16 try { 17 setCookie(key, value, 365); 18 setCookie('t-cookie-law-at', Date.now(), 365); 19 return true; 20 } catch (e) { 21 return false; 22 } 23 }, 24 removeItem(key) { 25 try { 26 setCookie(key, '', -1); 27 setCookie('t-cookie-law-at', '', -1); 28 return true; 29 } catch (e) { 30 return false; 31 } 32 }, 33 show(element) { 34 if (!element) return; 35 element.classList.remove('opacity-0', 'invisible', 'translate-y-full'); 36 }, 37 hide(element) { 38 if (!element) return; 39 element.classList.add('opacity-0', 'invisible', 'translate-y-full'); 40 }, 41 toggleModal(modal, show) { 42 if (!modal) return; 43 const box = modal.querySelector('[data-cookie-modal-content]'); 44 45 if (show) { 46 modal.classList.remove('opacity-0', 'invisible'); 47 if (box) box.classList.remove('scale-95'); 48 } else { 49 modal.classList.add('opacity-0', 'invisible'); 50 if (box) box.classList.add('scale-95'); 51 } 52 }, 53 getConsentConfig() { 54 return { 55 'ad_storage': this.COOKIE_PREFERENCES[this.CATEGORIES.MARKETING] ? 'granted' : 'denied', 56 'analytics_storage': this.COOKIE_PREFERENCES[this.CATEGORIES.ANALYTICS] ? 'granted' : 'denied', 57 'functionality_storage': this.COOKIE_PREFERENCES[this.CATEGORIES.FUNCTIONAL] ? 'granted' : 'denied', 58 'personalization_storage': this.COOKIE_PREFERENCES[this.CATEGORIES.MARKETING] ? 'granted' : 'denied', 59 'security_storage': 'granted' 60 }; 61 }, 62 loadPreferences() { 63 const consent = this.getItem(this.COOKIE_NAME); 64 if (!consent) { 65 this.showBanner(); 66 return; 67 } 68 69 try { 70 const parsed = JSON.parse(consent); 71 72 if (parsed === true) { 73 this.setAllPreferences(true); 74 } else if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) { 75 this.COOKIE_PREFERENCES = {...this.DEFAULT_PREFERENCES, ...parsed}; 76 } else { 77 this.resetToDefaults(); 78 } 79 80 this.updateConsentMode(); 81 } catch (e) { 82 this.resetToDefaults(); 83 } 84 }, 85 savePreferences() { 86 if (!this.COOKIE_PREFERENCES.consentAt) { 87 this.COOKIE_PREFERENCES.consentAt = Date.now(); 88 } 89 this.setItem(this.COOKIE_NAME, JSON.stringify(this.COOKIE_PREFERENCES)); 90 this.updateConsentMode(); 91 }, 92 setAllPreferences(enabled) { 93 Object.keys(this.CATEGORIES).forEach(key => { 94 const category = this.CATEGORIES[key]; 95 this.COOKIE_PREFERENCES[category] = category === this.CATEGORIES.NECESSARY ? true : enabled; 96 }); 97 if (enabled && !this.COOKIE_PREFERENCES.consentAt) { 98 this.COOKIE_PREFERENCES.consentAt = Date.now(); 99 } 100 }, 101 resetToDefaults() { 102 this.COOKIE_PREFERENCES = {...this.DEFAULT_PREFERENCES}; 103 this.savePreferences(); 104 }, 105 updatePreference(category, enabled) { 106 if (Object.values(this.CATEGORIES).includes(category)) { 107 this.COOKIE_PREFERENCES[category] = !!enabled; 108 } 109 }, 110 acceptAll() { 111 this.setAllPreferences(true); 112 this.savePreferences(); 113 this.hideBanner(); 114 this.closeSettings(); 115 }, 116 rejectAll() { 117 this.setAllPreferences(false); 118 this.savePreferences(); 119 this.hideBanner(); 120 this.closeSettings(); 121 }, 122 showBanner() { 123 const banner = document.getElementById('cookieBanner'); 124 this.show(banner); 125 }, 126 hideBanner() { 127 const banner = document.getElementById('cookieBanner'); 128 this.hide(banner); 129 }, 130 showSettings() { 131 const modal = document.getElementById('cookieModal'); 132 this.toggleModal(modal, true); 133 this.updateSettingsUI(); 134 }, 135 closeSettings() { 136 const modal = document.getElementById('cookieModal'); 137 this.toggleModal(modal, false); 138 }, 139 updateSettingsUI() {
140 Object.values(this.CATEGORIES).forEach(category => { 141 const element = document.getElementById(category); 142 if (element) { 143 element.checked = this.COOKIE_PREFERENCES[category]; 144 } 145 }); 146 }, 147 updateConsentMode() { 148 const self = this; 149 if (typeof dataLayer !== 'undefined') { 150 dataLayer.push({ 151 'event': 'consent_update', 152 ...self.getConsentConfig() 153 }); 154 } 155 }, 156 reset() { 157 this.removeItem(this.COOKIE_NAME); 158 this.resetToDefaults(); 159 this.showBanner(); 160 }, 161 bindModalOutsideClick() { 162 const modal = document.getElementById('cookieModal'); 163 if (!modal || modal.__cookieBound) return; 164 165 modal.addEventListener('click', (e) => { 166 const box = modal.querySelector('[data-cookie-modal-content]'); 167 if (!box) return; 168 if (!box.contains(e.target)) { 169 this.closeSettings(); 170 } 171 }); 172 173 modal.__cookieBound = true; 174 }, 175 globalFunctions() { 176 const self = this; 177 window.showCookieSettings = () => self.showSettings(), 178 window.closeCookieSettings = () => self.closeSettings(); 179 window.acceptAllCookies = () => self.acceptAll(); 180 window.rejectAllCookies = () => this.rejectAll(); 181 window.updateCookiePreference = (type, enabled) => self.updatePreference(type, enabled); 182 window.savePreferences = () => { 183 self.savePreferences(); 184 self.hideBanner(); 185 self.closeSettings(); 186 }; 187 }, 188 init() { 189 this.globalFunctions(); 190 this.DEFAULT_PREFERENCES = { 191 [this.CATEGORIES.NECESSARY]: true, 192 [this.CATEGORIES.FUNCTIONAL]: false, 193 [this.CATEGORIES.ANALYTICS]: false,
194 [this.CATEGORIES.MARKETING]: false, 195 consentAt: null 196 }; 197 this.COOKIE_PREFERENCES = {...this.DEFAULT_PREFERENCES}; 198 199 const consent = JSON.parse(this.getItem(this.COOKIE_NAME) || '{}'); 200 if (consent?.consentAt) { 201 this.setItem('t-cookie-law-at', consent.consentAt); 202 return 203 }; 204 205 if (typeof dataLayer !== 'undefined') { 206 dataLayer.push({ 207 event: 'consent_default', 208 ad_storage: consent?.marketing ? 'granted' : 'denied', 209 analytics_storage: consent?.analytics ? 'granted' : 'denied', 210 functionality_storage: consent?.functional ? 'granted' : 'denied', 211 personalization_storage: consent?.marketing ? 'granted' : 'denied', 212 security_storage: 'granted' 213 }); 214 } 215 216 this.bindModalOutsideClick(); 217 this.loadPreferences(); 218 } 219}; 220 221SNIPPET_JS['COOKIE_LAW'].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.