(tables, activeLevel, needle)
| 44 | } |
| 45 | |
| 46 | function 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, ...]}, ...] |
no test coverage detected