From a0f9b5c11cad0ca48629382258f86f5338493b11 Mon Sep 17 00:00:00 2001 From: Abhishek Roy Date: Tue, 6 Aug 2024 19:50:19 +0100 Subject: [PATCH] make submit button only be pressed if not processing --- static/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/static/index.js b/static/index.js index 9e27eec..e187b9f 100644 --- a/static/index.js +++ b/static/index.js @@ -188,7 +188,15 @@ async function render_path(shortest_path) { } // Add an event listener for submit button click +let isSubmitting = false; + submitButton.addEventListener('click', async () => { + if (isSubmitting) { + return; + } + + isSubmitting = true; + let actor_1 = selections['actor_1']; let actor_2 = selections['actor_2']; @@ -212,6 +220,8 @@ submitButton.addEventListener('click', async () => { errorSection.style.display = 'block'; // Hide the submission results resultsSection.style.display = 'none'; + } finally { + isSubmitting = false; } } else { // Show the error section @@ -219,6 +229,7 @@ submitButton.addEventListener('click', async () => { // Hide the submission results submissionResultsList.style.display = 'none'; spinner.classList.add('d-none'); + isSubmitting = false; } });