Skip to content

Commit

Permalink
add search field
Browse files Browse the repository at this point in the history
  • Loading branch information
piebro committed Dec 9, 2024
1 parent 597064f commit 7ba4df5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions questions/zugverbindung/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Deutsche Bahn Statistiken</title>
<link rel="stylesheet" type="text/css" href="../style.css">
<script src="../index.js"></script>
<script defer data-domain="piebro.github.io/deutsche-bahn-statistics" src="https://plausible.io/js/script.js"></script>
<!-- <script defer data-domain="piebro.github.io/deutsche-bahn-statistics" src="https://plausible.io/js/script.js"></script> -->
</head>
<body>
<!-- header generated with scripts/generate_html_links.py -->
Expand All @@ -32,7 +32,8 @@ <h1 id="Verspätungen pro Zugverbindung">Welche Fernverkehrszüge haben am meist
<p>
Viele Fernverkehrszüge haben eine eindeutige Nummer in den Daten und damit lässt sich die Pünktlichkeit und Ausfallquote aller Ferverbindungen von ICE, IC, FLX (FlixTrain) oder EC (EuroCity) ermitteln.
</p>
<div class="filter-options"></div>
<div class="filter-options">
<label>Zugname suchen: <input type="text" id="train-search"></label>
<label><input type="checkbox" id="min-samples" checked> Mindestens 100 geplante Fahrten</label>
</div>
<br>
Expand All @@ -53,12 +54,15 @@ <h1 id="Verspätungen pro Zugverbindung">Welche Fernverkehrszüge haben am meist
file: 'data/long_distance_train_stats.json',
filter: (data) => {
const minSamples = document.getElementById('min-samples').checked;
const searchTerm = document.getElementById('train-search').value.toLowerCase();

return data.filter(row => {
if (minSamples && row['sample_count'] < 100) return false;
if (searchTerm && !row['train_name'].toLowerCase().includes(searchTerm)) return false;
return true;
});
},
filterTriggerElementList: ['#min-samples']
filterTriggerElementList: ['#min-samples', '#train-search']
}
];
setupTable('table-container', files, columns, defaultSort = { column: 'sample_count', direction: 'desc' });
Expand Down

0 comments on commit 7ba4df5

Please sign in to comment.