You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

86 lines
2.7 KiB

window.au_set = false;
window.LMS = 'https://codemy.ru';
function parseGetParams() {
var $_GET = {};
var __GET = window.location.search.substring(1).split("&");
for(var i=0; i<__GET.length; i++) {
var getVar = __GET[i].split("=");
$_GET[getVar[0]] = typeof(getVar[1])=="undefined" ? "" : getVar[1];
}
return $_GET;
}
function in_array(value, array) {
for(var i=0; i<array.length; i++){
if(value == array[i]) return true;
}
return false;
}
function check_email(data){
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(data);
}
function not_empty(data){
var result = false;
if (data.length > 0){
result = true
}
return result;
}
function check_form(email, phone, data, error, func) {
$(error).fadeOut('fast');
if(check_email(email) && not_empty(phone)){
func($(data), $(error))
} else {
$(error).html('Заполните форму верно').fadeIn();
}
}
function create_bill(form, error){
var get = parseGetParams();
if ('admitad_uid' in get && !window.au_set){
var forms = $('form');
var ad_ui = get['admitad_uid'];
var input = '<input readonly name="uid" style="display: none;" value="'+ad_ui+'">';
for (var i =0;i<forms.length;i++){
$(forms[i]).append(input)
}
window.au_set = true;
}
$(error).fadeOut();
$.ajax({
type: 'POST',
url: window.LMS + '/access/create_bill/',
data: $(form).serialize(),
success: function(data) {
if (data.code == '0'){
$(error).html(data.response).fadeIn();
} else {
if (!data['data']['gift']){
location.href=data['data']['pay_url']
} else {
$(error).html('Счет успешно добавлен').fadeIn();
}
}
}
});
}
function create_user(form, error){
$(error).fadeOut();
$.ajax({
type: 'POST',
url: window.LMS + '/access/create_user/',
data: $(form).serialize(),
success: function(data) {
if (data.code == '0'){
$(error).html(data.response).fadeIn();
} else {
$(error).html('Пользователь успешно зарегистрирован').fadeIn();
}
}
});
}