1import { isProd } from './helpers.js'; 2 3export function selectCheckboxAll() { 4 const selectAllCheckboxId = isProd ? [22, 23] : [11, 12]; // id of a checkbox "Zaznaczam wszystkie zgody" 5 6 const formCheckboxElements = document.querySelectorAll( 7 '.additional-fields-wrapper input[type="checkbox"]' 8 ); // select all checkboxes in the form 9 10 const formCheckboxArray = Array.from(formCheckboxElements); 11 12 const currentCheckboxElement = formCheckboxArray.filter((checkbox) => { 13 const idArray = checkbox.id.split('_'); // id looks like additional_13 so we need to turn it into array and grab the second part that is a number 14 const checkboxId = idArray[idArray.length - 1]; // get the id of the checkbox 15 16 return selectAllCheckboxId.includes(Number(checkboxId)); // if true, return the checkbox element 17 })[0]; 18 19 currentCheckboxElement?.addEventListener('click', () => { 20 if (currentCheckboxElement.checked === true) { 21 formCheckboxElements.forEach((element) => { 22 if ( 23 element.checked !== true && 24 element.getAttribute('id') !== 25 currentCheckboxElement.getAttribute('id') 26 ) { 27 element.checked = 'true'; 28 } 29 }); 30 } 31 }); 32}
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.