From e0ca887623682d059c6513a1ce36228d4e8c4f21 Mon Sep 17 00:00:00 2001 From: Arne Rief Date: Fri, 27 Mar 2026 11:29:40 +0100 Subject: Upload to web repo --- static/filter.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 static/filter.js (limited to 'static/filter.js') diff --git a/static/filter.js b/static/filter.js new file mode 100644 index 0000000..9318c23 --- /dev/null +++ b/static/filter.js @@ -0,0 +1,34 @@ +// Filter-search a table +// Code expanded from this source: https://www.w3schools.com/howto/howto_js_filter_table.asp + +function filter() { + let selector, val; + selector = document.getElementsByName("select"); + + // Loop through the radio buttons to determine the filter-settings + for (let i = 0; i < selector.length; i++) { + if (selector[i].checked) { + val = parseInt(selector[i].value); + break; + } + } + + let input, insensitive, table, tr, td, txtValue; + input = document.getElementById("search_history"); + insensitive = input.value.toUpperCase(); + table = document.getElementById("history"); + tr = table.getElementsByTagName("tr"); + + // Loop through all table rows, and hide those that don't match the search query + for (let i = 0; i < tr.length; i++) { + td = tr[i].getElementsByTagName("td")[val]; + if (td) { + txtValue = td.textContent || td.innerText; + if (txtValue.toUpperCase().indexOf(insensitive) > -1) { + tr[i].style.display = ""; + } else { + tr[i].style.display = "none"; + } + } + } +} -- cgit v1.2.3