(function() { const qs = (sel) => document.querySelector(sel); const initIndexSearch = () => { const input = document.querySelector("[data-index-search]"); if (!input) return; const targetSel = input.getAttribute("data-target"); const target = targetSel ? qs(targetSel) : null; const indexUrl = input.getAttribute("data-index-url"); if (!target || !indexUrl) return; let cached = []; fetch(indexUrl) .then((resp) => resp.json()) .then((data) => { cached = data.items || []; }) .catch(() => { target.innerHTML = "

Index unavailable.

"; }); const render = (term) => { if (!cached.length) return; const value = term.trim().toLowerCase(); const results = cached.filter((row) => { if (!value) return false; return row.cve_id.toLowerCase().includes(value) || (row.top_languages || []).join(" ").toLowerCase().includes(value) || String(row.max_score || "").includes(value); }).slice(0, 40); if (!results.length) { target.innerHTML = "

No matches yet.

"; return; } target.innerHTML = results.map((row) => { const langs = (row.top_languages || []).map((lang) => `${lang}`).join(" "); return `
${row.cve_id}
${row.high_confidence} high ${row.medium_confidence} med ${row.poc_count} PoCs
Max score ${row.max_score || 0}
${langs}
`; }).join(""); }; input.addEventListener("input", (e) => render(e.target.value)); }; document.addEventListener("DOMContentLoaded", () => { initIndexSearch(); }); })();