Skip to content

Commit 711e0f8

Browse files
authored
Update index.html
1 parent 6b011bb commit 711e0f8

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

index.html

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<body>
1313
<h1><a href="https://github.com/MikeCZ23/CCCL">Colonization Construction Commodities List</a></h1>
1414

15+
<!-- <button id="resetFilters">Resetovat filtr</button> -->
16+
1517
<table id="myTable" class="display">
1618
<thead>
1719
<tr>
@@ -953,7 +955,7 @@ <h1><a href="https://github.com/MikeCZ23/CCCL">Colonization Construction Commodi
953955
</tbody>
954956
</table>
955957

956-
<script>
958+
<script>
957959
$(document).ready(function () {
958960
const table = $('#myTable').DataTable({
959961
language: {
@@ -962,7 +964,32 @@ <h1><a href="https://github.com/MikeCZ23/CCCL">Colonization Construction Commodi
962964
pageLength: 100,
963965
order: [[1, 'asc']],
964966
});
967+
968+
// Kliknutí na hlavičku sloupce pro filtr
969+
$('#myTable thead th').on('click', function () {
970+
const colIndex = $(this).index();
971+
const th = $(this);
972+
const isFiltered = th.hasClass('filtered');
973+
974+
// Přepínání filtru
975+
if (isFiltered) {
976+
table.column(colIndex).search('').draw(); // Reset filtru
977+
th.removeClass('filtered'); // Odebrání indikace
978+
} else {
979+
table.column(colIndex).search('^(?!\\s*$).+', true, false).draw(); // Filtr na neprázdné buňky
980+
th.addClass('filtered'); // Přidání indikace
981+
}
982+
});
983+
984+
// Reset všech filtrů a vizuální indikace
985+
$('#resetFilters').on('click', function () {
986+
table.search('') // Reset globálního vyhledávání
987+
.columns().search('') // Reset filtrů všech sloupců
988+
.order([[1, 'asc']]) // Reset řazení na výchozí hodnotu
989+
.draw(); // Obnova zobrazení tabulky
990+
$('#myTable thead th').removeClass('filtered'); // Odebrání indikace ze všech sloupců
991+
});
965992
});
966-
</script>
993+
</script>
967994
</body>
968995
</html>

0 commit comments

Comments
 (0)