ChatBot
Document search
+Find what you need, when you need it.
+Search your saved documents by the name you remember. Everything stays on this device.
+
-
+ diff --git a/index.html b/index.html index 8fa09fb..5dfaa8e 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@
-Document search
+Search your saved documents by the name you remember. Everything stays on this device.
+Keep related documents together, such as personal records or family documents.
+ + +No documents yet
'}Create a collection to narrow your search.
'}`; +} + +function isDocumentInSearchScope(doc) { + return selectedCollectionIds.size === 0 || selectedCollectionIds.has(doc.collectionId) || (selectedCollectionIds.has('__unfiled__') && !doc.collectionId); +} + +function openDocumentForEditing(doc) { + document.getElementById("docName").value = doc.name; + document.getElementById("docValue").value = doc.value; + document.getElementById("docInfo").value = doc.info || ""; + document.getElementById("docFile").value = ""; + docCollection.value = doc.collectionId || ''; + removeExistingFile.checked = false; + removeFileOption.hidden = !doc.file; + saveDocBtn.setAttribute("data-edit-id", doc.id); + popup.style.display = "flex"; +} async function generatePdfThumbnail(pdfDataURL) { const pdf = await pdfjsLib.getDocument({ url: pdfDataURL }).promise; @@ -222,12 +295,13 @@ function addMessage(content, sender) { let vault = []; (async () => { vault = await getAllDocs(); + renderCollectionControls(); })(); function findDoc(query) { query = query.toLowerCase(); - return vault.filter(d => d.name.toLowerCase().includes(query)); + return vault.filter(d => isDocumentInSearchScope(d) && d.name.toLowerCase().includes(query)); } // Typing Animation @@ -262,6 +336,7 @@ sendBtn.onclick = () => { const text = userInput.value.trim(); if (!text) return; + dismissSearchIntro(); addMessage(text, 'user'); userInput.value = ''; @@ -328,14 +403,16 @@ const showAllCmds = [ if (showAllCmds.some(cmd => lower === cmd || lower.includes(cmd))) { - if (vault.length === 0) { + const scopedVault = vault.filter(isDocumentInSearchScope); + + if (scopedVault.length === 0) { addMessage("Your vault is empty. Add a document first!", "bot"); return; } - addMessage(`You have ${vault.length} stored documents:`, "bot"); + addMessage(`You have ${scopedVault.length} stored documents in this search scope:`, "bot"); - vault.forEach((doc, index) => { + scopedVault.forEach((doc, index) => { let reply = `${index + 1}. ${doc.name}: ${doc.value}`; if (doc.info) reply += `