Skip to content

Commit

Permalink
make submit button only be pressed if not processing
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-roy-obd committed Aug 6, 2024
1 parent 9cfbb44 commit a0f9b5c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand All @@ -212,13 +220,16 @@ submitButton.addEventListener('click', async () => {
errorSection.style.display = 'block';
// Hide the submission results
resultsSection.style.display = 'none';
} finally {
isSubmitting = false;
}
} else {
// Show the error section
errorSection.style.display = 'block';
// Hide the submission results
submissionResultsList.style.display = 'none';
spinner.classList.add('d-none');
isSubmitting = false;
}
});

0 comments on commit a0f9b5c

Please sign in to comment.