add auto refresh
This commit is contained in:
parent
d5628dcfab
commit
dcf360b7d2
9 changed files with 164 additions and 29 deletions
|
|
@ -1,13 +0,0 @@
|
|||
window.downloadAll = function () {
|
||||
// Get all download links
|
||||
const downloadLinks = document.querySelectorAll("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 * 100);
|
||||
});
|
||||
};
|
||||
35
src/public/results.js
Normal file
35
src/public/results.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
window.downloadAll = function () {
|
||||
// Get all download links
|
||||
const downloadLinks = document.querySelectorAll("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 * 100);
|
||||
});
|
||||
};
|
||||
const jobId = window.location.pathname.split("/").pop();
|
||||
const main = document.querySelector("main");
|
||||
const progressElem = document.querySelector("progress");
|
||||
|
||||
const refreshData = () => {
|
||||
console.log("Refreshing data...");
|
||||
console.log(progressElem.value);
|
||||
console.log(progressElem.max);
|
||||
|
||||
if (progressElem.value !== progressElem.max) {
|
||||
fetch(`/progress/${jobId}`)
|
||||
.then((res) => res.text())
|
||||
.then((html) => {
|
||||
main.innerHTML = html;
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
|
||||
setTimeout(refreshData, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
refreshData();
|
||||
|
|
@ -5,11 +5,11 @@ let fileType;
|
|||
|
||||
const selectElem = document.querySelector("select[name='convert_to']");
|
||||
|
||||
const convertFromSelect = document.querySelector("select[name='convert_from']");
|
||||
// const convertFromSelect = document.querySelector("select[name='convert_from']");
|
||||
|
||||
// Add a 'change' event listener to the file input element
|
||||
fileInput.addEventListener("change", (e) => {
|
||||
console.log(e.target.files);
|
||||
// console.log(e.target.files);
|
||||
// Get the selected files from the event target
|
||||
const files = e.target.files;
|
||||
|
||||
|
|
@ -28,18 +28,16 @@ fileInput.addEventListener("change", (e) => {
|
|||
|
||||
if (!fileType) {
|
||||
fileType = file.name.split(".").pop();
|
||||
console.log(file.type);
|
||||
fileInput.setAttribute("accept", `.${fileType}`);
|
||||
setTitle();
|
||||
|
||||
// choose the option that matches the file type
|
||||
for (const option of convertFromSelect.children) {
|
||||
console.log(option.value);
|
||||
if (option.value === fileType) {
|
||||
option.selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
// for (const option of convertFromSelect.children) {
|
||||
// console.log(option.value);
|
||||
// if (option.value === fileType) {
|
||||
// option.selected = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
fetch("/conversions", {
|
||||
method: "POST",
|
||||
|
|
@ -50,7 +48,6 @@ fileInput.addEventListener("change", (e) => {
|
|||
})
|
||||
.then((res) => res.text()) // Convert the response to text
|
||||
.then((html) => {
|
||||
console.log(html);
|
||||
selectElem.outerHTML = html; // Set the HTML
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue