From 897a094e253a318d79f81f7c076ebfedeecebbc2 Mon Sep 17 00:00:00 2001 From: Renato Rosa Date: Wed, 19 Aug 2026 20:51:56 -0300 Subject: [PATCH] Atualizar web/chat.js --- web/chat.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/web/chat.js b/web/chat.js index 3a14ebc..894d6c3 100644 --- a/web/chat.js +++ b/web/chat.js @@ -78,6 +78,52 @@ async function loadHistory() { }); } + +async function searchMessages() { + const q = prompt("Search:"); + const r = await fetch(`/api/search?q=${encodeURIComponent(q)}`); + const results = await r.json(); + console.log(results); +} + +async function addTags() { + const tags = prompt("Tags (comma separated):"); + await fetch(`/api/tags/${conversationId}`, { + method: "POST", + headers: {"Content-Type": "application/json"}, + body: JSON.stringify({tags: tags.split(",")}) + }); +} + +async function shareConversation() { + const email = prompt("Share with email:"); + await fetch(`/api/share/${conversationId}`, { + method: "POST", + headers: {"Content-Type": "application/json"}, + body: JSON.stringify({email}) + }); +} + +function exportMD() { + window.open(`/api/export/md/${conversationId}`, "_blank"); +} + +function exportPDF() { + window.open(`/api/export/pdf/${conversationId}`, "_blank"); +} + +async function importFile() { + const file = document.getElementById("importFile").files[0]; + const form = new FormData(); + form.append("file", file); + await fetch(`/api/import/${conversationId}`, { + method: "POST", + body: form + }); + await loadHistory(); +} + + async function sendMessage() { const promptText = document.getElementById("prompt").value; const file = document.getElementById("attachment").files[0];