1'use strict'; 2 3class htmlElements { 4 createNewElement(tagName, tagId = null, tagClass = null, innerText = null, options = {}) { 5 let output = false; 6 7 switch (tagName) { 8 case "div": { 9 output = document.createElement(tagName); 10 break; 11 } 12 case "button": { 13 output = document.createElement(tagName); 14 break; 15 } 16 case "p": { 17 output = document.createElement(tagName); 18 break; 19 } 20 case "span": { 21 output = document.createElement(tagName); 22 break; 23 } 24 case "a": { 25 let element = document.createElement(tagName); 26 27 if (options.href) { 28 element.setAttribute("href", options.href); 29 } 30 31 if (options.target) { 32 element.setAttribute("target", options.target); 33 } 34 35 output = element; 36 break; 37 } 38 case "checkbox": { 39 const text = document.createTextNode(innerText); 40 41 let label = document.createElement("label"); 42 label.setAttribute("class", "control control--checkbox"); 43 44 let input = document.createElement("input"); 45 input.setAttribute("id", tagId); 46 input.setAttribute("type", "checkbox"); 47 input.setAttribute("checked", "checked"); 48 49 let span = document.createElement("span"); 50 span.setAttribute("class", "control__indicator"); 51 52 label.appendChild(input); 53 label.appendChild(span); 54 label.appendChild(text); 55 56 return label; 57 } 58 } 59 60 if (tagId) { 61 output.setAttribute("id", tagId); 62 } 63 64 if (tagClass) { 65 if(Array.isArray(tagClass)) { 66 output.classList.add(...tagClass); 67 } 68 else { 69 output.classList.add(tagClass); 70 } 71 } 72 73 if (innerText) { 74 output.innerText = innerText; 75 } 76 77 return output; 78 }; 79} 80 81class cookiesHandler extends htmlElements { 82 83 constructor() { 84 super(); 85 86 this.dataConsentDays = 7; 87 this.dataConsent = [ 88 { 89 "id": "cookieBannerSettingsCheckboxStrictly", 90 "label": "Notwendig" 91 }, 92 { 93 "id": "cookieBannerSettingsCheckboxPerformance", 94 "label": "Performance" 95 }, 96 { 97 "id": "cookieBannerSettingsCheckboxTargeting", 98 "label": "Targeting" 99 }, 100 { 101 "id": "cookieBannerSettingsCheckboxFunctionality", 102 "label": "Funktionalität" 103 } 104 ]; 105 } 106 107 checkCookie() { 108 if (this.getCookie('codeCookieConsent')) { 109 return true; 110 } 111 112 return false; 113 } 114 115 getCookie(name) { 116 const nameEQ = name + "="; 117 const ca = document.cookie.split(';'); 118 for (let i = 0; i < ca.length; i++) { 119 let c = ca[i]; 120 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 121 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 122 } 123 return null; 124 } 125 126 setCookie(name, value, days) { 127 let expires = ""; 128 if (days) { 129 const date = new Date(); 130 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 131 expires = "; expires=" + date.toUTCString(); 132 } 133 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 134 } 135 136 setCookieBannerAcceptAll() { 137 let cookieConsent = []; 138 this.dataConsent.forEach(e => { 139 cookieConsent.push({ 140 "id": e.id, 141 "checked": true 142 }); 143 }); 144 145 this.setCookie('codeCookieConsent', JSON.stringify(cookieConsent), this.dataConsentDays); 146 document.getElementById("cookieBanner").remove(); 147 148 const cookieBannerOverlay = document.getElementById("cookieBannerOverlay"); 149 if (cookieBannerOverlay) { 150 cookieBannerOverlay.remove(); 151 } 152 } 153 154 cookieBannerSettingsBtnSave() { 155 const checkedTopics = document 156 .getElementById("cookieBannerSettingsCheckboxRow") 157 .querySelectorAll("label>input[type=checkbox]"); 158 159 let cookieConsent = []; 160 161 checkedTopics.forEach(e => { 162 cookieConsent.push({ 163 "id": e.id, 164 "checked": e.checked 165 }); 166 }); 167 168 this.setCookie('codeCookieConsent', JSON.stringify(cookieConsent), this.dataConsentDays); 169 document.getElementById("cookieBanner").remove(); 170 document.getElementById("cookieBannerOverlay").remove(); 171 } 172 173 createBannerSettings() { 174 const mainElement = this.createNewElement( 175 "div", 176 "cookieBannerSettings"); 177 let saveButtonElement = this.createNewElement( 178 "button", 179 "cookieBannerSettingsSave", 180 "ghost", 181 "Speichern"); 182 const titleElement = this.createNewElement( 183 "p", 184 null, 185 "bold", 186 "Ihre Cookie Einstellungen manuell ändern:"); 187 const textElement = this.createNewElement( 188 "p", 189 null, 190 null, 191 "CasinoOnline.de nutzt Cookies and ähnliche Dienste. Hier können Sie entweder alle " + 192 "Cookies akzeptieren, um die Nutzung unserer Seite optimal zu gestalten, oder einzelne oder alle " + 193 "Cookies blockieren. Weitere Informationen finden Sie in unseren "); 194 const urlElement = this.createNewElement( 195 "a", 196 "cookieBannerSettingsUrl", 197 "bold", 198 "Datenschutzhinweisen", 199 {href: "https://www.casinoonline.de/datenschutzerklaerung.php", target: "_blank"}); 200 const checkboxRow = cookies.createNewElement( 201 "div", 202 "cookieBannerSettingsCheckboxRow", 203 "mb-m-4"); 204 205 this.dataConsent.forEach(e => { 206 checkboxRow.appendChild(cookies.createNewElement("checkbox", e.id, null, e.label)); 207 }); 208 209 // Find elements already created 210 const cookieBannerOverlay = document.getElementById("cookieBannerOverlay"); 211 const cookieBanner = document.getElementById("cookieBanner"); 212 const cookieBannerText = document.getElementById("cookieBannerText"); 213 const cookieBannerBtnSettings = document.getElementById("cookieBannerBtnSettings"); 214 const cookieBannerBtnAcceptAll = document.getElementById("cookieBannerBtnAcceptAll"); 215 const period = document.createTextNode("."); 216 217 // Actions 218 textElement.appendChild(urlElement); 219 textElement.appendChild(period); 220 221 mainElement.appendChild(titleElement); 222 mainElement.appendChild(textElement); 223 mainElement.appendChild(checkboxRow); 224 225 cookieBanner.insertBefore(mainElement, cookieBanner.firstChild); 226 cookieBanner.insertBefore(saveButtonElement, cookieBannerBtnAcceptAll); 227 cookieBanner.setAttribute("class", "flex-wrap justify-content-end rebrand opened"); 228 229 cookieBannerText.remove(); 230 cookieBannerBtnSettings.remove(); 231 232 cookieBannerOverlay.setAttribute("class", "active-overlay"); 233 234 saveButtonElement.setAttribute("id", "cookieBannerSettingsBtnSave"); 235 saveButtonElement.addEventListener("click", () => { 236 cookies.cookieBannerSettingsBtnSave(); 237 }); 238 } 239
240 setCookieBannerSettings() { 241 if (!document.getElementById("cookieBannerSettings")) { 242 cookies.createBannerSettings(); 243 } 244 }; 245 246 setCookieBanner() { 247 let cookieBannerBtnSettings = this.createNewElement( 248 "button", 249 "cookieBannerBtnSettings", 250 "ghost", 251 "Cookie Einstellungen"); 252 253 cookieBannerBtnSettings.addEventListener("click", e => { 254 e.preventDefault(); 255 this.setCookieBannerSettings(); 256 }); 257 258 let cookieBannerBtnAcceptAll = this.createNewElement( 259 "button", 260 "cookieBannerBtnAcceptAll", 261 "secondary", 262 null); 263 cookieBannerBtnAcceptAll.addEventListener("click", e => { 264 e.preventDefault(); 265 cookies.setCookieBannerAcceptAll(); 266 }); 267 268 let cookieBannerText = document.createElement("p"); 269 cookieBannerText.setAttribute("id", "cookieBannerText"); 270 cookieBannerText.innerText = "ðª Wir verwenden Cookies, um die Webseite zu vereinfachen. "; 271 272 let urlElement = this.createNewElement( 273 "a", 274 "cookieBannerSettingsUrl", 275 "bold", 276 "Datenschutzhinweisen", 277 {href: "https://www.casinoonline.de/datenschutzerklaerung.php", target: "_blank"}); 278 279 cookieBannerText.appendChild(urlElement); 280 281 let cookieBannerBtnAcceptAllIcon = document. createElementNS("http://www.w3.org/2000/svg", "svg"); 282 cookieBannerBtnAcceptAllIcon.innerHTML = "<use xlink:href='/_atomic/assets/icons/icons.svg#ic-checkmark'></use>"; 283 284 let cookieBannerBtnAcceptAllText = document.createTextNode(" Ich stimme zu"); 285 cookieBannerBtnAcceptAll.appendChild(cookieBannerBtnAcceptAllIcon); 286 cookieBannerBtnAcceptAll.appendChild(cookieBannerBtnAcceptAllText); 287 288 let cookieBannerOverlay = document.createElement("div"); 289 cookieBannerOverlay.setAttribute("id", "cookieBannerOverlay"); 290 291 let cookieBanner = document.createElement("div"); 292 cookieBanner.setAttribute("id", "cookieBanner"); 293 cookieBanner.setAttribute("class", "justify-content-center rebrand"); 294 295 document.body.appendChild(cookieBannerOverlay); 296 cookieBannerOverlay.appendChild(cookieBanner); 297 cookieBanner.appendChild(cookieBannerText); 298 cookieBanner.appendChild(cookieBannerBtnSettings); 299 cookieBanner.appendChild(cookieBannerBtnAcceptAll); 300 } 301} 302 303const cookies = new cookiesHandler(); 304 305if (!cookies.checkCookie()) { 306 cookies.setCookieBanner(); 307}
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.