Files
ConvertX/public/results.js
T

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-11-06 08:49:53 +01:00
const webroot = document.querySelector("meta[name='webroot']").content;
2024-05-25 02:33:24 +02:00
const jobId = window.location.pathname.split("/").pop();
const main = document.querySelector("main");
let progressElem = document.querySelector("progress");
2024-05-25 02:33:24 +02:00
const refreshData = () => {
// console.log("Refreshing data...", progressElem.value, progressElem.max);
2024-05-25 02:33:24 +02:00
if (progressElem.value !== progressElem.max) {
2024-11-06 08:49:53 +01:00
fetch(`${webroot}/progress/${jobId}`, {
2024-05-25 18:09:28 +02:00
method: "POST",
})
2024-05-25 02:33:24 +02:00
.then((res) => res.text())
.then((html) => {
main.innerHTML = html;
})
.catch((err) => console.log(err));
setTimeout(refreshData, 1000);
}
progressElem = document.querySelector("progress");
2024-05-25 02:33:24 +02:00
};
refreshData();
window.downloadAll = function () {
// Get all download links
const downloadLinks = document.querySelectorAll("tbody a[download]");
// Trigger download for each link
downloadLinks.forEach((link, index) => {
// We add a delay for each download to prevent them from starting at the same time
setTimeout(() => {
const event = new MouseEvent("click");
link.dispatchEvent(event);
}, index * 300);
});
};