Biocoder09 commited on
Commit
10d9463
·
verified ·
1 Parent(s): b5af915

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +32 -0
static/script.js CHANGED
@@ -387,3 +387,35 @@ function openBigRadar() {
387
  function closeBigRadar() {
388
  document.getElementById("bigRadarModal").classList.add("hidden");
389
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  function closeBigRadar() {
388
  document.getElementById("bigRadarModal").classList.add("hidden");
389
  }
390
+
391
+ // DOWNLOAD CSV
392
+
393
+ function downloadCSV() {
394
+ if (!fastaResults || fastaResults.length === 0) {
395
+ alert("No batch results available to download.");
396
+ return;
397
+ }
398
+
399
+ fetch("/api/download_csv", {
400
+ method: "POST",
401
+ headers: { "Content-Type": "application/json" },
402
+ body: JSON.stringify(fastaResults)
403
+ })
404
+ .then(res => {
405
+ if (!res.ok) throw new Error("Failed to generate CSV");
406
+ return res.blob();
407
+ })
408
+ .then(blob => {
409
+ const url = window.URL.createObjectURL(blob);
410
+ const a = document.createElement("a");
411
+ a.href = url;
412
+ a.download = "canloc_results.csv";
413
+ document.body.appendChild(a);
414
+ a.click();
415
+ a.remove();
416
+ window.URL.revokeObjectURL(url);
417
+ })
418
+ .catch(err => {
419
+ alert("Download error: " + err.message);
420
+ });
421
+ }