From 089add1a806504b7393265da2c7667b9b87b662a Mon Sep 17 00:00:00 2001 From: Guillem Borrell Date: Sat, 27 Jul 2024 22:07:16 +0200 Subject: [PATCH] Disable the upload button while uploading --- src/hellocomputer/static/script.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hellocomputer/static/script.js b/src/hellocomputer/static/script.js index 0f2da18..c6f7b84 100644 --- a/src/hellocomputer/static/script.js +++ b/src/hellocomputer/static/script.js @@ -151,6 +151,10 @@ document.addEventListener("DOMContentLoaded", function () { return; } + // Disable the upload button + uploadButton.disabled = true; + uploadButton.textContent = 'Uploading...'; + const formData = new FormData(); formData.append('file', file); @@ -173,6 +177,10 @@ document.addEventListener("DOMContentLoaded", function () { addAIManualMessage('File uploaded and processed!'); } catch (error) { uploadResultDiv.textContent = 'Error: ' + error.message; + } finally { + // Re-enable the upload button + uploadButton.disabled = false; + uploadButton.textContent = 'Upload'; } }); });