Files

20 lines
651 B
JavaScript
Raw Permalink Normal View History

// Index page filter: hides rows and groups that do not match. Without
// JavaScript the full list stays visible.
(function () {
var box = document.getElementById("filter");
if (!box) return;
var groups = document.querySelectorAll("section.group");
box.addEventListener("input", function () {
var q = box.value.trim().toLowerCase();
groups.forEach(function (g) {
var shown = 0;
g.querySelectorAll("tbody tr").forEach(function (tr) {
var hit = q === "" || tr.textContent.toLowerCase().indexOf(q) !== -1;
tr.hidden = !hit;
if (hit) shown++;
});
g.hidden = shown === 0;
});
});
})();