display filter info
This commit is contained in:
parent
6ebc758e25
commit
9cfcfaee67
5 changed files with 25 additions and 12 deletions
13
elevators.js
13
elevators.js
|
@ -566,6 +566,10 @@ ${station.state.unavailable ? `Bei ${station.state.unavailable} ${station.state.
|
|||
|
||||
}
|
||||
|
||||
listContainer.insertAdjacentHTML('beforeend', `<li id="filterInfo">
|
||||
<span id="filteredCount">0</span> von <span id="stationCount">0</span> Stationen durch Filter ausgeblendet.
|
||||
</li>`);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue