2020-06-14 20:15:53 +02:00
|
|
|
(function () {
|
2020-06-25 16:44:34 +02:00
|
|
|
var form = document.getElementById('accountForm');
|
2020-06-14 20:15:53 +02:00
|
|
|
|
|
|
|
form.elements.password_new.onkeyup = function () {
|
|
|
|
MapGuesser.toggleDisableOnChange(this, form.elements.save);
|
|
|
|
};
|
|
|
|
|
|
|
|
form.elements.password_new_confirm.onkeyup = function () {
|
|
|
|
MapGuesser.toggleDisableOnChange(this, form.elements.save);
|
|
|
|
};
|
|
|
|
|
|
|
|
form.onsubmit = function (e) {
|
|
|
|
document.getElementById('loading').style.visibility = 'visible';
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
var formData = new FormData(form);
|
|
|
|
|
|
|
|
MapGuesser.httpRequest('POST', form.action, function () {
|
|
|
|
document.getElementById('loading').style.visibility = 'hidden';
|
|
|
|
|
|
|
|
if (this.response.error) {
|
|
|
|
var errorText;
|
|
|
|
switch (this.response.error) {
|
|
|
|
case 'password_not_match':
|
|
|
|
errorText = 'The given current password is wrong.'
|
|
|
|
break;
|
2020-06-21 12:55:49 +02:00
|
|
|
case 'password_too_short':
|
2020-06-14 20:15:53 +02:00
|
|
|
errorText = 'The given new password is too short. Please choose a password that is at least 6 characters long!'
|
|
|
|
break;
|
|
|
|
case 'passwords_not_match':
|
|
|
|
errorText = 'The given new passwords do not match.'
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-25 16:44:34 +02:00
|
|
|
var accountFormError = document.getElementById('accountFormError');
|
|
|
|
accountFormError.style.display = 'block';
|
|
|
|
accountFormError.innerHTML = errorText;
|
2020-06-14 20:15:53 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-25 16:44:34 +02:00
|
|
|
document.getElementById('accountFormError').style.display = 'none';
|
2020-06-14 20:15:53 +02:00
|
|
|
form.reset();
|
|
|
|
form.elements.save.disabled = true;
|
|
|
|
}, formData);
|
|
|
|
};
|
|
|
|
})();
|