reverted back to old code because what i was

trying to do failed
This commit is contained in:
Karma Riuk
2025-05-20 14:46:17 +02:00
parent 24ef78e615
commit d302d585c7

View File

@ -110,21 +110,15 @@ document.getElementById("upload-btn").onclick = async () => {
[...document.getElementsByClassName("download-results")].forEach((e) => { [...document.getElementsByClassName("download-results")].forEach((e) => {
e.onclick = () => { e.onclick = () => {
// 1. Convert object to JSON string const dataStr =
const json = JSON.stringify(results, null, 2); "data:text/json;charset=utf-8," +
// 2. Create a Blob of type application/json encodeURIComponent(JSON.stringify(results));
const blob = new Blob([json], { type: "application/json" }); const dlAnchorElem = document.createElement("a");
// 3. Generate a temporary object URL dlAnchorElem.setAttribute("href", dataStr);
const url = URL.createObjectURL(blob); dlAnchorElem.setAttribute("download", "results.json");
// 4. Create a temporary <a> element and trigger download document.body.appendChild(dlAnchorElem); // required for firefox
const link = document.createElement("a"); dlAnchorElem.click();
link.href = url; dlAnchorElem.remove();
link.download = "results.json";
// document.body.appendChild(link);
link.click();
// 5. Cleanup: revoke the object URL and remove the link
URL.revokeObjectURL(url);
// document.body.removeChild(link);
}; };
}); });