');
},
success: function(data) {
if (data == "yes") {
jQuery('.page-modal').remove();
jQuery('.mobile-number').text(getCookie('phone'))
} else {
jQuery('.page-modal').remove();
}
}
});
}
/////////////////////////////////
function getphn() {
jQuery('#lr-submit-form-e').show();
jQuery('#lr-send-form-e').hide();
jQuery('#error-phone-e').hide();
clock.setTime(119);
clock.setCountdown(true);
clock.start();
jQuery('.page-modal').remove();
}
var digit1 = jQuery('input#digit-1-e').val();
var digit2 = jQuery('input#digit-2-e').val();
var digit3 = jQuery('input#digit-3-e').val();
var digit4 = jQuery('input#digit-4-e').val();
var digits = digit1.concat(digit2, digit3, digit4);
var codeCookie = getCookie('opt_code');
var clock = jQuery('#lr-countdown-e').FlipClock({
autoStart: false,
callbacks: {
start: function() {
jQuery('#recode-e').attr('disabled', 'disabled');
jQuery('.mobile-number').text(getCookie('phone'))
},
stop: function() {
jQuery('#lr-submit').hide();
jQuery('#recode-e').show();
jQuery('#recode-e').removeAttr('disabled');
}
}
});
jQuery('#lr-send-form-e').on('submit', function(e) {
e.preventDefault();
var nonce = jQuery('meta[name="csrf-token"]').attr('content');
jQuery.ajaxSetup({headers: {'X-CSRF-TOKEN': nonce}});
if (jQuery('#pass-e').length < 1) {
if (jQuery('#phone-e').val().length > 0) {
jQuery.ajax({
url: "/bakala/ajax/send_code/",
type: 'POST',
data: {
action: "bakala_send_code",
phone_email: jQuery('#phone-e').val(),
},
beforeSend: function() {
jQuery('body').append('
');
},
success: function(data) {
var phone_pattern = /^(\+98|0098|98|0)?9\d{9}$/;
var email_pattern = /^[a-zA-Z-' ]*$/;
if (phone_pattern.test(jQuery('#phone-e').val())) {
jQuery('#lr-submit-form-e').show();
jQuery('#lr-send-form-e').hide();
jQuery('#error-phone-e').hide();
clock.setTime(119);
clock.setCountdown(true);
clock.start();
jQuery('.page-modal').remove();
jQuery('#digit-1-e').trigger("focus");
jQuery('#digit-4-e').keyup(function() {
jQuery('#lr-submit-e').trigger("click");
jQuery('body').append('
');
});
} else if (validateEmail(jQuery('#phone-e').val())) {
jQuery('.page-modal').remove();
getEmail(jQuery('#phone-e').val())
} else {
jQuery('#error-phone-e').show();
}
}
});
} else {
jQuery('#error-phone-e').text('Enter mobile number or email!');
jQuery('#error-phone-e').show();
}
} else {
if (phone_pattern.test(jQuery('#phone-e').val())) {
jQuery.ajax({
url: "/bakala/ajax/send_code/",
type: 'POST',
data: {
action: "bakala_send_code",
phone_email: jQuery('#phone-e').val(),
},
beforeSend: function() {
jQuery('body').append('
');
},
success: function(data) {
var phone_pattern = /^(\+98|0098|98|0)?9\d{9}$/;
var email_pattern = /^[a-zA-Z-' ]*$/;
if (phone_pattern.test(jQuery('#phone-e').val())) {
getphn();
jQuery('#digit-1-e').trigger("focus");
jQuery('#digit-4-e').keyup(function() {
jQuery('#lr-submit-e').trigger("click");
jQuery('body').append('
');
});
} else if (validateEmail(jQuery('#phone-e').val())) {
jQuery('.page-modal').remove();
getEmail(jQuery('#phone-e').val())
} else {
jQuery('#error-phone-e').show();
}
}
});
} else {
jQuery('#error-phone').text('Enter the mobile number!');
jQuery('#error-phone').show();
}
}
return false;
})
jQuery('#lr-btn-e').on('click', function() {
var phone_pattern = /^(\+98|0098|98|0)?9\d{9}$/;
var email_pattern = /^[a-zA-Z-' ]*$/;
if (jQuery('#phone-e').val().length > 0 && jQuery('#pass-e').val().length > 1) {
jQuery.ajax({
url: "https://pashmalo.com/wp-admin/admin-ajax.php",
type: 'POST',
dataType: "json",
data: {
action: "bakala_lr_submit",
phone_email: jQuery('#phone-e').val(),
password: jQuery('#pass-e').val()
},
beforeSend: function() {
jQuery('body').append('
');
},
success: function(response) {
jQuery('.page-modal').remove();
if (response.status_code == 500) {
jQuery('#pass-e').css('borderColor', '#ee5a66')
jQuery('#error-pass-e').text(response.message)
jQuery('#error-pass-e').show()
} else {
const Toast = Swal.mixin({
toast: true,
position: 'center',
showConfirmButton: false,
timer: 4000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
title: response.message,
icon: 'success',
}).then((result) => {
if (window.location.href == document.referrer) {
location.reload();
} else {
window.location = document.referrer;
}
})
}
}
});
}
})
var phone_pattern = /^(\+98|0098|98|0)?9\d{9}$/;
var email_pattern = /^[a-zA-Z-' ]*$/;
jQuery('#phone-e').keyup(function() {
if (phone_pattern.test(jQuery(this).val()) == false && !Array.isArray(validateEmail(jQuery(this).val()))) {
jQuery(this).parent().css('height','auto');
jQuery('#error-phone-e').text('شماره موبایل یا ایمیل صحیح وارد کنید!');
jQuery('#error-phone-e').show();
jQuery(this).css('borderColor', '#ee5a66')
} else {
jQuery(this).parent().css('height','65px');
jQuery('#error-phone-e').hide();
jQuery(this).css('borderColor', 'green')
}
});
jQuery('#lr-submit-form-e').on('submit', function(e) {
e.preventDefault();
var digit1 = jQuery('input#digit-1-e').val();
var digit2 = jQuery('input#digit-2-e').val();
var digit3 = jQuery('input#digit-3-e').val();
var digit4 = jQuery('input#digit-4-e').val();
var digits = digit1.concat(digit2, digit3, digit4);
jQuery.ajax({
url: "/bakala/ajax/submit_code/",
type: 'POST',
dataType: "json",
data: {
action: "bakala_submit_code",
token: digits,
},
beforeSend: function() {
jQuery('.loader').show();
},
success: function(response) {
jQuery('.loader').hide();
if (response.status_code == 500) {
jQuery('#lr-token-e input').css('borderColor', '#ee5a66')
jQuery('.token-error').text(response.message)
} else {
const Toast = Swal.mixin({
toast: true,
position: 'center',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
title: response.message,
icon: 'success',
}).then((result) => {
if (window.location.href == document.referrer) {
location.reload();
} else {
window.location = document.referrer;
}
})
}
}
});
return false;
})
jQuery('#lr-password-form-e').on('submit', function(e) {
e.preventDefault();
var password = jQuery('input#password-e').val();
jQuery.ajax({
url: "https://pashmalo.com/wp-admin/admin-ajax.php",
type: 'POST',
dataType: "json",
data: {
action: "bakala_submit_password",
password: password,
},
beforeSend: function() {
jQuery('.loader').show();
},
success: function(response) {
jQuery('.loader').hide();
if (response.status_code == 500) {
jQuery('#password-e').css('borderColor', '#ee5a66')
jQuery('.password-error').text(response.message)
} else {
const Toast = Swal.mixin({
toast: true,
position: 'center',
showConfirmButton: false,
timer: 4000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
title: response.message,
icon: 'success',
}).then((result) => {
if (window.location.href == document.referrer) {
location.reload();
} else {
window.location = document.referrer;
}
})
}
}
});
return false;
})
////////////////////
//////////////////////
jQuery('#recode-e').on('click', function() {
jQuery.ajax({
url: "https://pashmalo.com/wp-admin/admin-ajax.php",
type: 'POST',
data: {
action: "bakala_send_code",
phone_email: jQuery('#phone-e').val(),
},
beforeSend: function() {
jQuery('body').append('
');
},
complete: function() {
jQuery('.page-modal').remove();
},
success: function(data) {
clock.setTime(120);
clock.setCountdown(true);
clock.start();
var pattern = /^(\+98|0098|98|0)?9\d{9}$/;
if (pattern.test(jQuery('#phone-e').val())) {
jQuery('#lr-submit-form-e').show();
jQuery('#lr-send-form-e').hide();
jQuery('#error-phone-e').hide();
} else {
jQuery('#error-phone-e').show();
}
}
});
})
jQuery('#edit-phone-number-e').click(function(e) {
e.preventDefault();
jQuery('#lr-submit-form-e').hide();
jQuery('#lr-send-form-e').show();
})
String.prototype.toEnglishDigit = function() {
var find = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
var replace = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var replaceString = this;
var regex;
for (var i = 0; i < find.length; i++) {
regex = new RegExp(find[i], "g");
replaceString = replaceString.replace(regex, replace[i]);
}
return replaceString;
};
document.querySelectorAll('input').forEach(x => {
x.oninput = function() {
x.value = x.value.toEnglishDigit()
}
});
jQuery('#lr-token-e').find('input').each(function() {
jQuery(this).attr('maxlength', 1);
jQuery(this).on('keyup', function(e) {
e.preventDefault();
var parent = jQuery(jQuery(this).parent());
inputCharacter = String.fromCharCode(e.which);
acceptableNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
if (e.keyCode == 8 || e.keyCode == 37) {
var prev = parent.find('input#' + jQuery(this).data('previous'));
if (prev.length != undefined) {
jQuery(prev).select();
}
} else if (e.which == 229 || (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 65 && e.keyCode <= 90) || (e.keyCode >= 96 && e.keyCode <= 105) || e.keyCode === 39) {
//} else if( checkIsInArray( inputCharacter , acceptableNumbers ) ) {
var next = parent.find('input#' + jQuery(this).data('next'));
if (next.length != undefined) {
jQuery(next).select();
} else {
if (parent.data('autosubmit')) {
parent.submit();
}
}
}
});
});