MCPcopy Create free account
hub / github.com/Cosmian/kms / applyFilters

Function applyFilters

documentation/docs/javascripts/log_filter.js:46–71  ·  view source on GitHub ↗
(tables, activeLevel, needle)

Source from the content-addressed store, hash-verified

44}
45
46function applyFilters(tables, activeLevel, needle) {
47 tables.forEach((tableEl) => {
48 const tbody = tableEl.querySelector("tbody");
49 if (!tbody) return;
50 const rows = Array.from(tbody.querySelectorAll("tr"));
51
52 rows.forEach((row) => {
53 const cells = Array.from(row.querySelectorAll("td"));
54 if (!cells.length) return;
55 const levelText = cells[0].textContent.trim().toLowerCase();
56 const matchesLevel = activeLevel === "" || levelText === activeLevel;
57 const matchesSearch = needle === "" ||
58 cells.some((td) => td.textContent.toLowerCase().includes(needle));
59 row.style.display = matchesLevel && matchesSearch ? "" : "none";
60 });
61
62 // Re-sort visible rows by severity (error first → trace last)
63 const visible = rows.filter(r => r.style.display !== "none");
64 visible.sort((a, b) => {
65 const la = a.querySelector("td")?.textContent.trim().toLowerCase() || "";
66 const lb = b.querySelector("td")?.textContent.trim().toLowerCase() || "";
67 return (LEVELS.indexOf(la) ?? 99) - (LEVELS.indexOf(lb) ?? 99);
68 });
69 visible.forEach(r => tbody.appendChild(r));
70 });
71}
72
73// ── Domain section discovery ──────────────────────────────────────────────
74// Returns [{heading: h2El, tables: [tableEl, ...]}, ...]

Callers 1

buildDomainControlsFunction · 0.85

Calls 4

forEachMethod · 0.45
fromMethod · 0.45
includesMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected