mirror of
https://github.com/karma-riuk/crab-webapp.git
synced 2025-07-05 06:08:13 +02:00
fixed minor mistake
This commit is contained in:
@ -110,15 +110,21 @@ document.getElementById("upload-btn").onclick = async () => {
|
|||||||
|
|
||||||
[...document.getElementsByClassName("download-results")].forEach((e) => {
|
[...document.getElementsByClassName("download-results")].forEach((e) => {
|
||||||
e.onclick = () => {
|
e.onclick = () => {
|
||||||
const dataStr =
|
// 1. Convert object to JSON string
|
||||||
"data:text/json;charset=utf-8," +
|
const json = JSON.stringify(results, null, 2);
|
||||||
encodeURIComponent(JSON.stringify(results));
|
// 2. Create a Blob of type application/json
|
||||||
const dlAnchorElem = document.createElement("a");
|
const blob = new Blob([json], { type: "application/json" });
|
||||||
dlAnchorElem.setAttribute("href", dataStr);
|
// 3. Generate a temporary object URL
|
||||||
dlAnchorElem.setAttribute("download", "results.json");
|
const url = URL.createObjectURL(blob);
|
||||||
document.body.appendChild(dlAnchorElem);
|
// 4. Create a temporary <a> element and trigger download
|
||||||
dlAnchorElem.click();
|
const link = document.createElement("a");
|
||||||
document.body.removeChild(dlAnchorElem);
|
link.href = url;
|
||||||
|
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);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -185,7 +191,7 @@ socket.on("queue_position", (data) => {
|
|||||||
let queue_position_interval = null;
|
let queue_position_interval = null;
|
||||||
|
|
||||||
document.getElementById("request-status").onclick = async () => {
|
document.getElementById("request-status").onclick = async () => {
|
||||||
if (!id.reportValidity()) return;
|
if (!uuid.reportValidity()) return;
|
||||||
const res = await fetch(`/answers/status/${uuid.value}`, {
|
const res = await fetch(`/answers/status/${uuid.value}`, {
|
||||||
headers: {
|
headers: {
|
||||||
"X-Socket-Id": socket.id,
|
"X-Socket-Id": socket.id,
|
||||||
@ -209,6 +215,8 @@ document.getElementById("request-status").onclick = async () => {
|
|||||||
if (json.type == "comment") populateCommentTable(json.results);
|
if (json.type == "comment") populateCommentTable(json.results);
|
||||||
else if (json.type == "comment") populateRefinementTable(json.results);
|
else if (json.type == "comment") populateRefinementTable(json.results);
|
||||||
else console.error(`Unknown type ${data.type}`);
|
else console.error(`Unknown type ${data.type}`);
|
||||||
|
// set global variable, used when user wants to download results
|
||||||
|
results = json.results;
|
||||||
} else if (json.status == "waiting") {
|
} else if (json.status == "waiting") {
|
||||||
statusStatusEl.textContent = `Currently waiting, position in queue ${json.queue_position}`;
|
statusStatusEl.textContent = `Currently waiting, position in queue ${json.queue_position}`;
|
||||||
queue_position_interval = setInterval(() => {
|
queue_position_interval = setInterval(() => {
|
||||||
|
Reference in New Issue
Block a user