mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-28 18:22:05 +00:00
Add feedback that spotting is happening. #154
This commit is contained in:
@@ -150,6 +150,9 @@ function loadCredentials(providerName) {
|
||||
// Method called to add a spot to the server
|
||||
function addSpot() {
|
||||
try {
|
||||
$("#result-bad").empty();
|
||||
setSubmitting(true);
|
||||
|
||||
// Save settings (this will save "your call" for future use)
|
||||
saveSettings();
|
||||
|
||||
@@ -214,6 +217,7 @@ function addSpot() {
|
||||
}, 2000);
|
||||
},
|
||||
error: function (result) {
|
||||
setSubmitting(false);
|
||||
if (window._recaptchaWidgetId !== undefined) {
|
||||
grecaptcha.reset(window._recaptchaWidgetId);
|
||||
}
|
||||
@@ -225,11 +229,19 @@ function addSpot() {
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
setSubmitting(false);
|
||||
showAddSpotError(error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show or hide the "in progress" state on the Spot button.
|
||||
function setSubmitting(submitting) {
|
||||
$("#add-spot-submit").prop("disabled", submitting);
|
||||
$("#add-spot-spinner").toggle(submitting);
|
||||
$("#add-spot-submit-text").text(submitting ? "Spotting..." : "Spot");
|
||||
}
|
||||
|
||||
// Show an "add spot" error.
|
||||
function showAddSpotError(text) {
|
||||
const div = $("<div class='alert alert-danger alert-dismissible fade show mb-0 mt-4' role='alert'></div>");
|
||||
|
||||
Reference in New Issue
Block a user