1let _clickHandler = null; 2let _destroyFn = null; 3 4export function initCookiePage() { 5 function getSubmitButton() { 6 return document.querySelector(`button[data-cookie-action="saveChoices"]`); 7 } 8 9 function setCheckboxesChecked(checked) { 10 const checkboxes = document.querySelectorAll(`input[type="checkbox"]:not([required])`); 11 checkboxes.forEach((checkbox) => { 12 checkbox.checked = checked; 13 }); 14 } 15 16 _clickHandler = (e) => { 17 const { target } = e; 18 19 if (!(target instanceof HTMLButtonElement)) { 20 return; 21 } 22 23 if (target.dataset.cookieAction === "acceptNecessary") { 24 setCheckboxesChecked(false); 25 const submit = getSubmitButton(); 26 if (submit) { 27 submit.click(); 28 } 29 } 30 31 if (target.dataset.cookieAction === "acceptAll") { 32 setCheckboxesChecked(true); 33 const submit = getSubmitButton(); 34 if (submit) { 35 submit.click(); 36 } 37 } 38 }; 39 40 document.addEventListener("click", _clickHandler); 41 42 function destroy() { 43 if (_clickHandler) { 44 document.removeEventListener("click", _clickHandler); 45 _clickHandler = null; 46 } 47 } 48 49 _destroyFn = destroy; 50} 51 52export function destroyCookiePage() { 53 if (_destroyFn) { 54 _destroyFn(); 55 _destroyFn = null; 56 } 57} 58 59if (!window.__STORYBOOK_PREVIEW__) { 60 initCookiePage(); 61}
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.