Spaces:
Running
Running
Update static/application.js
Browse files- static/application.js +11 -15
static/application.js
CHANGED
@@ -57,16 +57,16 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
57 |
return bubble;
|
58 |
}
|
59 |
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
}
|
70 |
|
71 |
sendBtn.addEventListener("click", async () => {
|
72 |
const question = userInput.value.trim();
|
@@ -77,13 +77,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
77 |
return;
|
78 |
}
|
79 |
|
80 |
-
// Remove preview
|
81 |
-
if (filePreviewDiv) filePreviewDiv.remove();
|
82 |
|
83 |
-
// Show user message + file
|
84 |
createMessageBubble(question, "You", null, selectedFile.name);
|
85 |
|
86 |
-
// Show thinking placeholder
|
87 |
const thinkingBubble = createMessageBubble("Chris is thinking...", "Chris");
|
88 |
|
89 |
const formData = new FormData();
|
@@ -98,8 +95,8 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
98 |
|
99 |
const result = await response.json();
|
100 |
|
101 |
-
// Replace thinking bubble with actual answer
|
102 |
thinkingBubble.querySelector(".text").innerText = result.answer || "No response received.";
|
|
|
103 |
if (result.audio) {
|
104 |
const audio = document.createElement("audio");
|
105 |
audio.controls = true;
|
@@ -112,12 +109,11 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
112 |
} catch (err) {
|
113 |
thinkingBubble.querySelector(".text").innerText = "⚠️ Chris had trouble connecting.";
|
114 |
}
|
115 |
-
|
116 |
userInput.value = "";
|
117 |
selectedFile = null;
|
118 |
});
|
119 |
|
120 |
-
// File icon handlers
|
121 |
imageIcon.addEventListener("click", () => {
|
122 |
const input = document.createElement("input");
|
123 |
input.type = "file";
|
|
|
57 |
return bubble;
|
58 |
}
|
59 |
|
60 |
+
function showFilePreview(filename, icon = "📎") {
|
61 |
+
if (filePreviewDiv) filePreviewDiv.remove();
|
62 |
|
63 |
+
filePreviewDiv = document.createElement("div");
|
64 |
+
filePreviewDiv.className = "file-preview-bubble";
|
65 |
+
filePreviewDiv.innerHTML = `${icon} <strong>Selected:</strong> ${filename}`;
|
66 |
|
67 |
+
convo.appendChild(filePreviewDiv);
|
68 |
+
scrollToBottom();
|
69 |
+
}
|
70 |
|
71 |
sendBtn.addEventListener("click", async () => {
|
72 |
const question = userInput.value.trim();
|
|
|
77 |
return;
|
78 |
}
|
79 |
|
80 |
+
if (filePreviewDiv) filePreviewDiv.remove(); // Remove preview bubble
|
|
|
81 |
|
|
|
82 |
createMessageBubble(question, "You", null, selectedFile.name);
|
83 |
|
|
|
84 |
const thinkingBubble = createMessageBubble("Chris is thinking...", "Chris");
|
85 |
|
86 |
const formData = new FormData();
|
|
|
95 |
|
96 |
const result = await response.json();
|
97 |
|
|
|
98 |
thinkingBubble.querySelector(".text").innerText = result.answer || "No response received.";
|
99 |
+
|
100 |
if (result.audio) {
|
101 |
const audio = document.createElement("audio");
|
102 |
audio.controls = true;
|
|
|
109 |
} catch (err) {
|
110 |
thinkingBubble.querySelector(".text").innerText = "⚠️ Chris had trouble connecting.";
|
111 |
}
|
112 |
+
|
113 |
userInput.value = "";
|
114 |
selectedFile = null;
|
115 |
});
|
116 |
|
|
|
117 |
imageIcon.addEventListener("click", () => {
|
118 |
const input = document.createElement("input");
|
119 |
input.type = "file";
|