Zeichnen ist toll

`; const setPhpCookie = (data) => { const d = new Date(); d.setTime(d.getTime() + (365*24*60*60*1000)); document.cookie = storageKey + "=" + JSON.stringify(data) + ";expires=" + d.toUTCString() + ";path=/;SameSite=Lax"; }; const injectScript = (html, target = document.head) => { const div = document.createElement('div'); div.innerHTML = html; Array.from(div.querySelectorAll("script")).forEach(oldS => { const newS = document.createElement("script"); Array.from(oldS.attributes).forEach(a => newS.setAttribute(a.name, a.value)); newS.appendChild(document.createTextNode(oldS.innerHTML)); target.appendChild(newS); }); }; const getMigratedData = () => { const cur = localStorage.getItem(storageKey); if (cur) return JSON.parse(cur); const oldKey = Object.keys(localStorage).find(k => k.startsWith('dc_consent_')); return oldKey ? JSON.parse(localStorage.getItem(oldKey)) : null; }; const updateCheckboxes = () => { const data = getMigratedData(); if (!data) return; if (document.getElementById('dc-ch-matomo')) document.getElementById('dc-ch-matomo').checked = !!data.matomo; document.querySelectorAll('.dc-dynamic-ch').forEach(ch => { ch.checked = !!data[ch.dataset.id]; }); }; const loadContent = () => { const c = JSON.parse(localStorage.getItem(storageKey)); if(!c) return; if (c.matomo) injectScript(matomoRaw); // Matomo erst JETZT laden document.querySelectorAll('.dc-placeholder').forEach(wrapper => { if (c[wrapper.dataset.service]) { const temp = wrapper.querySelector('.dc-template'); if(temp) { wrapper.innerHTML = temp.innerHTML; injectScript(wrapper.innerHTML, wrapper); } } }); }; if (!localStorage.getItem(storageKey)) { updateCheckboxes(); overlay.style.display = 'flex'; } else { loadContent(); } const save = (all) => { const mCh = document.getElementById('dc-ch-matomo'); let data = { matomo: all || (mCh ? mCh.checked : false) }; document.querySelectorAll('.dc-dynamic-ch').forEach(ch => { data[ch.dataset.id] = all || ch.checked; }); Object.keys(localStorage).forEach(k => { if(k.startsWith('dc_consent_')) localStorage.removeItem(k); }); localStorage.setItem(storageKey, JSON.stringify(data)); setPhpCookie(data); location.reload(); }; document.getElementById('dc-btn-all').onclick = () => save(true); document.getElementById('dc-btn-save').onclick = () => save(false); document.addEventListener('click', e => { if (e.target.classList.contains('dc-open-popup') || e.target.closest('.dc-open-popup')) { e.preventDefault(); updateCheckboxes(); overlay.style.display = 'flex'; } }); });