ikraamkb commited on
Commit
a7c53f0
Β·
verified Β·
1 Parent(s): 8ffb8bd

Update static/application.js

Browse files
Files changed (1) hide show
  1. static/application.js +27 -26
static/application.js CHANGED
@@ -145,10 +145,9 @@
145
  // Create user's message bubble
146
  createMessageBubble(question, "You", null, selectedFile.name);
147
 
148
- // Thinking bubble
149
  const thinkingBubble = createMessageBubble("Wait, let me think πŸ€”... <div class='loader'></div>", "Aidan");
150
 
151
-
152
  const formData = new FormData();
153
  formData.append("question", question);
154
  formData.append("file", selectedFile);
@@ -163,10 +162,11 @@
163
  const answerText = result.answer || "No response.";
164
  const audioSrc = result.audio || null;
165
 
166
- // Update the thinking bubble
167
  const message = thinkingBubble.querySelector(".text");
168
- message.innerText = answerText;
169
 
 
170
  if (audioSrc) {
171
  const icon = document.createElement("i");
172
  icon.className = "fa-solid fa-volume-high audio-toggle";
@@ -217,24 +217,24 @@
217
  });
218
 
219
  const style = document.createElement('style');
220
- style.textContent = `
221
- .loader {
222
- display: inline-block;
223
- border: 2px solid #f3f3f3;
224
- border-top: 2px solid #3b82f6;
225
- border-radius: 50%;
226
- width: 16px;
227
- height: 16px;
228
- animation: spin 1s linear infinite;
229
- margin-left: 8px;
230
- }
231
- @keyframes spin {
232
- 0% { transform: rotate(0deg); }
233
- 100% { transform: rotate(360deg); }
234
- }
235
- `;
236
- document.head.appendChild(style);
237
-
238
  });
239
  */
240
  document.addEventListener("DOMContentLoaded", () => {
@@ -304,12 +304,14 @@ document.addEventListener("DOMContentLoaded", () => {
304
  if (type === "document") {
305
  filePreviewBubble.textContent = `πŸ“Ž Selected: ${file.name}`;
306
  } else if (type === "image") {
 
307
  const img = document.createElement("img");
308
  img.src = URL.createObjectURL(file);
309
  img.alt = "Selected Image";
310
- img.style.maxWidth = "200px"; // Adjust the size of the image as needed
311
- img.style.maxHeight = "200px"; // Adjust the size of the image as needed
312
- img.style.borderRadius = "8px"; // Optional, for rounded corners
 
313
  filePreviewBubble.appendChild(img);
314
  filePreviewBubble.appendChild(document.createTextNode(` Selected: ${file.name}`));
315
  }
@@ -486,5 +488,4 @@ document.addEventListener("DOMContentLoaded", () => {
486
  }
487
  `;
488
  document.head.appendChild(style);
489
-
490
  });
 
145
  // Create user's message bubble
146
  createMessageBubble(question, "You", null, selectedFile.name);
147
 
148
+ // Thinking bubble with loader
149
  const thinkingBubble = createMessageBubble("Wait, let me think πŸ€”... <div class='loader'></div>", "Aidan");
150
 
 
151
  const formData = new FormData();
152
  formData.append("question", question);
153
  formData.append("file", selectedFile);
 
162
  const answerText = result.answer || "No response.";
163
  const audioSrc = result.audio || null;
164
 
165
+ // Update the thinking bubble to show the answer text and remove the loader
166
  const message = thinkingBubble.querySelector(".text");
167
+ message.innerHTML = answerText; // Replacing with answer
168
 
169
+ // If audio exists, add audio toggle icon
170
  if (audioSrc) {
171
  const icon = document.createElement("i");
172
  icon.className = "fa-solid fa-volume-high audio-toggle";
 
217
  });
218
 
219
  const style = document.createElement('style');
220
+ style.textContent = `
221
+ .loader {
222
+ display: inline-block;
223
+ border: 2px solid #f3f3f3;
224
+ border-top: 2px solid #3b82f6;
225
+ border-radius: 50%;
226
+ width: 16px;
227
+ height: 16px;
228
+ animation: spin 1s linear infinite;
229
+ margin-left: 8px;
230
+ }
231
+ @keyframes spin {
232
+ 0% { transform: rotate(0deg); }
233
+ 100% { transform: rotate(360deg); }
234
+ }
235
+ `;
236
+ document.head.appendChild(style);
237
+
238
  });
239
  */
240
  document.addEventListener("DOMContentLoaded", () => {
 
304
  if (type === "document") {
305
  filePreviewBubble.textContent = `πŸ“Ž Selected: ${file.name}`;
306
  } else if (type === "image") {
307
+ // Create an image element for preview
308
  const img = document.createElement("img");
309
  img.src = URL.createObjectURL(file);
310
  img.alt = "Selected Image";
311
+ img.style.maxWidth = "100%"; // Make the image fill the bubble width
312
+ img.style.borderRadius = "8px"; // Optional: Rounded corners for images
313
+
314
+ // Append the image to the preview bubble
315
  filePreviewBubble.appendChild(img);
316
  filePreviewBubble.appendChild(document.createTextNode(` Selected: ${file.name}`));
317
  }
 
488
  }
489
  `;
490
  document.head.appendChild(style);
 
491
  });