Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- static/chatbot.js +9 -7
static/chatbot.js
CHANGED
|
@@ -88,7 +88,7 @@ const Chatbot = (() => {
|
|
| 88 |
|
| 89 |
function hideQuickReplies() { quickReplies.style.display = 'none'; quickReplies.innerHTML = ''; }
|
| 90 |
function showUpload() { uploadArea.style.display = 'block'; scrollToBottom(); }
|
| 91 |
-
function hideUpload() { uploadArea.style.display = 'none'; uploadPreview.style.display = 'none'; uploadDropzone.style.display = 'flex';
|
| 92 |
function showInput(placeholder) { inputArea.style.display = 'block'; userInput.placeholder = placeholder || 'Type your message...'; userInput.focus(); }
|
| 93 |
function hideInput() { inputArea.style.display = 'none'; }
|
| 94 |
|
|
@@ -245,12 +245,14 @@ const Chatbot = (() => {
|
|
| 245 |
showUpload();
|
| 246 |
break;
|
| 247 |
|
| 248 |
-
case 'XRAY_ANALYZING':
|
|
|
|
| 249 |
hideUpload();
|
| 250 |
-
const fileCount =
|
| 251 |
await botSay(`<span class="loader-ring">Sending ${fileCount} file${fileCount>1?'s':''} to AI detection model... This may take a moment.</span>`, true, 400);
|
| 252 |
-
await analyzeXray();
|
| 253 |
break;
|
|
|
|
| 254 |
|
| 255 |
case 'CORRELATION':
|
| 256 |
await performCorrelation();
|
|
@@ -357,10 +359,10 @@ const Chatbot = (() => {
|
|
| 357 |
}
|
| 358 |
}
|
| 359 |
|
| 360 |
-
async function analyzeXray() {
|
| 361 |
try {
|
| 362 |
const formData = new FormData();
|
| 363 |
-
|
| 364 |
|
| 365 |
const resp = await fetch('/api/detect-xray', { method: 'POST', body: formData });
|
| 366 |
if (!resp.ok) {
|
|
@@ -796,4 +798,4 @@ const Chatbot = (() => {
|
|
| 796 |
return { init };
|
| 797 |
})();
|
| 798 |
|
| 799 |
-
document.addEventListener('DOMContentLoaded', () => Chatbot.init());
|
|
|
|
| 88 |
|
| 89 |
function hideQuickReplies() { quickReplies.style.display = 'none'; quickReplies.innerHTML = ''; }
|
| 90 |
function showUpload() { uploadArea.style.display = 'block'; scrollToBottom(); }
|
| 91 |
+
function hideUpload() { uploadArea.style.display = 'none'; uploadPreview.style.display = 'none'; uploadDropzone.style.display = 'flex'; if(previewGrid) previewGrid.innerHTML = ''; }
|
| 92 |
function showInput(placeholder) { inputArea.style.display = 'block'; userInput.placeholder = placeholder || 'Type your message...'; userInput.focus(); }
|
| 93 |
function hideInput() { inputArea.style.display = 'none'; }
|
| 94 |
|
|
|
|
| 245 |
showUpload();
|
| 246 |
break;
|
| 247 |
|
| 248 |
+
case 'XRAY_ANALYZING': {
|
| 249 |
+
const filesToAnalyze = [...uploadedFiles]; // capture BEFORE hideUpload clears the array
|
| 250 |
hideUpload();
|
| 251 |
+
const fileCount = filesToAnalyze.length;
|
| 252 |
await botSay(`<span class="loader-ring">Sending ${fileCount} file${fileCount>1?'s':''} to AI detection model... This may take a moment.</span>`, true, 400);
|
| 253 |
+
await analyzeXray(filesToAnalyze);
|
| 254 |
break;
|
| 255 |
+
}
|
| 256 |
|
| 257 |
case 'CORRELATION':
|
| 258 |
await performCorrelation();
|
|
|
|
| 359 |
}
|
| 360 |
}
|
| 361 |
|
| 362 |
+
async function analyzeXray(files) {
|
| 363 |
try {
|
| 364 |
const formData = new FormData();
|
| 365 |
+
files.forEach(f => formData.append('images', f));
|
| 366 |
|
| 367 |
const resp = await fetch('/api/detect-xray', { method: 'POST', body: formData });
|
| 368 |
if (!resp.ok) {
|
|
|
|
| 798 |
return { init };
|
| 799 |
})();
|
| 800 |
|
| 801 |
+
document.addEventListener('DOMContentLoaded', () => Chatbot.init());
|