1document.addEventListener('DOMContentLoaded', () => { 2 const filterForm = document.getElementById('praeventivdienste-filter-form'); 3 4 const tfSuchbegriff = document.getElementById('filter-suchbegriff'); 5 const selectBL = document.getElementById('filter-bundesland'); 6 const selectDienst = document.getElementById('filter-dienst'); 7 8 const listItems = document.querySelectorAll('#element-list li'); 9 const statusText = document.getElementById('praeventivdienste-filter-status'); 10 const visualNoResults = document.getElementById('visual-no-results'); 11 12 if (!filterForm || !tfSuchbegriff || !selectBL || !statusText || !visualNoResults || !selectDienst) { 13 return; 14 } 15 16 const totalCount = listItems.length; 17 18 /** 19 * Prüft, ob der übergebene `searchText` in einem der Felder aus `item` vorkommt. 20 * @param {*} searchText 21 * @param {*} item 22 * @returns 23 */ 24 function matchWithSearchtext(searchText, item) { 25 if (!searchText || !item) { 26 return true; 27 } 28 return Array.from(item.querySelectorAll("span.praeventivdienste-searchable-content")).some( 29 (elem) => elem.innerText.trim().toLowerCase().includes(searchText) 30 ); 31 } 32 33 function filterList() { 34 const valBL = selectBL.value; 35 const valDienst = selectDienst.value.trim(); 36 const valSuchbegriff = tfSuchbegriff.value.trim().toLowerCase(); 37 let visibleCount = 0; 38 const isFilterActive = valBL !== "" || valDienst !== ""; 39 40 listItems.forEach(item => { 41 const rawBL = item.getAttribute('data-bld') || ''; 42 const rawDienstart = item.getAttribute('data-dienstart') || ''; 43 44 const matchBL = valBL === "" || rawBL.toLowerCase() === valBL.toLowerCase(); 45 const matchPLZ = valDienst === "" || rawDienstart.toLowerCase() === valDienst.toLowerCase(); 46 47 // Suche alle Felder Suchbegriff 48 var matchSuchbegriff = true; 49 if (valSuchbegriff && matchBL && matchPLZ) { 50 // Aufwaendige Textsuche nur dann durchführen, wenn das Element noch nicht herausgefiltert wurde. 51 matchSuchbegriff = matchWithSearchtext(valSuchbegriff, item); 52 } 53 54 if (matchBL && matchPLZ && matchSuchbegriff) { 55 item.classList.remove('d-none'); 56 visibleCount++; 57 } else { 58 item.classList.add('d-none'); 59 } 60 }); 61 62 if (visibleCount === 0 && isFilterActive && totalCount > 0) { 63 statusText.textContent = "Keine passenden Elemente für diese Auswahl gefunden."; 64 visualNoResults.classList.remove('d-none'); 65 } else { 66 statusText.textContent = `${visibleCount} Element(e) angezeigt.`; 67 visualNoResults.classList.add('d-none'); 68 } 69 } 70 71 filterForm.addEventListener('submit', function(event) { 72 event.preventDefault(); 73 filterList(); 74 }); 75 76 filterList(); 77});
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.