mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-21 19:08:24 +01:00
Fix: Bored waiting button doesnt remove itself after processing (#2079) hide bored waiting? button after request handling both success and error cases to properly hide the button. Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
This commit is contained in:
parent
6d3f14375e
commit
bd29dd1ac3
@ -34,6 +34,12 @@
|
||||
const url = this.action;
|
||||
const files = $("#fileInput-input")[0].files;
|
||||
const formData = new FormData(this);
|
||||
const submitButton = document.getElementById("submitBtn");
|
||||
const showGameBtn = document.getElementById("show-game-btn");
|
||||
const originalButtonText = submitButton.textContent;
|
||||
var boredWaiting = localStorage.getItem("boredWaiting") || "disabled";
|
||||
|
||||
showGameBtn.style.display = "none";
|
||||
|
||||
// Remove empty file entries
|
||||
for (let [key, value] of formData.entries()) {
|
||||
@ -42,14 +48,10 @@
|
||||
}
|
||||
}
|
||||
const override = $("#override").val() || "";
|
||||
const originalButtonText = $("#submitBtn").text();
|
||||
$("#submitBtn").text("Processing...");
|
||||
console.log(override);
|
||||
|
||||
// Set a timeout to show the game button if operation takes more than 5 seconds
|
||||
const timeoutId = setTimeout(() => {
|
||||
var boredWaiting = localStorage.getItem("boredWaiting") || "disabled";
|
||||
const showGameBtn = document.getElementById("show-game-btn");
|
||||
if (boredWaiting === "enabled" && showGameBtn) {
|
||||
showGameBtn.style.display = "block";
|
||||
showGameBtn.parentNode.insertBefore(document.createElement('br'), showGameBtn.nextSibling);
|
||||
@ -57,6 +59,9 @@
|
||||
}, 5000);
|
||||
|
||||
try {
|
||||
submitButton.textContent = "Processing...";
|
||||
submitButton.disabled = true;
|
||||
|
||||
if (remoteCall === true) {
|
||||
if (override === "multi" || (!multipleInputsForSingleRequest && files.length > 1 && override !== "single")) {
|
||||
await submitMultiPdfForm(url, files);
|
||||
@ -65,12 +70,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
clearFileInput();
|
||||
clearTimeout(timeoutId);
|
||||
$("#submitBtn").text(originalButtonText);
|
||||
showGameBtn.style.display = "none";
|
||||
showGameBtn.style.marginTop = "";
|
||||
submitButton.textContent = originalButtonText;
|
||||
submitButton.disabled = false;
|
||||
|
||||
// After process finishes, check for boredWaiting and gameDialog open status
|
||||
const boredWaiting = localStorage.getItem("boredWaiting") || "disabled";
|
||||
const gameDialog = document.getElementById('game-container-wrapper');
|
||||
if (boredWaiting === "enabled" && gameDialog && gameDialog.open) {
|
||||
// Display a green banner at the bottom of the screen saying "Download complete"
|
||||
@ -89,8 +97,10 @@
|
||||
} catch (error) {
|
||||
clearFileInput();
|
||||
clearTimeout(timeoutId);
|
||||
showGameBtn.style.display = "none";
|
||||
submitButton.textContent = originalButtonText;
|
||||
submitButton.disabled = false;
|
||||
handleDownloadError(error);
|
||||
$("#submitBtn").text(originalButtonText);
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user