| Current Path : /home/smartconb/www/armencom33/acv2026/account/ |
| Current File : /home/smartconb/www/armencom33/acv2026/account/index.js |
function validatePassword(password, confirm_password) {
if (password.val() != confirm_password.val()) {
//confirm_password.get(0).setCustomValidity(TX_ADMIN_WARNING_PASSWORD_RESET_MISMATCH);
confirm_password.get(0).setCustomValidity('Password mismatch');
} else {
confirm_password.get(0).setCustomValidity('');
}
}
$(document).ready(function () {
$(document).on('change keyup', '#user_pwd_new, #user_pwd_confirm', function () {
validatePassword($('#user_pwd_new'), $('#user_pwd_confirm'));
});
$('#sc-user-reset-btn').on('click', function (e) {
e.preventDefault();
$('#userFrm').trigger("reset");
});
$('#sc-user-pwd-reset-btn').on('click', function (e) {
e.preventDefault();
$('#userPwdFrm').trigger("reset");
});
$('#userFrm').on('submit', function (e) {
e.preventDefault();
$('#sc-user-save-btn').click();
});
$('#userPwdFrm').on('submit', function (e) {
e.preventDefault();
$('#sc-user-pwd-save-btn').click();
});
$('#user_mail').on('change blur', function (e) {
$this = $(this);
$.ajax({
url: 'action.php',
type: "POST",
dataType: "json",
data: {
action: 3,
user_mail: $this.val()
},
async: false,
success: function (data, textStatus, jqXHR) {
if (data.error == 0) {
$this.get(0).setCustomValidity('')
} else {
$this.get(0).setCustomValidity(TX_ADMIN_WARNING_MAIL_VALUE_EXISTS);
}
}
});
});
$('#user_pwd_old').on('change blur', function (e) {
$this = $(this);
$.ajax({
url: 'action.php',
type: "POST",
dataType: "json",
data: {
action: 4,
user_pwd_old: $this.val()
},
async: false,
success: function (data, textStatus, jqXHR) {
if (data.error == 0) {
$this.get(0).setCustomValidity('')
} else {
$this.get(0).setCustomValidity(TX_ADMIN_WARNING_OLD_PASSWORD_MISMATCH);
}
}
});
});
$('#sc-user-save-btn').on('click', function (e) {
e.preventDefault();
var invalidElemets = $('#userFrm *:invalid');
if (invalidElemets.length > 0) {
var tmpText = TX_ADMIN_WARNING_FIELD_VALUE_INVALID;
if (invalidElemets.length > 1)
tmpText = TX_ADMIN_WARNING_FIELDS_VALUES_INVALID;
UIkit.notification(
'<i class="uk-icon-warning"></i> ' + tmpText,
{
status: 'danger',
timeout: 5000,
pos: 'top-center'
}
);
UIkit.scroll(invalidElemets.first(), {
duration: 800,
offset: 80
});
invalidElemets.first().focus();
invalidElemets.first().select();
return false;
}
var postData = {};
$('#userFrm .sc-submit-field').each(function () {
postData[$(this).attr('name')] = $(this).val();
});
if ($('#user_mail').length > 0) {
$.ajax({
url: 'action.php',
type: "POST",
dataType: "json",
data: {
action: 3,
user_mail: postData['user_mail']
},
async: false,
success: function (data, textStatus, jqXHR) {
if (data.error == 0) {
$('#user_mail').get(0).setCustomValidity('')
} else {
$('#user_mail').get(0).setCustomValidity(TX_ADMIN_WARNING_MAIL_VALUE_EXISTS);
return false;
}
}
});
}
$.ajax({
url: 'action.php',
type: "POST",
dataType: "json",
data: postData,
//{bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}
success: function (data, textStatus, jqXHR) {
if (data.error == 0) {
swal({
type: 'success',
//title: 'Oops...',
allowOutsideClick: false,
allowEnterKey: false,
customClass: 'animated wobble',
text: data.message
}).then((result) => {
window.location.href = './';
})
} else {
swal({
type: 'error',
title: 'Oops...',
allowOutsideClick: false,
allowEnterKey: false,
customClass: 'animated wobble',
text: data.message
});
}
}
});
});
$('#sc-user-pwd-save-btn').on('click', function (e) {
e.preventDefault();
validatePassword($('#user_pwd_new'), $('#user_pwd_confirm'));
var invalidElemets = $('#userPwdFrm *:invalid');
if (invalidElemets.length > 0) {
var tmpText = TX_ADMIN_WARNING_FIELD_VALUE_INVALID;
if (invalidElemets.length > 1)
tmpText = TX_ADMIN_WARNING_FIELDS_VALUES_INVALID;
UIkit.notification(
'<i class="uk-icon-warning"></i> ' + tmpText,
{
status: 'danger',
timeout: 5000,
pos: 'top-center'
}
);
UIkit.scroll(invalidElemets.first(), {
duration: 800,
offset: 80
});
invalidElemets.first().focus();
invalidElemets.first().select();
return false;
}
var postData = {};
$('#userPwdFrm .sc-submit-field').each(function () {
postData[$(this).attr('name')] = $(this).val();
});
$.ajax({
url: 'action.php',
type: "POST",
dataType: "json",
data: {
action: 4,
user_pwd_old: postData['user_pwd_old']
},
async: false,
success: function (data, textStatus, jqXHR) {
if (data.error == 0) {
$('#user_pwd_old').get(0).setCustomValidity('')
} else {
$('#user_pwd_old').get(0).setCustomValidity(TX_ADMIN_WARNING_OLD_PASSWORD_MISMATCH);
return false;
}
}
});
$.ajax({
url: 'action.php',
type: "POST",
dataType: "json",
data: postData,
//{bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}
success: function (data, textStatus, jqXHR) {
if (data.error == 0) {
swal({
type: 'success',
//title: 'Oops...',
allowOutsideClick: false,
allowEnterKey: false,
customClass: 'animated wobble',
text: data.message
}).then((result) => {
window.location.href = './';
})
} else {
swal({
type: 'error',
title: 'Oops...',
allowOutsideClick: false,
allowEnterKey: false,
customClass: 'animated wobble',
text: data.message
});
}
}
});
});
});