summaryrefslogtreecommitdiff
path: root/static/filter.js
diff options
context:
space:
mode:
authorArne Rief <riearn@proton.me>2026-03-27 11:29:40 +0100
committerArne Rief <riearn@proton.me>2026-03-27 11:29:40 +0100
commite0ca887623682d059c6513a1ce36228d4e8c4f21 (patch)
tree87c4304b4c1b7fc28acaa230485f12730b04fc9c /static/filter.js
Upload to web repoHEADmaster
Diffstat (limited to 'static/filter.js')
-rw-r--r--static/filter.js34
1 files changed, 34 insertions, 0 deletions
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";
+ }
+ }
+ }
+}