MCPcopy Create free account
hub / github.com/Alfredredbird/CyberKelp / handleSearchInput

Function handleSearchInput

script.js:358–390  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

356}
357
358async function handleSearchInput() {
359 const q = searchInput.value.trim().toLowerCase();
360 searchResultsEl.innerHTML = "";
361 if (!q) return;
362
363 await ensureAllNotesLoaded();
364
365 const results = NOTES.filter((note) => {
366 const text = noteCache.get(note.path) || "";
367 return note.title.toLowerCase().includes(q) || text.toLowerCase().includes(q);
368 });
369
370 results.slice(0, 30).forEach((note) => {
371 const div = document.createElement("div");
372 div.className = "search-result";
373 div.textContent = note.title;
374 div.addEventListener("click", () => {
375 loadNote(note);
376 searchResultsEl.innerHTML = "";
377 searchInput.value = "";
378 });
379 searchResultsEl.appendChild(div);
380 });
381
382 if (results.length === 0) {
383 const empty = document.createElement("div");
384 empty.className = "search-result";
385 empty.style.color = "var(--text-muted)";
386 empty.style.cursor = "default";
387 empty.textContent = "No results found.";
388 searchResultsEl.appendChild(empty);
389 }
390}
391
392// --- Mobile sidebar toggle ------------------------------------
393

Callers

nothing calls this directly

Calls 2

ensureAllNotesLoadedFunction · 0.85
loadNoteFunction · 0.85

Tested by

no test coverage detected