1if (document.readyState === 'complete') { 2 hwCookieBanner(); 3} else { 4 document.addEventListener('readystatechange', () => { 5 if (document.readyState === 'complete') { 6 hwCookieBanner(); 7 } 8 }); 9} 10 11export function hwCookieBanner() { 12 13 // Container for the full text 14 var cookieBannerFull = document.getElementById('hw_datenschutz_banner__full'); 15 16 var cookieBannerSmallWrap = document.getElementById('hw_datenschutz_banner__small'); 17 18 var scrollContainer = document.getElementById('hw_datenschutz_banner__content'); 19 20 var acceptableCookieCheckBoxes = []; 21 22 // Variable to save the opening element 23 var cookieBannerOpeningElement = null; 24 25 var globalTrackingReload = false; 26 27 // Small cookie Banner 28 if (cookieBannerSmallWrap && cookieBannerFull) { 29 30 var cookieBannerVersion = cookieBannerSmallWrap.dataset.version; 31 32 let allCookieCheckBoxes = cookieBannerFull.getElementsByTagName('input'); 33 let cookieBannerSmallDenyAll = document.getElementById('hw_datenschutz_banner__none'); 34 let cookieBannerSmallAcceptAll = document.getElementById('hw_datenschutz_banner__all'); 35 let cookieBannerSmallAcceptAllType = false;
36 if (cookieBannerSmallAcceptAll) { 37 cookieBannerSmallAcceptAllType = cookieBannerSmallAcceptAll.dataset.action; 38 } 39 let cookieBannerSmallMore = document.getElementById('hw_datenschutz_banner__additional'); 40 let frameOpenButtons = document.querySelectorAll('.hw_datenschutz_frame .hw_cookiebanner__open--full'); 41 42 let cookieBannerApprovedName = cookieBannerSmallWrap.dataset.ckap; 43 let cookieBannerApprovedVersion = cookieBannerSmallWrap.dataset.version; 44 let cookieBannerOpenClass = cookieBannerSmallWrap.dataset.ccbi; 45 46 if (getCookieValue(cookieBannerApprovedName) === cookieBannerApprovedVersion && cookieBannerSmallWrap.classList.contains(cookieBannerOpenClass)) { 47 cookieBannerSmallWrap.classList.remove(cookieBannerOpenClass); 48 } 49 const urlParams = new URLSearchParams(window.location.search); 50 51 // Check if the "appv3mode" parameter exists and is set to "yes" 52 if (urlParams.has('appv3mode') && urlParams.get('appv3mode') === 'yes') { 53 54 setCookieBannerVersion(cookieBannerVersion); 55 56 if (!cookieBannerSmallAcceptAllType && frameOpenButtons.length > 0) { 57 for (let i = 0; i < frameOpenButtons.length; i++) { 58 setCookie(frameOpenButtons[i].dataset.target + '_denied', 1); 59 } 60 } 61 cookieBannerSmallWrap.classList.remove('hw_datenschutz_banner_small--open'); 62 cookieBannerSmallWrap.close(); 63 } 64 65 // Button - deny all 66 cookieBannerSmallDenyAll.addEventListener('click', (e) => { 67 e.preventDefault(); 68 setCookieBannerVersion(cookieBannerVersion); 69 if (!cookieBannerSmallAcceptAllType && frameOpenButtons.length > 0) { 70 for (let i = 0; i < frameOpenButtons.length; i++) { 71 setCookie(frameOpenButtons[i].dataset.target + '_denied', 1); 72 } 73 } 74 cookieBannerSmallWrap.classList.remove('hw_datenschutz_banner_small--open'); 75 cookieBannerSmallWrap.close(); 76 }); 77 78 if (cookieBannerSmallAcceptAll) { 79 80 // Button - accept all (all or tracking) 81 cookieBannerSmallAcceptAll.addEventListener('click', (e) => { 82 83 e.preventDefault(); 84 setCookieBannerVersion(cookieBannerVersion); 85 86 if (cookieBannerSmallAcceptAllType === 'acceptalltracking') { 87 88 for (let i = 0; i < allCookieCheckBoxes.length; i++) { 89 if (allCookieCheckBoxes[i].dataset.typ === 'tracking') { 90 acceptableCookieCheckBoxes.push(allCookieCheckBoxes[i]); 91 } 92 } 93 94 for (let i = 0; i < acceptableCookieCheckBoxes.length; i++) { 95 setCookie(acceptableCookieCheckBoxes[i].dataset.key, 1); 96 } 97 } else { 98 99 let trackingReload = false; 100 101 for (let i = 0; i < allCookieCheckBoxes.length; i++) { 102 103 if (allCookieCheckBoxes[i].dataset.typ) { 104 105 acceptableCookieCheckBoxes.push(allCookieCheckBoxes[i]); 106 107 if (allCookieCheckBoxes[i].dataset.typ === 'tracking') { 108 trackingReload = true; 109 } 110 } 111 } 112 113 // the identifier is set for extra Cookies, they get handled internally via placeholder keys 114 for (let i = 0; i < acceptableCookieCheckBoxes.length; i++) { 115 if (acceptableCookieCheckBoxes[i].dataset.identifier) { 116 setCookie(acceptableCookieCheckBoxes[i].dataset.identifier, 1); 117 } else { 118 setCookie(acceptableCookieCheckBoxes[i].dataset.key, 1); 119 } 120 } 121 } 122 location.reload(); 123 }); 124 } 125 126 // Button - more - open full banner 127 cookieBannerSmallMore.addEventListener('click', (e) => { 128 e.preventDefault(); 129 cookieBannerOpeningElement = cookieBannerSmallMore; 130 cookieBannerSmallWrap.classList.remove('hw_datenschutz_banner_small--open'); 131 cookieBannerSmallWrap.close(); 132 cookieBannerFull.showModal(); 133 cookieBannerFull.classList.add('hw_datenschutz_banner__full--open'); 134 if (!cookieBannerSmallAcceptAllType && frameOpenButtons.length > 0) { 135 scrollBannerContentToTarget('hw_datenschutz_banner__content_service__'+frameOpenButtons[0].dataset.target, scrollContainer, frameOpenButtons[0].dataset.target); 136 } 137 }); 138 139 // ###### ######## ## ## ## ## ######## ### ## ## ## ## ######## ######## ###### 140 // ## ## ## ## ## ## ## ## ## ## ### ## ### ## ## ## ## ## 141 // ## ## ## ## ## ## ## ## ## ## #### ## #### ## ## ## ## ## 142 // ## ###### ## ## ## ## ######## ## ## ## ## ## ## ## ## ###### ######## ## 143 // ## ## ## ## ## ## ## ## ######### ## #### ## #### ## ## ## ## 144 // ## ## ## ## ## ## ## ## ## ## ## ### ## ### ## ## ## ## 145 // ###### ## ####### ######## ######## ######## ## ## ## ## ## ## ######## ## ## ###### 146 147 let elementsWithDataTarget = cookieBannerFull.querySelectorAll('[data-target]'); 148 let sideBarToggleButton = document.getElementById('hw_datenschutz_banner__sidebar__toggle_button'); 149 let sideBarToggleIcon = sideBarToggleButton.querySelector('i'); 150 151 // Every link with a corresponding data target, to set the event listener to scroll the inside of the cookie banner 152 if (elementsWithDataTarget.length > 0) { 153 154 for (let i = 0; i < elementsWithDataTarget.length; i++) { 155 156 elementsWithDataTarget[i].addEventListener('click', function (e) { 157 158 e.preventDefault(); 159 160 if (cookieBannerFull.classList.contains("sidebar--open")) { 161 cookieBannerFull.classList.remove("sidebar--open"); 162 sideBarToggleIcon.classList.remove('fa-xmark'); 163 sideBarToggleIcon.classList.add('fa-bars'); 164 } 165 166 scrollBannerContentToTarget(this.dataset.target, scrollContainer); 167 }); 168 } 169 } 170 171 // Button: uncheck all 172 if (document.getElementById('hw_datenschutz_banner__uncheck--all')) { 173 174 let uncheckAllButton = document.getElementById('hw_datenschutz_banner__uncheck--all'); 175 176 uncheckAllButton.addEventListener('click', (e) => { 177 e.preventDefault(); 178 179 for (let i = 0; i < cookieBannerCheckBoxes.length; i++) { 180 181 let currentBannerCheckBox = cookieBannerCheckBoxes[i]; 182 183 if (currentBannerCheckBox.checked) { 184 currentBannerCheckBox.checked = false;
185 if (currentBannerCheckBox.dataset.typ === 'tracking' && (!!getCookieValue(currentBannerCheckBox.dataset.identifier) || !!getCookieValue(currentBannerCheckBox.dataset.key))) { 186 globalTrackingReload = true; 187 } 188 } 189 } 190 }) 191 } 192 193 var cookieBannerCheckBoxes = document.querySelectorAll('#hw_datenschutz_banner__full .hw_checkbox:not([disabled="disabled"])'); 194 var cookieBannerCheckBoxesContent = scrollContainer.querySelectorAll('#hw_datenschutz_banner__full .hw_checkbox:not([disabled="disabled"])'); 195 196 // add EventListener to tracking cookie-checkboxes to reload on uncheck 197 for (let i = 0; i < cookieBannerCheckBoxes.length; i++) { 198 199 let currentBannerCheckBox = cookieBannerCheckBoxes[i]; 200 201 if (currentBannerCheckBox.dataset.typ === 'tracking' && (currentBannerCheckBox.dataset.identifier || currentBannerCheckBox.dataset.key)) { 202 203 currentBannerCheckBox.addEventListener('click', () => { 204 if (!!getCookieValue(currentBannerCheckBox.dataset.identifier) || !!getCookieValue(currentBannerCheckBox.dataset.key)) { 205 globalTrackingReload = true; 206 } 207 }) 208 } 209 } 210 211 // Button: check all 212 if (document.getElementById('hw_datenschutz_banner__check--all')) { 213 214 let checkAllButton = document.getElementById('hw_datenschutz_banner__check--all'); 215 216 checkAllButton.addEventListener('click', (e) => { 217 e.preventDefault(); 218 219 for (let i = 0; i < cookieBannerCheckBoxes.length; i++) { 220 if (!cookieBannerCheckBoxes[i].checked) cookieBannerCheckBoxes[i].checked = true; 221 } 222 }) 223 } 224 225 // Button: save and quit 226 if (document.getElementById('hw_datenschutz_banner__submit')) { 227 228 let submitButton = document.getElementById('hw_datenschutz_banner__submit'); 229 230 submitButton.addEventListener('click', (e) => { 231 232 e.preventDefault(); 233 234 let checkedBoxes = []; 235 let notCheckedBoxes = []; 236 let trackingReload = false; 237 238 for (let i = 0; i < cookieBannerCheckBoxesContent.length; i++) { 239 if (cookieBannerCheckBoxesContent[i].checked) { 240 checkedBoxes.push(cookieBannerCheckBoxesContent[i]); 241 } else { 242 notCheckedBoxes.push(cookieBannerCheckBoxesContent[i]); 243 } 244 } 245 246 for (let i = 0; i < checkedBoxes.length; i++) { 247 248 if (checkedBoxes[i].dataset.identifier) { 249 if (checkedBoxes[i].dataset.typ === 'tracking') trackingReload = true; 250 setCookie(checkedBoxes[i].dataset.identifier, 1); 251 } else { 252 if (checkedBoxes[i].dataset.typ === 'tracking') trackingReload = true; 253 setCookie(checkedBoxes[i].dataset.key, 1); 254 } 255 } 256 257 for (let i = 0; i < notCheckedBoxes.length; i++) { 258 259 if (notCheckedBoxes[i].dataset.identifier) { 260 if (!!getCookieValue(notCheckedBoxes[i].dataset.identifier)) { 261 setCookie(notCheckedBoxes[i].dataset.identifier, 0, -30); 262 } 263 } else { 264 if (!!getCookieValue(notCheckedBoxes[i].dataset.key)) { 265 setCookie(notCheckedBoxes[i].dataset.key, 0, -30); 266 } 267 } 268 } 269 270 // Reload the page is there is any cookie banner, or we saved/delete a tracking cookie 271 if (document.getElementsByClassName('hw_datenschutz_frame').length > 0 || trackingReload || globalTrackingReload) { 272 273 setCookieBannerVersion(cookieBannerVersion); 274 location.reload(); 275 } else { 276
277 setCookieBannerVersion(cookieBannerVersion); 278 cookieBannerSmallWrap.classList.remove('hw_datenschutz_banner_small--open'); 279 cookieBannerSmallWrap.close(); 280 cookieBannerFull.classList.remove('hw_datenschutz_banner__full--open'); 281 cookieBannerFull.close(); 282 283 if (cookieBannerOpeningElement !== cookieBannerSmallMore) { 284 cookieBannerOpeningElement.focus(); 285 } 286 } 287 }) 288 } 289 290 // Sidebar toggle button 291 if (sideBarToggleButton) { 292 293 sideBarToggleButton.addEventListener('click', (e) => { 294 295 e.preventDefault(); 296 297 if (sideBarToggleButton.getAttribute('aria-pressed')) { 298 sideBarToggleButton.setAttribute('aria-pressed', 'false'); 299 } else { 300 sideBarToggleButton.setAttribute('aria-pressed', 'true'); 301 } 302 303 if (cookieBannerFull.classList.contains("sidebar--open")) { 304 cookieBannerFull.classList.remove("sidebar--open"); 305 sideBarToggleIcon.classList.remove('fa-xmark'); 306 sideBarToggleIcon.classList.add('fa-bars'); 307 } else { 308 cookieBannerFull.classList.add("sidebar--open"); 309 sideBarToggleIcon.classList.remove('fa-bars'); 310 sideBarToggleIcon.classList.add('fa-xmark'); 311 } 312 }); 313 314 scrollContainer.addEventListener('click', (e) => { 315 if (cookieBannerFull.classList.contains("sidebar--open")) { 316 cookieBannerFull.classList.remove("sidebar--open"); 317 sideBarToggleIcon.classList.remove('fa-xmark'); 318 sideBarToggleIcon.classList.add('fa-bars'); 319 } 320 }); 321 322 window.addEventListener('orientationchange', () => { 323 setTimeout(() => { 324 if (window.innerWidth > 639 && cookieBannerFull.classList.contains("sidebar--open")) { 325 cookieBannerFull.classList.remove("sidebar--open"); 326 sideBarToggleIcon.classList.remove('fa-xmark'); 327 sideBarToggleIcon.classList.add('fa-bars'); 328 } 329 }, 25) 330 }) 331 } 332 333 // Check the other input checkbox for list and content 334 335 let missingTagElements = []; 336 337 let sideBar = document.getElementById('hw_datenschutz_banner__sidebar'); 338 let sideBarCheckBoxes = sideBar.querySelectorAll('input[type="checkbox"]:not([disabled="disabled"])') 339 340 if (sideBarCheckBoxes.length > 0 && cookieBannerCheckBoxesContent.length > 0 && sideBarCheckBoxes.length === cookieBannerCheckBoxesContent.length) { 341 342 for (let i = 0; i < sideBarCheckBoxes.length; i++) { 343 344 sideBarCheckBoxes[i].addEventListener("click", (e) => { 345 346 let otherTarget = 'hw_datenschutz_banner__check__' + sideBarCheckBoxes[i].dataset.key; 347 let otherElement; 348 349 for (let j = 0; j < cookieBannerCheckBoxesContent.length; j++) { 350 if (cookieBannerCheckBoxesContent[j].id === otherTarget) { 351 otherElement = cookieBannerCheckBoxesContent[j]; 352 } 353 } 354 355 otherElement.checked = !!sideBarCheckBoxes[i].checked; 356 357 alertTagManager(otherElement, missingTagElements, scrollContainer); 358 }); 359 } 360 361 for (let i = 0; i < cookieBannerCheckBoxesContent.length; i++) { 362 363 cookieBannerCheckBoxesContent[i].addEventListener("click", (e) => { 364 365 let otherTarget = 'hw_datenschutz_banner__check_sidebar__' + cookieBannerCheckBoxesContent[i].dataset.key; 366 let otherElement; 367 368 for (let j = 0; j < sideBarCheckBoxes.length; j++ ) { 369 if (sideBarCheckBoxes[j].id === otherTarget) { 370 otherElement = sideBarCheckBoxes[j]; 371 } 372 } 373 374 otherElement.checked = !!cookieBannerCheckBoxesContent[i].checked; 375 376 alertTagManager(cookieBannerCheckBoxesContent[i], missingTagElements, scrollContainer); 377 }); 378 } 379 } 380 381 // close cookie banner on click inside the bgr 382 let backgroundOverlay = document.getElementById('hw_datenschutz__overlay'); 383 384 if (backgroundOverlay) { 385 backgroundOverlay.addEventListener('click', (e) => { 386 387 cookieBannerFull.classList.remove('hw_datenschutz_banner__full--open'); 388 cookieBannerFull.close(); 389 390 if (cookieBannerOpeningElement === cookieBannerSmallMore) { 391 cookieBannerSmallWrap.classList.add('hw_datenschutz_banner_small--open'); 392 cookieBannerSmallWrap.show(); 393 } else { 394 cookieBannerOpeningElement.focus(); 395 } 396 }) 397 } 398 399 // close cookie banner on click to dialog modal itself (includes backdrop, not the dialogs content) 400 const datenschutzBannerFull = document.querySelector('#hw_datenschutz_banner__full'); 401 402 if (datenschutzBannerFull) { 403 datenschutzBannerFull.addEventListener('click', (e) => { 404 if (e.target !== datenschutzBannerFull) { 405 return; 406 } 407 408 cookieBannerFull.classList.remove('hw_datenschutz_banner__full--open'); 409 cookieBannerFull.close(); 410 411 if (cookieBannerOpeningElement === cookieBannerSmallMore) { 412 cookieBannerSmallWrap.classList.add('hw_datenschutz_banner_small--open'); 413 cookieBannerSmallWrap.show(); 414 } else { 415 cookieBannerOpeningElement.focus(); 416 } 417 }); 418 } 419 420 // global links to open the cookie-banner and the corresponding cookie 421 422 if (document.getElementsByClassName('hwcookiebanner-open-full') || document.getElementsByClassName('hw_cookiebanner__open--full')) { 423 424 let cookieBannerOpenPopupLinks = document.querySelectorAll('.hwcookiebanner-open-full, .hw_cookiebanner__open--full'); 425 426 for (let i = 0; i < cookieBannerOpenPopupLinks.length; i++) { 427 428 cookieBannerOpenPopupLinks[i].addEventListener('click', (e) => { 429 430 if (!(cookieBannerOpenPopupLinks[i].classList.contains('hwcookiebanner-open-full') || cookieBannerOpenPopupLinks[i].classList.contains('hw_cookiebanner__open--full'))) { 431 return; 432 } 433 434 e.preventDefault(); 435 436 if (!cookieBannerFull.classList.contains('hw_datenschutz_banner__full--open')) { 437 cookieBannerFull.showModal(); 438 cookieBannerFull.classList.add('hw_datenschutz_banner__full--open'); 439 } 440 let scrollTarget = cookieBannerOpenPopupLinks[i].dataset.target; 441 if (scrollTarget !== '') { 442 if (scrollTarget === 'essentiell' || scrollTarget === 'funktionell' ) { 443 scrollBannerContentToTarget('hw_datenschutz_banner__content_group__'+scrollTarget, scrollContainer); 444 } else { 445 scrollBannerContentToTarget('hw_datenschutz_banner__content_service__'+scrollTarget, scrollContainer, scrollTarget); 446 } 447 } 448 cookieBannerOpeningElement = cookieBannerOpenPopupLinks[i]; 449 }) 450 } 451 } 452 if (document.getElementsByClassName('hw_cookiebanner_accept_reload')) { 453 454 let cookieBannerAcceptReloadElements = document.getElementsByClassName('hw_cookiebanner_accept_reload'); 455 456 for (let i = 0; i < cookieBannerAcceptReloadElements.length; i++) { 457 458 cookieBannerAcceptReloadElements[i].addEventListener('click', (e) => { 459 460 e.preventDefault(); 461 462 if (cookieBannerAcceptReloadElements[i].dataset.target) {
463 setCookieBannerVersion(cookieBannerVersion); 464 setCookie(cookieBannerAcceptReloadElements[i].dataset.target, 1); 465 location.reload(); 466 } 467 }) 468 } 469 } 470 471 if (frameOpenButtons.length > 0 && !cookieBannerSmallAcceptAllType) { 472 473 if (!getCookieValue('approved') && cookieBannerSmallWrap.dataset.hide !== '1') { 474 cookieBannerSmallWrap.classList.add('hw_datenschutz_banner_small--open'); 475 cookieBannerSmallWrap.show(); 476 } else { 477 478 for (let i = 0; i < frameOpenButtons.length; i++) { 479 let tempCookieValue = getCookieValue(frameOpenButtons[i].dataset.target + '_denied'); 480 if (getCookieValue(frameOpenButtons[i].dataset.target) !== '1' && !tempCookieValue && tempCookieValue !== '-2' && cookieBannerSmallWrap.dataset.hide !== '1') { 481 cookieBannerSmallWrap.classList.add('hw_datenschutz_banner_small--open'); 482 cookieBannerSmallWrap.show(); 483 break; 484 } 485 } 486 } 487 } 488 } 489} 490 491/* 492###### ## ## ######## ## ######## ######## ######## ###### 493## ## ## ## ## ## ## ## ## ## ## 494## ## ## ## ## ## ## ## ## ## ## 495## ######### ###### ## ######## ###### ######## ## 496## ## ## ## ## ## ## ## ## ## 497## ## ## ## ## ## ## ## ## ## 498###### ## ## ######## ######## ## ######## ## ## ###### 499*/ 500 501export function setCookieBannerVersion(cookieBannerVersion) { 502 if (getCookieValue('approved') !== cookieBannerVersion) { 503 setCookie('approved', cookieBannerVersion); 504 } 505} 506 507export function setCookie(cookieName, cookieValue, expirationDays = 30) { 508 let date = new Date(); 509 date.setTime(date.getTime() + (expirationDays * 24 * 60 * 60 * 1000)); 510 const expires = "expires=" + date.toUTCString(); 511 document.cookie = "hwdatenschutz_cookie_" + cookieName + "=" + cookieValue + "; " + expires + "; path=/; SameSite=Lax"; 512 513 // Emit cookie set event
514 const setCookieEvent = new CustomEvent('Hw:cookie_change', { 515 detail: { 516 cookie: document.cookie 517 } 518 }); 519 document.dispatchEvent(setCookieEvent); 520} 521 522export function getCookieValue(cookieName) { 523 const cookieNameComplete = "hwdatenschutz_cookie_" + cookieName + "="; 524 const cookieArray = document.cookie.split('; '); 525 let returnCookieValue = 0; 526 cookieArray.forEach(value => { 527 if (value.indexOf(cookieNameComplete) === 0) { 528 returnCookieValue = value.substring(cookieNameComplete.length); 529 } 530 }) 531 return returnCookieValue; 532} 533 534export function scrollBannerContentToTarget(targetId, scrollingElement, targetParam = '') { 535 536 let targetElement = document.getElementById(targetId); 537 if (targetElement === null && targetParam !== '') { 538 const selector = '[data-identifier="'+targetParam+'"]'; 539 targetElement = document.querySelector(selector); 540 } 541 542 if (targetElement && scrollingElement) { 543 544 const firstBannerHeaderHeight = document.getElementsByClassName('hw_datenschutz_banner__content_header')[0].clientHeight; 545 const firstBannerHeaderStyle = getComputedStyle(document.getElementsByClassName('hw_datenschutz_banner__content_header')[0]); 546 const firstBannerDescriptionHeight = document.getElementsByClassName('hw_datenschutz_banner__content_description')[0].clientHeight; 547 const firstBannerDescriptionStyle = getComputedStyle(document.getElementsByClassName('hw_datenschutz_banner__content_description')[0]); 548 549 const preHeight = firstBannerHeaderHeight + parseInt(firstBannerHeaderStyle.marginTop) + parseInt(firstBannerHeaderStyle.marginBottom) + firstBannerDescriptionHeight + + parseInt(firstBannerDescriptionStyle.marginTop) + parseInt(firstBannerDescriptionStyle.marginBottom); 550 const containerOffSet = scrollingElement.getBoundingClientRect().top; 551 552 window.setTimeout(() => { 553 554 const targetRectTop = targetElement.getBoundingClientRect().top; 555 const scrollTo = targetRectTop - containerOffSet - preHeight; 556 557 scrollingElement.scrollBy({ 558 top: scrollTo, 559 left: 0, 560 behavior: 'auto' 561 }); 562 }, ); 563 564 if(targetElement.nodeName === 'INPUT') { 565 targetElement.focus(); 566 } else { 567 targetElement.querySelector('input').focus(); 568 } 569 } 570} 571 572 573function alertTagManager(cookieBannerCheckBoxesContentElement, missingTagElements, scrollContainer) { 574 575 576 const initialColor = cookieBannerCheckBoxesContentElement.nextElementSibling.style.color; 577 578 const language = navigator.language || navigator.userLanguage; 579 580 if ((cookieBannerCheckBoxesContentElement.name).toLowerCase().includes('consentmode')) { 581 582 scrollBannerContentToTarget(cookieBannerCheckBoxesContentElement.id, scrollContainer); 583 584 if(document.getElementById('hw_datenschutz_banner__check__googletagmanagerExtended') === null) { 585 console.error('Enable Google Tag Manager with consent mode'); 586 } 587 588 if (!document.getElementById('hw_datenschutz_banner__check__googletagmanagerExtended').checked) { 589 cookieBannerCheckBoxesContentElement.nextElementSibling.style.color = 'red'; 590 591 if (!missingTagElements.includes(cookieBannerCheckBoxesContentElement.nextElementSibling)) { 592 missingTagElements.push(cookieBannerCheckBoxesContentElement.nextElementSibling); 593 } 594 595 if (cookieBannerCheckBoxesContentElement.nextElementSibling.nextElementSibling === null || !(cookieBannerCheckBoxesContentElement.nextElementSibling.nextElementSibling.classList.contains('hw_checkbox__label__alert'))) { 596 597 // Create a new div element for the message 598 const acceptMessageElement = document.createElement('label'); 599 acceptMessageElement.className = 'hw_checkbox__label hw_checkbox__label__alert'; 600 acceptMessageElement.style.color = 'red'; 601 602 let message = ''; 603 604 // Use a switch statement to handle different languages 605 switch (language.slice(0, 2)) { 606 case 'en': 607 message = 'Please also accept the Google Tag Manager.'; 608 break; 609 case 'de': 610 message = 'Bitte akzeptieren Sie auÃerdem das Cookie für den Google Tag Manager.'; 611 break; 612 case 'fr': 613 message = 'Veuillez également accepter le cookie pour le Google Tag Manager.'; 614 break; 615 case 'nl': 616 message = 'Accepteer ook de cookie voor Google Tag Manager.'; 617 break; 618 case 'es': 619 message = 'Por favor, acepte también la cookie para el Google Tag Manager.'; 620 break; 621 default: 622 // Fallback message in English if language not supported 623 message = 'Please also accept the Google Tag Manager.'; 624 break; 625 } 626 // Set the text content of the newly created div 627 acceptMessageElement.textContent = message; 628 cookieBannerCheckBoxesContentElement.nextElementSibling.insertAdjacentElement('afterend', acceptMessageElement); 629 } 630 } else { 631 632 const alertElements = document.querySelectorAll('.hw_checkbox__label__alert');
633 alertElements.forEach(element => { 634 element.remove(); 635 }); 636 missingTagElements.forEach(element => { 637 element.style.color = initialColor; 638 }); 639 } 640 } 641 642 if ((cookieBannerCheckBoxesContentElement.name).toLowerCase().includes('googletagmanagerextended') && !!cookieBannerCheckBoxesContentElement.checked) { 643 644 const alertElements = document.querySelectorAll('.hw_checkbox__label__alert'); 645 alertElements.forEach(element => { 646 element.remove(); 647 }); 648 missingTagElements.forEach(element => { 649 element.style.color = initialColor; 650 }); 651 } 652}
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.