1//polyfill 2if (!Element.prototype.matches) { 3 Element.prototype.matches = 4 Element.prototype.msMatchesSelector || 5 Element.prototype.webkitMatchesSelector; 6} 7 8if (!Element.prototype.closest) { 9 Element.prototype.closest = function (s) { 10 var el = this; 11 12 do { 13 if (Element.prototype.matches.call(el, s)) return el; 14 el = el.parentElement || el.parentNode; 15 } while (el !== null && el.nodeType === 1); 16 return null; 17 }; 18} 19 20 21var tx_cookie_client = (function () { 22 23 let html = document.querySelector('html'); 24 let body = document.querySelector('body'); 25 let form = document.querySelector('.tx-dm-initial-dialog .dialog-wrapper form'); 26 let root = document.querySelector('.tx-dm-initial-dialog'); 27 let wrapper = document.querySelector('.tx-dm-initial-dialog .dialog-wrapper'); 28 let configWrapper = document.querySelector('.tx-dm-initial-dialog .dialog-wrapper .config-wrap'); 29 let cookieConfigToggleBtns = document.querySelectorAll('.tx-dm-initial-dialog .dialog-wrapper .config-wrap .show-info-btn'); 30 let dialog = document.querySelector('.tx-dm-initial-dialog .dialog-wrapper .dialog'); 31 let btnClose = document.querySelector('.tx-dm-initial-dialog .dialog-wrapper .btn-close'); 32 let btnCloseconf = document.querySelector('.tx-dm-initial-dialog .dialog-wrapper .config-wrap .btn-close-conf'); 33 let showDialog = document.querySelectorAll('a.show-cookie-consent'); 34 let handledEvents = []; 35 36 var addClass = function (element, className) { 37 if (element.classList) { 38 element.classList.add(className); 39 } else { 40 element.className += ' ' + className; 41 } 42 } 43 44 var removeClass = function (element, className) { 45 if (element.classList) { 46 element.classList.remove(className); 47 } else { 48 element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); 49 } 50 } 51 52 var hasClass = function (element, className) { 53 if (element && element.classList) { 54 return element.classList.contains(className); 55 } else { 56 return new RegExp('(\\s|^)' + className + '(\\s|$)').test(element.className); 57 } 58 } 59 60 var addEvent = function (event, element, callback) { 61 if (element == null || typeof element === "undefined") { 62 return; 63 } 64 if (element.addEventListener) { 65 element.addEventListener(event, callback, false); 66 } else if (element.attachEvent) { 67 element.attachEvent("on" + event, callback); 68 } else { 69 element["on" + event] = callback; 70 } 71 } 72 73 var executeFunctionByName = function (functionName, context /*, args */) { 74 var args = Array.prototype.slice.call(arguments, 2); 75 var namespaces = functionName.split("."); 76 var func = namespaces.pop(); 77 for (var i = 0; i < namespaces.length; i++) { 78 context = context[namespaces[i]]; 79 } 80 return context[func].apply(context, args); 81 } 82 83 var setCookie = function (name, value = '1') { 84 let date = new Date(); 85 if(typeof tx_dmcookies_conf.cookies[name] !== "undefined" && typeof tx_dmcookies_conf.cookies[name].expires !== "undefined"){ 86 date.setTime(date.getTime() + (parseInt(tx_dmcookies_conf.cookies[name].expires) * 1000)); 87 }else{ 88 date.setTime(date.getTime() + (tx_dmcookies_conf.expires * 1000)); 89 } 90 91 92 let secure = ''; 93 if (location.protocol === 'https:') { 94 secure = '; secure'; 95 } 96 97 document.cookie = 'tx_dmcookies_allow_' + name + '=' + value + '; expires=' + date.toUTCString() + '; SameSite=Lax; path=/' + secure; 98 99 if (typeof tx_dmcookies_conf.cookies[name] !== "undefined" && typeof tx_dmcookies_conf.cookies[name].jsCallbacks !== "undefined") { 100 let callbacks = tx_dmcookies_conf.cookies[name].jsCallbacks.split(','); 101 callbacks.forEach(function (element) { 102 let callback = element.trim(); 103 if (callback != '') { 104 executeFunctionByName(element, window, tx_dmcookies_conf.cookies[name]); 105 } 106 }); 107 } 108 if (typeof tx_dmcookies_conf.cookies[name] !== "undefined") { 109 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_allowed', {'detail': {'key': name, 'cookieConf':tx_dmcookies_conf.cookies[name]}})); 110 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_' + name + '_allowed', {'detail': {'key': name, 'cookieConf':tx_dmcookies_conf.cookies[name]}})); 111 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_handle', {'detail': {'key': name, 'cookieConf':tx_dmcookies_conf.cookies[name]}})); 112 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_' + name + '_handle', {'detail': {'key': name, 'cookieConf':tx_dmcookies_conf.cookies[name]}})); 113 handledEvents.push('tx_dmcookie_cookie_' + name + '_allowed'); 114 handledEvents.push('tx_dmcookie_cookie_' + name + '_handle'); 115 } 116 } 117 118 function getCookie(cname) { 119 var name = "tx_dmcookies_allow_" + cname + "="; 120 var decodedCookie = decodeURIComponent(document.cookie); 121 var ca = decodedCookie.split(';'); 122 for (var i = 0; i < ca.length; i++) { 123 var c = ca[i];
124 while (c.charAt(0) == ' ') { 125 c = c.substring(1); 126 } 127 if (c.indexOf(name) == 0) { 128 return c.substring(name.length, c.length); 129 } 130 } 131 return ""; 132 } 133 134 var unsetCookie = function (name) { 135 let date = new Date(); 136 137 138 if(typeof tx_dmcookies_conf.cookies[name] !== "undefined" && typeof tx_dmcookies_conf.cookies[name].expires !== "undefined"){ 139 date.setTime(date.getTime() - (parseInt(tx_dmcookies_conf.cookies[name].expires) * 1000)); 140 }else{ 141 date.setTime(date.getTime() - (tx_dmcookies_conf.expires * 1000)); 142 } 143 144 145 let secure = ''; 146 if (location.protocol === 'https:') { 147 secure = '; secure'; 148 } 149 150 document.cookie = 'tx_dmcookies_allow_' + name + '=; expires=' + date.toUTCString() + '; path=/' + secure; 151 152 if (typeof tx_dmcookies_conf.cookies[name] !== "undefined" && typeof tx_dmcookies_conf.cookies[name].cookiesToDelete !== "undefined") { 153 let cookiesToDelete = tx_dmcookies_conf.cookies[name].cookiesToDelete.split(','); 154 cookiesToDelete.forEach(function (element) { 155 if (element.trim() != '') { 156 document.cookie = element.trim() + '=; expires=' + date.toUTCString() + '; path=/' + secure; 157 158 var arrSplit = document.cookie.split(";"); 159 for (var i = 0; i < arrSplit.length; i++) { 160 var cookie = arrSplit[i].trim(); 161 var cookieName = cookie.split("=")[0]; 162 if (cookieName.indexOf(element.trim()) === 0) { 163 document.cookie = cookieName + '=; expires=' + date.toUTCString() + '; path=/' + secure; 164 } 165 } 166 } 167 }); 168 } 169 170 if (typeof tx_dmcookies_conf.cookies[name] !== "undefined" && typeof tx_dmcookies_conf.cookies[name].jsDeleteCallbacks !== "undefined") { 171 let callbacks = tx_dmcookies_conf.cookies[name].jsDeleteCallbacks.split(','); 172 callbacks.forEach(function (element) { 173 let callback = element.trim(); 174 if (callback != '') { 175 executeFunctionByName(element, window, tx_dmcookies_conf.cookies[name]); 176 } 177 }); 178 } 179 180 if (typeof tx_dmcookies_conf.cookies[name] !== "undefined") { 181 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_refused', {'detail': {'key': name, 'cookieConf':tx_dmcookies_conf.cookies[name]}})); 182 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_' + name + '_refused', {'detail': {'key': name, 'cookieConf':tx_dmcookies_conf.cookies[name]}})); 183 handledEvents.push('tx_dmcookie_cookie_' + name + '_refused'); 184 } 185 186 } 187 188 var showConf = function () { 189 addClass(dialog, 'show-conf'); 190 addClass(wrapper, 'has-conf'); 191 visibility(); 192 } 193 194 var closeConf = function () { 195 removeClass(dialog, 'show-conf'); 196 removeClass(wrapper, 'has-conf'); 197 visibility(); 198 } 199 200 var handleToogleCookieInfo = function (e) { 201 let cookieInfo = e.target.closest('.cookie-info-content'); 202 203 if (hasClass(cookieInfo, 'show')) { 204 removeClass(cookieInfo, 'show'); 205 } else { 206 addClass(cookieInfo, 'show'); 207 } 208 209 visibility(); 210 } 211 212 var handleFormSubmit = function (event) { 213 event.preventDefault(); 214 215 let btn = null; 216 217 if (typeof event.submitter !== "undefined") { 218 btn = event.submitter; 219 } else { 220 btn = document.activeElement; 221 } 222 223 if (hasClass(btn, 'config')) { 224 showConf(); 225 return; 226 } 227 228 Object.keys(tx_dmcookies_conf.cookies).forEach(function (key) { 229 let inputName = 'allow_' + key; 230 let inputElement = document.querySelector('.tx-dm-initial-dialog form input.cookie-checkbox[name=tx_dmcookies_cookies\\[' + inputName + '\\]]'); 231 232 if (tx_dmcookies_conf.showAsCategory == 1) { 233 inputElement = document.querySelector('.tx-dm-initial-dialog form input.cookie-checkbox[name=tx_dmcookies_cookies\\[category_' + tx_dmcookies_conf.cookies[key].category + '\\]]'); 234 } 235 236 if ( 237 !hasClass(btn, 'none') 238 && 239 ( 240 inputElement.checked && hasClass(btn, 'apply') 241 || 242 hasClass(btn, 'all') 243 ) 244 ) {
245 setCookie(key); 246 } else { 247 unsetCookie(key); 248 } 249 }); 250 251 if(btn != null && typeof btn.value !== "undefined" && btn.value == 'all'){ 252 let checkboxes = root.querySelectorAll('input[type=checkbox]'); 253 checkboxes.forEach(function(checkbox){ 254 checkbox.checked = true; 255 }); 256 } 257 258 259 closeHandle(event); 260 }; 261 262 var handleCookies = function () { 263 Object.keys(tx_dmcookies_conf.cookies).forEach(function (key) { 264 if (document.cookie.indexOf('tx_dmcookies_allow_' + key + '=1') >= 0) { 265 if (typeof tx_dmcookies_conf.cookies[key].jsCallbacks !== "undefined") { 266 let callbacks = tx_dmcookies_conf.cookies[key].jsCallbacks.split(','); 267 callbacks.forEach(function (element) { 268 let callback = element.trim(); 269 if (callback != '') { 270 executeFunctionByName(element, window, tx_dmcookies_conf.cookies[key]); 271 } 272 }); 273 } 274 275 if (typeof tx_dmcookies_conf.cookies[key] !== "undefined") { 276 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_handle', {'detail': {'key': key, 'cookieConf':tx_dmcookies_conf.cookies[key]}})); 277 document.dispatchEvent(new CustomEvent('tx_dmcookie_cookie_' + key + '_handle', {'detail': {'key': key,'cookieConf':tx_dmcookies_conf.cookies[key]}})); 278 handledEvents.push('tx_dmcookie_cookie_' + key + '_handle'); 279 } 280 } 281 }); 282 }; 283 284 var visibility = function () { 285 if (getCookie('close_dialoge') != "") { 286 return; 287 } 288 if (hasClass(root, 'as-overlay')) { 289 return; 290 } 291 292 if (hasClass(wrapper, 'align-top')) { 293 294 } 295 if (hasClass(wrapper, 'align-bottom')) { 296 root.style.height = wrapper.offsetHeight + 'px'; 297 } 298 }; 299 300 var closeHandle = function (event) { 301 removeClass(html, 'tx-dm-initial-dialog-open'); 302 removeClass(body, 'tx-dm-initial-dialog-open'); 303 addClass(wrapper, 'invisible'); 304 removeClass(wrapper, 'visible'); 305 addClass(root, 'invisible'); 306 removeClass(root, 'visible'); 307 //localStorage.setItem('tx_dmcookie_close', true); 308 setCookie('close_dialoge', tx_dmcookies_conf.confhash); 309 root.style.height = ''; 310 311 }; 312 313 var openHandle = function (event) { 314 if (typeof event !== "undefined" && event != null) { 315 event.preventDefault(); 316 } 317 318 addClass(html, 'tx-dm-initial-dialog-open'); 319 addClass(body, 'tx-dm-initial-dialog-open'); 320 addClass(wrapper, 'visible'); 321 addClass(root, 'visible'); 322 removeClass(wrapper, 'invisible'); 323 removeClass(root, 'invisible'); 324 visibility(); 325 } 326 327 var resetConsent = function() { 328 unsetCookie('close_dialoge'); 329 Object.keys(tx_dmcookies_conf.cookies).forEach(function (key) { 330 unsetCookie(key); 331 }); 332 333 let checkboxes = root.querySelectorAll('input[type=checkbox]'); 334 checkboxes.forEach(function(checkbox){ 335 if(checkbox.disabled){ 336 return; 337 } 338 checkbox.checked = false; 339 }); 340 } 341 342 var handleCheckbox = function(event) { 343 let currentCheckbox = event.target; 344 345 if(currentCheckbox.dataset.type == 'category') { 346 let checkboxes = root.querySelectorAll('input[type=checkbox][data-category=' + currentCheckbox.dataset.category + ']'); 347 checkboxes.forEach(function(checkbox){ 348 checkbox.checked = currentCheckbox.checked; 349 }); 350 } 351 352 if(currentCheckbox.dataset.type == 'cookie') { 353 let checkboxes = root.querySelectorAll('input[type=checkbox][data-type=cookie][data-category=' + currentCheckbox.dataset.category + ']'); 354 let hasAll = true;
355 checkboxes.forEach(function(checkbox){ 356 if(!checkbox.checked) { 357 hasAll = false; 358 } 359 }); 360 361 let checkboxesCategory = root.querySelectorAll('input[type=checkbox][data-type=category][data-category=' + currentCheckbox.dataset.category + ']'); 362 checkboxesCategory.forEach(function(checkbox){ 363 checkbox.checked = hasAll; 364 }); 365 } 366 367 } 368 369 var hasConsent = function (key) { 370 if(key == ''){ 371 return false; 372 } 373 if (document.cookie.indexOf('tx_dmcookies_allow_' + key + '=1') >= 0) { 374 return true; 375 } 376 if (document.cookie.indexOf(key + '=1') >= 0) { 377 return true; 378 } 379 return false; 380 } 381 382 var init = function () { 383 addClass(root, 'has-js'); 384 addClass(wrapper, 'has-js'); 385 386 if(getCookie('close_dialoge') != tx_dmcookies_conf.confhash){ 387 resetConsent(); 388 } 389 390 handleCookies(); 391 392 window.onresize = visibility; 393 addEvent('submit', form, handleFormSubmit); 394 addEvent('click', btnClose, closeHandle); 395 addEvent('click', btnCloseconf, closeConf); 396 397 let checkboxes = root.querySelectorAll('input[type=checkbox]'); 398 checkboxes.forEach(function(checkbox){ 399 addEvent('change', checkbox, handleCheckbox); 400 }); 401 402 403 if (showDialog.length > 0) { 404 showDialog.forEach(function (showDialogElement) { 405 addEvent('click', showDialogElement, openHandle); 406 }); 407 } 408 409 if (cookieConfigToggleBtns.length > 0) { 410 cookieConfigToggleBtns.forEach(function (cookieConfigToggleBtn) { 411 addEvent('click', cookieConfigToggleBtn, handleToogleCookieInfo); 412 }); 413 } 414 415 if (getCookie('close_dialoge') == "") { 416 417 setTimeout(function () { 418 visibility(); 419 addClass(html, 'tx-dm-initial-dialog-open'); 420 addClass(body, 'tx-dm-initial-dialog-open'); 421 addClass(wrapper, 'visible'); 422 addClass(root, 'visible'); 423 }, 100) 424 setTimeout(visibility, 1000); 425 } 426 }; 427 428 return { 429 init: init, 430 showDialog: openHandle, 431 hasConsent: hasConsent, 432 handledEvents: handledEvents 433 }; 434 435})(); 436 437tx_cookie_client.init(); 438
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.