2022-03-14 19:13:10 +01:00
|
|
|
//profile image preview
|
|
|
|
function readURL(input) {
|
|
|
|
|
|
|
|
if (input.files && input.files[0]) {
|
|
|
|
var reader = new FileReader();
|
|
|
|
|
|
|
|
reader.onload = function (e) {
|
|
|
|
$("#profile-img").attr('src', e.target.result);
|
|
|
|
}
|
|
|
|
|
|
|
|
reader.readAsDataURL(input.files[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#imginput").on('change', function() {
|
|
|
|
readURL(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
//flag image preview
|
|
|
|
$("#flaginput").on('change', function() {
|
2022-04-03 15:53:18 +02:00
|
|
|
var newsrc = `${base_url}/img/flags/flags_medium/`+this.value.replace(' ','_')+'.png';
|
2022-03-14 19:13:10 +01:00
|
|
|
$("#flagimg").attr('src', newsrc);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#refresh-captcha').on('click', function() {
|
|
|
|
$().ajax(
|
2022-04-03 15:53:18 +02:00
|
|
|
`${base_url}/register/new_captcha`,
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
|
|
|
'dataType': 'text',
|
|
|
|
'success': function(res) {
|
|
|
|
$("#captcha").attr('src', res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#reg-form > form').on('submit', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
// Check if the password math
|
2022-04-03 15:53:18 +02:00
|
|
|
const passwd = $('#password').val();
|
|
|
|
const passwdcheck = $('#passwordcheck').val();
|
2022-03-14 19:13:10 +01:00
|
|
|
$('#register-error').hide();
|
|
|
|
$('#passwd-error').hide();
|
2022-04-03 15:53:18 +02:00
|
|
|
|
|
|
|
if (passwd.normalize() != passwdcheck.normalize()) {
|
2022-03-14 19:13:10 +01:00
|
|
|
$('#passwd-error').show();
|
|
|
|
} else {
|
2022-04-03 15:53:18 +02:00
|
|
|
const form_data = new FormData(this);
|
2022-03-14 19:13:10 +01:00
|
|
|
|
2022-04-03 15:53:18 +02:00
|
|
|
$().ajax(`${base_url}/register/newuser`, {
|
2022-03-14 19:13:10 +01:00
|
|
|
type: 'POST',
|
|
|
|
data: form_data,
|
|
|
|
success: (resp) => {
|
|
|
|
if (resp.ok) {
|
2022-04-03 15:53:18 +02:00
|
|
|
location.href = `${base_url}/register/ok`;
|
2022-03-14 19:13:10 +01:00
|
|
|
} else {
|
|
|
|
$('#register-error').text(resp.msg);
|
|
|
|
$('#register-error').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('input').on('keyup', function() {
|
2022-04-03 15:53:18 +02:00
|
|
|
const input = $(this);
|
|
|
|
const inputID = '#' + input.attr('id');
|
2022-03-14 19:13:10 +01:00
|
|
|
$(inputID + ' + .input-error').hide();
|
2022-04-03 15:53:18 +02:00
|
|
|
|
2022-03-14 19:13:10 +01:00
|
|
|
if (input.val() && input.is(':invalid')) $(inputID + ' + .input-error').show();
|
2022-04-03 15:53:18 +02:00
|
|
|
if (input.val() && (inputID == '#password' || inputID == '#passwordcheck')) {
|
|
|
|
const passwd = $('#password').val();
|
|
|
|
const passwdcheck = $('#passwordcheck').val();
|
|
|
|
if (passwd.normalize() != passwdcheck.normalize()) $('#passwd-error').show();
|
|
|
|
else $('#passwd-error').hide();
|
|
|
|
}
|
2022-03-14 19:13:10 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#flaginput").trigger('change');
|