From 9cfcfaee6765c2b0e78b846f1f4fdd1396f21d8e Mon Sep 17 00:00:00 2001 From: kritzl Date: Thu, 6 Jun 2024 15:31:42 +0200 Subject: [PATCH] display filter info --- elevators.js | 13 ++++++++++++- index.html | 2 +- style.css | 5 +++++ style.css.map | 2 +- style.scss | 15 ++++++--------- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/elevators.js b/elevators.js index 53d452c..ea999f4 100644 --- a/elevators.js +++ b/elevators.js @@ -566,6 +566,10 @@ ${station.state.unavailable ? `Bei ${station.state.unavailable} ${station.state. } + listContainer.insertAdjacentHTML('beforeend', `
  • +0 von 0 Stationen durch Filter ausgeblendet. +
  • `); + listContainer.querySelectorAll(`details`).forEach(e => { e.addEventListener("toggle", (event) => { const stationId = event.target.dataset['stationid']; @@ -646,6 +650,8 @@ function filterData() { if(typeS.dataset.pressed === 'true') activeTypes.push('S'); if(typeA.dataset.pressed === 'true') activeTypes.push('A'); if(typeR.dataset.pressed === 'true') activeTypes.push('R'); + const stationCount = internalData.stations.length; + let filteredStations = 0; if (internalData) { for (const stationIndex in internalData.stations) { const matchesSearch = internalData.stations[stationIndex].name.toLowerCase().search(searchString.toLowerCase()) >= 0; @@ -653,8 +659,13 @@ function filterData() { internalData.stations[stationIndex].types.forEach(type => { if(activeTypes.includes(type)) matchesType = true; }) - document.querySelector(`#station_${stationIndex}`).classList.toggle('hidden', !(matchesSearch && matchesType)); + const filtered = !(matchesSearch && matchesType); + document.querySelector(`#station_${stationIndex}`).classList.toggle('hidden', filtered); + if(filtered) filteredStations++; } + + document.querySelector('#stationCount').innerHTML = stationCount; + document.querySelector('#filteredCount').innerHTML = filteredStations; } } diff --git a/index.html b/index.html index b5bccbc..b676958 100644 --- a/index.html +++ b/index.html @@ -65,7 +65,7 @@