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.
83 lines
2.6 KiB
83 lines
2.6 KiB
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) {
|
|
$(error).fadeOut('fast');
|
|
if(check_email(email) && not_empty(phone)){
|
|
create_bill($(data), $(error))
|
|
} else {
|
|
$('[name=error_place]').html('Форма заполнена не верно').fadeIn();
|
|
}
|
|
}
|
|
|
|
function create_bill(form, error){
|
|
var get = parseGetParams();
|
|
if ('admitad_uid' in get){
|
|
var forms = $('forms');
|
|
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)
|
|
}
|
|
}
|
|
$(error).fadeOut();
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: 'https://lms.ru/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: 'https://lms.ru/access/create_user/',
|
|
data: $(form).serialize(),
|
|
success: function(data) {
|
|
if (data.code == '0'){
|
|
$(error).html(data.response).fadeIn();
|
|
} else {
|
|
$(error).html('Пользователь успешно зарегистрирован').fadeIn();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|