2024-04-07 22:42:48 +02:00
|
|
|
$('#login-form').on('submit', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
const form_data = new FormData(this);
|
|
|
|
$('#login-error').hide();
|
|
|
|
|
|
|
|
$().ajax(`${base_url}/dashboard/login`, {
|
|
|
|
type: 'POST',
|
|
|
|
data: form_data,
|
|
|
|
success: (resp) => {
|
|
|
|
if (resp.ok) {
|
|
|
|
location.href = `${base_url}/dashboard`;
|
|
|
|
} else {
|
|
|
|
$('#login-error').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2024-07-25 15:04:42 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#user-edit-form > form').on('submit', function(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
|
|
const formData = new FormData(this);
|
|
|
|
|
2024-07-25 15:29:22 +02:00
|
|
|
axios.post(`${base_url}/dashboard/update_user`, formData)
|
2024-07-25 15:04:42 +02:00
|
|
|
.then( resp => {
|
|
|
|
if (resp.data) window.location.reload()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
if (typeof nation !== 'undefined') {
|
|
|
|
$('#flaginput > option').each( ele => {
|
|
|
|
if (ele.innerText == nation) {
|
|
|
|
$(ele).attr('selected', true)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#user-passwd-form > form').on('submit', function(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
|
|
$('#passwd-error').hide();
|
|
|
|
const formData = new FormData(this);
|
|
|
|
if (formData.get('password') != formData.get('passwordcheck')) {
|
|
|
|
$('#passwd-error').show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-07-25 15:29:22 +02:00
|
|
|
axios.post(`${base_url}/dashboard/change_passwd`, formData)
|
2024-07-25 15:04:42 +02:00
|
|
|
.then( resp => {
|
|
|
|
if (resp.data) {
|
|
|
|
if (resp.data.ok) window.location.reload()
|
|
|
|
else alert(resp.data.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|