1 2function selectAllCookieTypes() { 3 document.getElementById('cookieSettingsEssential').checked = true; 4 document.getElementById('cookieSettingsStatistics').checked = true; 5 document.getElementById('cookieSettingsThirdparty').checked = true; 6} 7 8function rejectAllCookieTypes() { 9 document.getElementById('cookieSettingsEssential').checked = true; 10 document.getElementById('cookieSettingsStatistics').checked = false; 11 document.getElementById('cookieSettingsThirdparty').checked = false; 12} 13 14function dispatchCookieSettingsEvent() { 15 var event; 16 if (typeof (Event) === 'function') { 17 event = new Event('CookieSettingsChanged'); 18 } else { 19 // do not crash the IE 20 event = document.createEvent('Event'); 21 event.initEvent('CookieSettingsChanged', true, true); 22 } 23 window.dispatchEvent(event); 24} 25 26function setCookieSettings(_cookieSettings) { 27 var cookieSettings = { 28 // dont save unused keys 29 essential: _cookieSettings.essential || true, 30 statistics: _cookieSettings.statistics || false, 31 thirdparty: _cookieSettings.thirdparty || false, 32 cookiesAccepted: _cookieSettings.cookiesAccepted || false, 33 }; 34 if (cookieSettings) { 35 localStorage.setItem('cookieSettings', JSON.stringify(cookieSettings)); 36 } else { 37 localStorage.removeItem('cookieSettings'); 38 } 39 dispatchCookieSettingsEvent(); 40} 41 42function getCookieSettings() { 43 var thisScript = document.getElementById('cookieSettingsScript'); 44 var enabled = thisScript.dataset.cookieSettingsEnabled === 'true'; 45 var tracking = thisScript.dataset.tracking === 'true'; 46 47 if (!enabled) { 48 return { 49 essential: true, 50 statistics: true, 51 thirdparty: true, 52 cookiesAccepted: true, 53 enabled: false, 54 tracking: false 55 }; 56 } 57 58 var defaultCookieSettings = { 59 essential: true, 60 statistics: false, 61 thirdparty: false, 62 cookiesAccepted: false, 63 }; 64 65 var cookieSettings = null; 66 67 try { 68 cookieSettings = JSON.parse(localStorage.getItem('cookieSettings')); 69 } catch(e) { 70 console.log(e); 71 } 72 73 if (!cookieSettings) { 74 cookieSettings = defaultCookieSettings; 75 // setCookieSettings(cookieSettings); 76 } 77 78 cookieSettings.enabled = enabled; 79 cookieSettings.tracking = tracking; 80 return cookieSettings; 81} 82 83function initCookieSettingsDialog() { 84 var cookieSettings = getCookieSettings(); 85 document.getElementById('cookieSettingsStatistics').checked = cookieSettings.statistics === true; 86 document.getElementById('cookieSettingsThirdparty').checked = cookieSettings.thirdparty === true; 87} 88 89function openCookieSettings() { 90 initCookieSettingsDialog(); 91 document.getElementById('cookieSettingsDialog').classList.remove('cm-hidden'); 92} 93 94function closeCookieSettings() { 95 document.getElementById('cookieSettingsDialog').classList.add('cm-hidden'); 96} 97 98function saveCookieSettings() { 99 var cookieSettings = getCookieSettings(); 100 var statistics = document.getElementById('cookieSettingsStatistics').checked === true; 101 var thirdparty = document.getElementById('cookieSettingsThirdparty').checked === true; 102 var reboot = cookieSettings.statistics && !statistics || cookieSettings.thirdparty && !thirdparty; 103 cookieSettings.cookiesAccepted = true; 104 cookieSettings.statistics = statistics; 105 cookieSettings.thirdparty = thirdparty; 106 setCookieSettings(cookieSettings); 107 closeCookieSettings(); 108 if (reboot) { 109 document.location.reload(); 110 } 111} 112 113function resetCookieSettings() { 114 setCookieSettings(null); 115} 116 117(function() { 118 var cookieSettings = getCookieSettings(); 119 if (cookieSettings.enabled) { 120 window.addEventListener('CookieSettingsChanged', initCookieSettingsDialog); 121 // changed outside this document 122 window.addEventListener('storage', dispatchCookieSettingsEvent); 123 if (!cookieSettings.cookiesAccepted) { 124 openCookieSettings(); 125 } 126 } 127})(); 128 129 130// neu 131 132document.addEventListener('DOMContentLoaded', function() { 133 // set popup to display none if the close btn was clicked 134 var closeBtn = document.querySelector('.cm-cookie-header__close-button'); 135 if (closeBtn) { 136 closeBtn.addEventListener('click', closeCookieSettings); 137 closeBtn.addEventListener('keypress', function(ev) { 138 if (ev.keyCode === 32 || ev.keyCode === 13) { 139 closeCookieSettings(); 140 } 141 }); 142 } 143 144 /* keyboard control for switches */ 145 var switchWrapper = document.querySelectorAll( 146 '#cookieSettingsDialog .cm-cookie-switch-wrapper, .cm-wp-container .cm-wp-content-switcher'); 147 for (var i = 0; i < switchWrapper.length; i++) { 148 switchWrapper[i].addEventListener('keypress', function(ev) { 149 if (ev.keyCode === 32 || ev.keyCode === 13) { 150 ev.target.querySelector('input').click(); 151 ev.target.setAttribute("aria-checked", ev.target.querySelector('input').checked ? 'true' : 'false'); 152 } 153 }); 154 } 155 156 /* keyboard control for buttons */ 157 var cookieButton = document.querySelectorAll('#cookieSettingsDialog .cm-cookie-button'); 158 for (var i = 0; i < cookieButton.length; i++) { 159 cookieButton[i].addEventListener('keypress', function(ev) { 160 if (ev.keyCode === 32 || ev.keyCode === 13) { 161 ev.target.click(); 162 } 163 }); 164 } 165
166 // open the expansion panels and rotating the icon 167 var toggleExpansion = function(elem) { 168 var expansionButton = elem.querySelector('.cm-cookie-content-expansion-button'); 169 var expansionPanel = elem.closest('.cm-cookie-controls').querySelector('.cm-cookie-content-expansion-text'); 170 expansionButton.classList.toggle('cm-cookie-content-expansion-button--rotate'); 171 expansionPanel.classList.toggle('cm-cookie-content-expansion-text--open'); 172 expansionButton.setAttribute("aria-expanded", expansionPanel.classList.contains('cm-cookie-content-expansion-text--open') ? 'true' : 'false'); 173 }; 174 175 var expandBtn = document.querySelectorAll('.cm-cookie-expand-wrapper'); 176 for(var i = 0; i < expandBtn.length; i++ ) { 177 expandBtn[i].addEventListener('click', function() { 178 toggleExpansion(this); 179 }); 180 expandBtn[i].addEventListener('keypress', function(ev) { 181 if (ev.keyCode === 32 || ev.keyCode === 13) { 182 toggleExpansion(this); 183 } 184 }); 185 } 186 187 /* keyboard control for footer link (space) */ 188 var footerLink = document.querySelector('#cookieSettingsDialog .cm-cookie-footer__link'); 189 if (footerLink) { 190 footerLink.addEventListener('keypress', function(ev) { 191 if (ev.keyCode === 32) { 192 ev.target.click(); 193 } 194 }); 195 } 196});
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.