Clear file inputs after jobs (#2248)
This commit is contained in:
@@ -64,6 +64,8 @@
|
||||
await handleSingleDownload(url, formData);
|
||||
}
|
||||
}
|
||||
|
||||
clearFileInput();
|
||||
clearTimeout(timeoutId);
|
||||
$("#submitBtn").text(originalButtonText);
|
||||
|
||||
@@ -85,6 +87,7 @@
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
clearFileInput();
|
||||
clearTimeout(timeoutId);
|
||||
handleDownloadError(error);
|
||||
$("#submitBtn").text(originalButtonText);
|
||||
@@ -116,11 +119,15 @@
|
||||
|
||||
const blob = await response.blob();
|
||||
if (contentType.includes("application/pdf") || contentType.includes("image/")) {
|
||||
clearFileInput();
|
||||
return handleResponse(blob, filename, !isMulti, isZip);
|
||||
} else {
|
||||
clearFileInput();
|
||||
return handleResponse(blob, filename, false, isZip);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
clearFileInput();
|
||||
console.error("Error in handleSingleDownload:", error);
|
||||
throw error;
|
||||
}
|
||||
@@ -291,4 +298,27 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Clear file input after job
|
||||
function clearFileInput(){
|
||||
let pathname = document.location.pathname;
|
||||
if(pathname != "/merge-pdfs"){
|
||||
let formElement = document.querySelector("#fileInput-input");
|
||||
formElement.value = '';
|
||||
let editSectionElement = document.querySelector("#editSection");
|
||||
if(editSectionElement){
|
||||
editSectionElement.style.display = "none";
|
||||
}
|
||||
let cropPdfCanvas = document.querySelector("#crop-pdf-canvas");
|
||||
let overlayCanvas = document.querySelector("#overlayCanvas");
|
||||
if(cropPdfCanvas && overlayCanvas){
|
||||
cropPdfCanvas.width = 0;
|
||||
cropPdfCanvas.heigth = 0;
|
||||
|
||||
overlayCanvas.width = 0;
|
||||
overlayCanvas.heigth = 0;
|
||||
}
|
||||
} else{
|
||||
console.log("Disabled for 'Merge'");
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user