MCPcopy Create free account
hub / github.com/Cicada000/VV / handleSearch

Function handleSearch

Web/script.js:598–636  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

596 }
597}
598async function handleSearch(event) {
599 event.preventDefault();
600 const query = document.getElementById("query").value.trim();
601 if (!query) return;
602 const minRatio = parseInt(document.getElementById("minRatio").value) || 50;
603 const minSimilarity =
604 parseFloat(document.getElementById("minSimilarity").value) || 0;
605 const searchForm = document.getElementById("searchForm");
606 searchForm.classList.add("searching");
607 startNaturalLoadingBar();
608
609 try {
610 const results = await SearchController.performSearch(
611 query,
612 minRatio,
613 minSimilarity,
614 );
615
616 if (results && results.status === "success") {
617 AppState.cachedResults = results.data;
618 AppState.hasMoreResults = results.data.length > AppState.itemsPerPage;
619 AppState.displayedCount = 0;
620
621 displayResults(results);
622 completeLoadingBar();
623 } else {
624 throw new Error("Invalid search results format");
625 }
626 } catch (error) {
627 console.error("Search error:", error);
628 document.getElementById("errorDisplay").textContent =
629 `搜索失败: ${error.message}`;
630 document.getElementById("errorDisplay").style.display = "block";
631 completeLoadingBar();
632 } finally {
633 enableKeywordTags();
634 searchForm.classList.remove("searching");
635 }
636}
637async function initializeApp() {
638 try {
639 await dbStorage.init().catch((error) => {});

Callers 1

initializeAppFunction · 0.70

Calls 5

startNaturalLoadingBarFunction · 0.85
displayResultsFunction · 0.85
completeLoadingBarFunction · 0.85
enableKeywordTagsFunction · 0.85
performSearchMethod · 0.80

Tested by

no test coverage detected