/* Custom Js Files */
var public_key = $('#s_key').val();
if(public_key != undefined)
{
var stripe = Stripe(public_key);
}
(function($) {
"use strict";
$(function() {
var header = $(".start-style");
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 10) {
header.removeClass('start-style').addClass("scroll-on");
} else {
header.removeClass("scroll-on").addClass('start-style');
}
});
});
})(jQuery);
jQuery(function($) {
var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
$('.start-header .navbar-nav li a').each(function() {
if (this.href === path) {
$(this).addClass('active');
}
});
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
/* Tariffs Section Carousel */
jQuery("#tariff-sec").owlCarousel({
autoplay: false,
lazyLoad: true,
loop: true,
margin: 20,
responsiveClass: true,
autoHeight: true,
autoplayTimeout: 7000,
smartSpeed: 800,
nav: true,
dots: false,
responsive: {
0: {
items: 1
},
600: {
items: 2
},
1024: {
items: 3
},
1366: {
items: 3
}
}
});
/* Tariffs Section Carousel End*/
/* Ride History Datatable Js */
$(document).ready(function() {
$('#ride-history').DataTable({
"order": [[ 0, "desc" ]],
});
$('#main-history').DataTable();
$('#subscription-list').DataTable();
$('#subscription-history').DataTable();
$('#track-ride').DataTable({
"order": [[ 0, "desc" ]],
});
$('#transaction-history').DataTable();
getCountries();
});
function getCountries()
{
$.ajax({
url: "/api/booking/countriesList" ,
type: "POST",
success: function( data ) {
var opt = '';
for(var i=0;i+'+data.result[i].phonecode+'';
}
$('#country_code').html(opt);
}
});
}
/* Ride History Datatable Js End*/
$(document).ready(function() {
var li = $(".w3codemasters_time_slote .owl-item li a");
$(".w3codemasters_time_slote .owl-item li a").click(function() {
li.removeClass('active');
});
});
$('.owl_1').owlCarousel({
loop: false,
margin: 2,
responsiveClass: true,
autoplayHoverPause: true,
autoplay: false,
slideSpeed: 400,
paginationSpeed: 400,
autoplayTimeout: 3000,
dots: false,
responsive: {
0: {
items: 1,
nav: true,
loop: false
},
600: {
items: 2,
nav: true,
loop: false
},
1000: {
items: 3,
nav: true,
loop: false
}
}
});
function initMap() {
// The location of Uluru
var uluru = { lat: 38.637141, lng: -90.2015233 };
// The map, centered at Uluru
var map = new google.maps.Map(
document.getElementById('map'), { zoom: 17, center: uluru });
// The marker, positioned at Uluru
var marker = new google.maps.Marker({ position: uluru, map: map });
}
/*// Initialize and add the map
function initMap() {
// The location of Uluru
var uluru = { lat: -25.344, lng: 131.036 };
// The map, centered at Uluru
var map = new google.maps.Map(
document.getElementById('map'), { zoom: 4, center: uluru });
// The marker, positioned at Uluru
var marker = new google.maps.Marker({ position: uluru, map: map });
}*/
var today = new Date();
$('#book-now-date').calendar({
type: 'date',
minDate: new Date(today.getFullYear(), today.getMonth(), today.getDate()),
// maxDate: new Date(today.getFullYear(), today.getMonth(), today.getDate() + 5),
onChange: function(date, text, mode) {
calculate_estimate();
}
});
// $('#book-now-time').calendar({
// type: 'time',
// onChange: function(date, text, mode) {
// calculate_estimate();
// }
// });
$('#rl_pickup_time').timepicker({
showInputs: false,
disableFocus:true,
defaultTime: null
});
$(document).ready(function() {
$(".ajax-button").addClass("view");
$(".submit").addClass("loading");
setTimeout(function() {
$(".ajax-button").removeClass("view");
$(".submit").removeClass("loading");
}, 3000);
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
if (regexp.constructor != RegExp)
regexp = new RegExp(regexp);
else if (regexp.global)
regexp.lastIndex = 0;
return this.optional(element) || regexp.test(value);
},
"Please check your input."
);
// Wait for the DOM to be ready
$(function() {
$("#signup_form").validate({
rules: {
name: "required",
last_name: "required",
email: {
required: true,
// Specify that email should be validated
// by the built-in "email" rule
email: true,
regex:"^[^@\\s]+@([^@\\s]+\\.)+[^@\\s]+$",
},
password: {
required: true,
minlength: 8,
regex: "[^\w\d]*(([0-9]+.*[A-Za-z]+.*)|[A-Za-z]+.*([0-9]+.*))"
},
phone_number: {
required: true,
minlength: 8,
maxlength: 12,
digits: true
},
country_code: {
required: true,
regex: /^\+(\d{1}\-)?(\d{1,4})$/
},
},
// Specify validation error messages
messages: {
name: "Please enter your firstname",
last_name: "Please enter your lastname",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 8 characters long",
regex: "Password must contains one letter and one number"
},
email: {
required: "Please enter email",
email: "Please enter a valid email address",
regex: "Please enter a valid email address"
},
phone_number: {
required: "Please enter your phone number",
minlength: "Phone number atleast of 8 digits",
maxlength: "Phone number does not exceeds 12 digits",
digits: "Phone number must be in digits"
},
country_code: {
required: 'Enter CC',
regex: "Enter Valid CC"
}
},
submitHandler: function(form) {
$('#load-sign').prop('disabled', true);
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var email = $('#email').val();
var phone_number = $('#phone_number').val();
var country_code = $('#country_code').val();
var p_number = country_code +''+ phone_number;
var otp = $('#index_otp').val();
var user_referral_code = $('#user_referral_code').val();
$.ajax({
url: "/api/driver/sendOTP" ,
type: "POST",
data: {email:email,phone_number:p_number,type:'web',user_referral_code:user_referral_code},
success: function( data ) {
if(otp == '1')
{
if(data.message == 'Otp sent to your mail')
{
$.toast({
heading: 'Information',
text: data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
setTimeout(function(){
$('#sign-close').click();
$('#otp_sig_button').click();
$('#s_email').val(email);
$('#s_phone').val(p_number);
$('#load-sign').prop('disabled', false);
}, 3000);
}
else if(data.message == 'OTP Sent')
{
$.toast({
heading: 'Information',
text: "OTP sent to your phone number",
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
setTimeout(function(){
$('#sign-close').click();
$('#otp_sig_button').click();
$('#s_email').val(email);
$('#s_phone').val(p_number);
$('#load-sign').prop('disabled', false);
}, 3000);
}
else if(data.message == '[HTTP 400] Unable to create record: The number is unverified. Trial accounts cannot send messages to unverified numbers; verify at twilio.com/user/account/phone-numbers/verified, or purchase a Twilio number to send messages to unverified numbers.')
{
$.toast({
heading: 'Error',
text: "Update your phone number in twilio account.",
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#load-sign').prop('disabled', false);
}
else if(data.message == 'OTP disabled')
{
register_customer();
}
else
{
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#load-sign').prop('disabled', false);
}
}
else
{
if(data.message == 'OTP disabled')
{
register_customer();
}
else
{
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#load-sign').prop('disabled', false);
}
}
}
});
}
});
});
$(function() {
$("#signin_otp").validate({
rules: {
otp: {
required: true,
digits: true
},
},
// Specify validation error messages
messages: {
otp: {
required: "Please enter OTP",
digits: "OTP must be in digits"
}
},
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#sign_otp_button').prop('disabled', true);
$('.resend-otp').css('pointer-events', 'none');
$.ajax({
url: "/api/customer/verify" ,
type: "POST",
data: $('#signin_otp').serialize(),
success: function( data ) {
if(data.message == "OTP verified.")
{
$.toast({
heading: 'Information',
text: data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
setTimeout(function(){
register_customer();
}, 2000);
}
else if(data.message == 'Something went wrong. Please try again.')
{
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
setTimeout(function(){
location.reload(true);
}, 3000);
}
else
{
$('#sign_otp_button').prop('disabled', false);
$('.resend-otp').css('pointer-events', '');
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
}
});
});
function register_customer()
{
$.ajax({
url: "/register" ,
type: "POST",
data: $('#signup_form').serialize(),
success: function( data ) {
console.log(data.error)
if(data.error == 'Referral code does not exists')
{
$('#load-sign').prop('disabled', false);
$.toast({
heading: 'Error',
text: data.error,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
data.error = '';
}
else if ($.isEmptyObject(data.error)) {
var er = '- User registered successfully
';
$.toast({
heading: 'Information',
text: 'User registered successfully',
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
setTimeout(function(){ location.reload(true) }, 2000);
} else {
$('#load-sign').prop('disabled', false);
var er = '';
$.each(data.error, function(key, value) {
er = er + '- ' + value + '
';
});
er = er + '
';
// toastr.error(er, null, []);
$.toast({
heading: 'Error',
text: er,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
}
}
});
}
$(function() {
$("#login_form").validate({
rules: {
email: {
required: true,
// Specify that email should be validated
// by the built-in "email" rule
email: true
},
password: {
required: true,
minlength: 5
}
},
// Specify validation error messages
messages: {
username: "Please enter your firstname",
lastname: "Please enter your lastname",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 8 characters long"
},
email: "Please enter a valid email address"
},
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#log-button').prop('disabled', true);
$.ajax({
url: "/postlogin" ,
type: "POST",
data: $('#login_form').serialize(),
success: function( data ) {
if ($.isEmptyObject(data.error)) {
// var er = '';
// toastr.success(er, null, []);
if(data.login == 1){
$.toast({
heading: 'Information',
text: data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
$( "#close_pop" ).trigger( "click" );
setTimeout(function(){
window.location.href='book-now';
}, 2000);
} else {
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#log-button').prop('disabled', false);
}
} else {
var er = '';
$.each(data.error, function(key, value) {
er = er + '- ' + value + '
';
});
er = er + '
';
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
$('#log-button').prop('disabled', false);
// toastr.error(er, null, []);
}
}
});
}
});
});
$(".resend-otp").click(function() {
var email = $('#email').val();
var phone_number = $('#phone_number').val();
var country_code = $('#country_code').val();
var p_number = country_code +''+ phone_number;
var otp = $('#index_otp').val();
var user_referral_code = $('#user_referral_code').val();
$('#sign_otp_button').prop('disabled', true);
$('.resend-otp').css('pointer-events', 'none');
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "/api/driver/sendOTP" ,
type: "POST",
data: {email:email,phone_number:p_number,type:'web',user_referral_code:user_referral_code},
success: function( data ) {
if(otp == '1')
{
if(data.message == 'Otp sent to your mail')
{
$.toast({
heading: 'Information',
text: data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#sign_otp_button').prop('disabled', false);
$('.resend-otp').css('pointer-events', '');
}
else if(data.message == 'OTP Sent')
{
$.toast({
heading: 'Information',
text: "OTP sent to your phone number",
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#sign_otp_button').prop('disabled', false);
$('.resend-otp').css('pointer-events', '');
}
else if(data.message == '[HTTP 400] Unable to create record: The number is unverified. Trial accounts cannot send messages to unverified numbers; verify at twilio.com/user/account/phone-numbers/verified, or purchase a Twilio number to send messages to unverified numbers.')
{
$.toast({
heading: 'Error',
text: "Update your phone number in twilio account.",
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#sign_otp_button').prop('disabled', false);
$('.resend-otp').css('pointer-events', '');
}
else if(data.message == 'OTP disabled')
{
register_customer();
}
else
{
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#sign_otp_button').prop('disabled', false);
$('.resend-otp').css('pointer-events', '');
}
}
else
{
if(data.message == 'OTP disabled')
{
register_customer();
}
else
{
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#sign_otp_button').prop('disabled', false);
$('.resend-otp').css('pointer-events', '');
}
}
}
});
})
// On Click SignUp It Will Hide Login Form and Display Registration Form
$("#signinButton").click(function() {
$("#signupPanel").slideUp("slow", function() {
$("#login_form").trigger("reset");
$("label.error").hide();
$(".error").removeClass("error");
$("#loginPanel").slideDown("slow");
});
});
// On Click SignIn It Will Hide Registration Form and Display Login Form
$("#signupButton").click(function() {
$("#loginPanel").slideUp("slow", function() {
$("#signup_form").trigger("reset");
$("label.error").hide();
$(".error").removeClass("error");
$("#signupPanel").slideDown("slow");
});
});
function enableEdit()
{
$("#first_name").prop('disabled', false);
$("#lastname").prop('disabled', false);
$("#dob_profile").prop('disabled', false);
$("#age_profile").prop('disabled', false);
$("#country_profile").prop('disabled', false);
$('#country_profile').css('pointer-events','');
$("#state_profile").prop('disabled', false);
$("#city_profile").prop('disabled', false);
$("#postal_code_profile").prop('disabled', false);
$("#address_profile").prop('disabled', false);
$('#new_password').prop('disabled', false);
$('#confirm_password').prop('disabled', false);
$("#save").prop('disabled', false);
$('#edit_prof').hide();
$('#bank_fname').prop('disabled', false);
$('#bank_email').prop('disabled', false);
$('#account_num').prop('disabled', false);
$('#bankname').prop('disabled', false);
$('#bank_code').prop('disabled', false);
$('#payout_req').prop('disabled', false);
}
$(function() {
$("#edit_profile").validate({
rules: {
name: "required",
last_name: "required",
email: {
required: true,
// Specify that email should be validated
// by the built-in "email" rule
email: true
},
phone_number: {
required: true,
minlength: 8,
maxlength: 12,
digits: true
},
},
// Specify validation error messages
messages: {
name: "Name is required",
last_name: "Last name is required",
email: "E-mail is required",
phone_number: "Phone number is required",
},
submitHandler: function(form) {
$('#load-sign').prop('disabled', true);
$.ajaxSetup({
headers: {
'Authorization': 'Bearer ' + $('#access_token').val()
}
});
/*var password = $('#new_password').val();
var conf_password = $('#confirm_password').val();
if(password != 'undefined')
{
if(password != conf_password)
{
$('#cover-spin').hide();
$('.scs_msg').html('{{trans("common.Failure")}}');
$('#status_img').attr('src',"/images/failure.png");
$('#success_msg').html('trans("common.passwd_mismatch")');
$('#exampleModalCenter').modal({backdrop: 'static', keyboard: false});
$('#new_password').val('');
$('#confirm_password').val('');
return false;
}
}*/
$('#cover-spin').show();
$('#save').prop('disabled', true);
$.ajax({
url: "/api/customer/update" ,
type: "POST",
data: $('#edit_profile').serialize(),
success: function( data ) {
$('#cover-spin').hide();
if (data.message=="Profile updated successfully.") {
$('#status_img').attr('src',"/images/success.png");
//$('.scs_msg').html('Success');
//$('#success_msg').html('Profile Updated Successfully');
//$('#exampleModalCenter').modal({backdrop: 'static', keyboard: false});
$.toast({
heading: 'Success',
text: data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
setTimeout(function(){ location.reload(true) }, 3000);
} else {
// $.toast({
// heading: 'Error',
// text: data.message,
// icon: 'error',
// loader: true, // Change it to false to disable loader
// loaderBg: '#9EC600',
// position: 'top-right',
// class: 'custom_toast'
// })
$('#status_img').attr('src',"/images/failure.png");
$('.scs_msg').html('Failure');
$('#success_msg').html(data.message);
$('#exampleModalCenter').modal({backdrop: 'static', keyboard: false});
}
}
});
}
});
});
$(function() {
$("#forgot_mail").validate({
rules: {
email: {
required: true,
email: true
},
},
// Specify validation error messages
messages: {
email: {
required: "Please enter email",
email: "Please enter a valid email address"
}
},
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#for_mail_button').prop('disabled', true);
$.ajax({
url: "/api/customer/forgetPassword" ,
type: "POST",
data: $('#forgot_mail').serialize(),
success: function( data ) {
if(data.message == "Mail sent successfully")
{
$.toast({
heading: 'Information',
text: "OTP sent to your email.",
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
$('#for_pass_email').val(data.result.email);
setTimeout(function(){
$('#for_mail_button').prop('disabled', false);
// $('#forgotMailModal').hide();
$('#f_email').val('');
$('#f_pass_mail').click();
$('#mail_otp_verify').click();
}, 3000);
}
else
{
$('#for_mail_button').prop('disabled', false);
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
}
});
});
$(function() {
$("#forgot_otp").validate({
rules: {
otp: {
required: true,
digits: true
},
},
// Specify validation error messages
messages: {
otp: {
required: "Please enter OTP",
digits: "OTP must be in digits"
}
},
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#for_otp_button').prop('disabled', true);
$.ajax({
url: "/api/customer/forgotPasswordOtpVerify" ,
type: "POST",
data: $('#forgot_otp').serialize(),
success: function( data ) {
if(data.message == "verified.")
{
$.toast({
heading: 'Information',
text: "OTP Verified.",
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
$('#f_otp').val(data.data.otp);
$('#f_id').val(data.data.id);
setTimeout(function(){
$('#for_otp_button').prop('disabled', false);
// $('#forgotOtpModal').hide();
$('#fo_otp').val('');
$('#f_pass_otp').click();
$('#mail_new_password').click();
}, 3000);
}
else
{
$('#for_otp_button').prop('disabled', false);
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
}
});
});
$(function() {
$("#forgot_password").validate({
rules: {
password: {
required: true,
minlength: 8,
regex: "[^\w\d]*(([0-9]+.*[A-Za-z]+.*)|[A-Za-z]+.*([0-9]+.*))"
},
confirm_password: {
required: true,
equalTo: "#f_password"
}
},
// Specify validation error messages
messages: {
password: {
required: "OTP must be in digits",
minlength: "Your password must be at least 8 characters long",
regex: "Password must contains one letter and one number"
},
confirm_password: {
required: "Please enter confirm password",
equalTo: "Password must match."
}
},
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#for_pass_button').prop('disabled', true);
$.ajax({
url: "/api/customer/changePass" ,
type: "POST",
data: $('#forgot_password').serialize(),
success: function( data ) {
if(data.message == "Success")
{
$.toast({
heading: 'Information',
text: "Password updated successfully.",
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
setTimeout(function(){
location.reload(true)
}, 3000);
}
else
{
$('#for_pass_button').prop('disabled', false);
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
}
});
});
$(function() {
$("#card-form").validate({
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#card-save').prop('disabled', true);
setTimeout(function(){
$.ajax({
url: "/api/savecard" ,
type: "POST",
data: $('#card-form').serialize(),
success: function( data ) {
console.log(data)
if(data.message.error)
{
$('#card-save').prop('disabled', false);
$.toast({
heading: 'Error',
text: "Please provide the card details",
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
else if(data.message == "Card details saved in stripe successfully.")
{
$.toast({
heading: 'Information',
text: data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
setTimeout(function(){
window.location.href='manage_cards';
}, 3000);
}
else
{
$('#card-save').prop('disabled', false);
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
}, 3000);
}
});
$("#top_wall").validate({
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#wall-upt').prop('disabled', true);
$('#card-save').prop('disabled', true);
setTimeout(function(){
$.ajax({
url: "/api/topup_wallet" ,
type: "POST",
data: {customer_id:$("#user_id").val(),amount:$("#amnt_cpy").val(),token:$("#str_token").val()},
success: function( data ) {
console.log(data);
if(data.message.error)
{
$('#card-save').prop('disabled', false);
$.toast({
heading: 'Error',
text: "Please provide valid card details",
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
else if(data.message == "Success")
{
$.toast({
heading: 'Information',
text: 'Money added to wallet successfully',
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
setTimeout(function(){
$('#card-save').prop('disabled', false);
window.location.href='wallet';
}, 2000);
}
else
{
$.toast({
heading: 'Error',
text: 'Something went wrong. Please try again.',
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#card-save').prop('disabled', false);
}
}
});
}, 3000);
}
});
});
$(function(){
$("#image_update").validate({
rules: {
avatar: {
required: true,
},
},
// Specify validation error messages
messages: {
avatar: {required: "Choose Image"}
},
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'Authorization': 'Bearer ' + $('#access_token').val()
}
});
var fuData = document.getElementById('profile_image');
var FileUploadPath = fuData.value;
if (FileUploadPath == '') {
$.toast({
heading: 'Error',
text: "Upload an image in jpeg or png format",
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
$('#status_img').attr('src',"/images/failure.png");
$('.scs_msg').html('Failure');
$('#success_msg').html('Upload Failed');
$('#exampleModalCenter').modal({backdrop: 'static', keyboard: false});
}
else
{
var Extension = FileUploadPath.substring(
FileUploadPath.lastIndexOf('.') + 1).toLowerCase();
if (Extension == "png" || Extension == "jpeg" || Extension == "jpg") {
$('#image_button').prop('disabled', true);
var cus_type = $('#cus_type').val();
$.ajax({
url: 'api/customer/uploadImage',
type: "POST",
// data: $('#tutor_signup').serialize(),
data: new FormData($("#image_update")[0]),
processData: false,
contentType: false,
success: function( data ) {
if(data.message == 'image uploaded.')
{
$.toast({
heading: 'Success',
text: 'Image updated successfully',
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
// $('#status_img').attr('src',"/images/success.png");
// $('.scs_msg').html('Success');
// $('#success_msg').html('Profile Image Updated Successfully');
// $('#exampleModalCenter').modal({backdrop: 'static', keyboard: false});
setTimeout(function(){ location.reload(true) }, 3000);
}
}
});
}
else{
$('#profile_image').val('');
// $.toast({
// heading: 'Error',
// text: "Photo only allows file types of PNG, JPG and JPEG",
// icon: 'error',
// loader: true, // Change it to false to disable loader
// loaderBg: '#9EC600',
// position: 'top-right',
// class: 'custom_toast'
// });
$('#status_img').attr('src',"/images/failure.png");
$('.scs_msg').html('{{trans("common.Failure")}}');
$('#success_msg').html('{{trans("common.allow_image_type")}}');
$('#exampleModalCenter').modal({backdrop: 'static', keyboard: false});
}
}
}
});
});
function card_default_change(card_id,user_id)
{
swal({
title: "Do you want to make this card as default?",
icon: "warning",
buttons: true,
dangerMode: true,
buttons: ['No', 'Yes']
}).then((willDelete) => {
if(willDelete) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "/api/defaultcard" ,
type: "POST",
data: {user_id:user_id,card_id:card_id},
success: function( data ) {
if(data.message == "Success")
{
$.toast({
heading: 'Information',
text: 'Card default status updated successfully',
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
setTimeout(function(){
window.location.href='manage_cards';
}, 2000);
}
else
{
$.toast({
heading: 'Error',
text: 'Something went wrong. Please try again.',
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
} else {
}
});
}
$(function() {
$("#card-default").validate({
submitHandler: function(form) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#yes_button').prop('disabled', true);
$('#no_button').css('pointer-events','none');
$.ajax({
url: "/api/defaultcard" ,
type: "POST",
data: $('#card-default').serialize(),
success: function( data ) {
if(data.message == "Success")
{
$.toast({
heading: 'Information',
text: 'Card default status updated successfully',
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
})
setTimeout(function(){
window.location.href='manage_cards';
}, 3000);
}
else
{
$('#yes_button').prop('disabled', false);
$('#no_button').css('pointer-events','');
$.toast({
heading: 'Error',
text: 'Something went wrong. Please try again.',
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}
}
});
}
});
});
(function() {
"use strict";
var elements = stripe.elements({
fonts: [
{
cssSrc: "https://rsms.me/inter/inter-ui.css"
}
],
// Stripe's examples are localized to specific languages, but if
// you wish to have Elements automatically detect your user's locale,
// use `locale: 'auto'` instead.
locale: window.__exampleLocale
});
/**
* Card Element
*/
var card = elements.create("card", {
style: {
base: {
color: "#000",
fontFamily: "Inter UI, Open Sans, Segoe UI, sans-serif",
fontSize: "16px",
fontSmoothing: "antialiased",
"::placeholder": {
color: "#000"
}
},
invalid: {
color: "#fff"
}
}
});
card.mount("#example4-card");
/**
* Payment Request Element
*/
var paymentRequest = stripe.paymentRequest({
country: "US",
currency: "usd",
total: {
amount: 2000,
label: "Total"
}
});
paymentRequest.on("token", function(result) {
var example = document.querySelector(".example4");
example.querySelector(".token").innerText = result.token.id;
example.classList.add("submitted");
result.complete("success");
});
var paymentRequestElement = elements.create("paymentRequestButton", {
paymentRequest: paymentRequest,
style: {
paymentRequestButton: {
type: "donate"
}
}
});
paymentRequest.canMakePayment().then(function(result) {
if (result) {
document.querySelector(".example4 .card-only").style.display = "none";
document.querySelector(
".example4 .payment-request-available"
).style.display =
"block";
paymentRequestElement.mount("#example4-paymentRequest");
}
});
registerElements([card, paymentRequestElement], "example4");
})();
function registerElements(elements, exampleName) {
var formClass = '.' + exampleName;
var example = document.querySelector(formClass);
console.log(example);
var form = example.querySelector('form');
var resetButton = example.querySelector('a.reset');
var error = form.querySelector('.error');
var errorMessage = error.querySelector('.message');
function enableInputs() {
Array.prototype.forEach.call(
form.querySelectorAll(
"input[type='text'], input[type='email'], input[type='tel']"
),
function(input) {
input.removeAttribute('disabled');
}
);
}
function disableInputs() {
Array.prototype.forEach.call(
form.querySelectorAll(
"input[type='text'], input[type='email'], input[type='tel']"
),
function(input) {
input.setAttribute('disabled', 'true');
}
);
}
function triggerBrowserValidation() {
// The only way to trigger HTML5 form validation UI is to fake a user submit
// event.
var submit = document.createElement('input');
submit.type = 'submit';
submit.style.display = 'none';
form.appendChild(submit);
submit.click();
submit.remove();
}
// Listen for errors from each Element, and show error messages in the UI.
var savedErrors = {};
elements.forEach(function(element, idx) {
element.on('change', function(event) {
if (event.error) {
error.classList.add('visible');
savedErrors[idx] = event.error.message;
errorMessage.innerText = event.error.message;
} else {
savedErrors[idx] = null;
// Loop over the saved errors and find the first one, if any.
var nextError = Object.keys(savedErrors)
.sort()
.reduce(function(maybeFoundError, key) {
return maybeFoundError || savedErrors[key];
}, null);
if (nextError) {
// Now that they've fixed the current error, show another one.
errorMessage.innerText = nextError;
} else {
// The user fixed the last error; no more errors.
error.classList.remove('visible');
}
}
});
});
// Listen on the form's 'submit' handler...
form.addEventListener('submit', function(e) {
e.preventDefault();
// Trigger HTML5 validation UI on the form if any of the inputs fail
// validation.
var plainInputsValid = true;
Array.prototype.forEach.call(form.querySelectorAll('input'), function(
input
) {
if (input.checkValidity && !input.checkValidity()) {
plainInputsValid = false;
return;
}
});
if (!plainInputsValid) {
triggerBrowserValidation();
return;
}
// Show a loading screen...
example.classList.add('submitting');
// Disable all inputs.
disableInputs();
// Gather additional customer data we may have collected in our form.
var name = form.querySelector('#' + exampleName + '-name');
var address1 = form.querySelector('#' + exampleName + '-address');
var city = form.querySelector('#' + exampleName + '-city');
var state = form.querySelector('#' + exampleName + '-state');
var zip = form.querySelector('#' + exampleName + '-zip');
var additionalData = {
name: name ? name.value : undefined,
address_line1: address1 ? address1.value : undefined,
address_city: city ? city.value : undefined,
address_state: state ? state.value : undefined,
address_zip: zip ? zip.value : undefined,
};
// Use Stripe.js to create a token. We only need to pass in one Element
// from the Element group in order to create a token. We can also pass
// in the additional customer data we collected in our form.
stripe.createToken(elements[0], additionalData).then(function(result) {
// Stop loading!
example.classList.remove('submitting');
if (result.token) {
// If we received a token, show the token ID.
//example.querySelector('.token').innerText = result.token.id;
$('#str_token').val(result.token.id);
$('#pay_token').val(result.token.id);
example.classList.add('submitted');
form.submit();
//alert(result.token.id);
example.classList.add('submitted');
} else {
// Otherwise, un-disable inputs.
enableInputs();
}
});
});
resetButton.addEventListener('click', function(e) {
e.preventDefault();
// Resetting the form (instead of setting the value to `''` for each input)
// helps us clear webkit autofill styles.
form.reset();
// Clear each Element.
elements.forEach(function(element) {
element.clear();
});
// Reset error state as well.
error.classList.remove('visible');
// Resetting the form does not un-disable inputs, so we need to do it separately:
enableInputs();
example.classList.remove('submitted');
});
}
function delClick(){
var cust_id=$('#delete_id').val();
var mobile_type="web";
var type="customer";
$('#delete_confirm_yes').prop('disabled', true);
let spinner = document.getElementById("spinner");
spinner.style.visibility = 'visible';
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "api/sendAccoutDeleteRequest" ,
type:"POST",
data:{user_id:cust_id,type:type,mobile_type:mobile_type},
success: function( data ) {
console.log("del res -->",data);
if(data.data==null)
{
setTimeout(function(){
spinner.style.visibility = 'hidden';
$('#delete_confirm_yes').prop('disabled', false);
$.toast({
heading: 'Error',
text: data.message,
icon: 'error',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
}, 3000);
}
else{
// console.log("data",data.data);
$('#delete_confirm_btn').click();
$('#delete_otp').val('');
$('#dele_nul_otp').hide();
$('#dele_otp_err').hide();
$('#delete_confirm_yes').prop('disabled', false);
spinner.style.visibility = 'hidden';
}
}
});
}
function otpClick(){
var cust_id=$('#delete_id').val();
var otp=$('#delete_otp').val();
var type="customer";
if(otp=="")
{
$('#dele_otp_err').hide();
$('#dele_nul_otp').show();
}
else{
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "api/confirmAccountDelete" ,
type:"POST",
data:{user_id:cust_id,type:type,unique_code:otp},
success: function( data ) {
if(data.message=="After 15 to 30 minutes your account will be deleted.")
{
$('#dele_otp_err').hide();
$.toast({
heading: 'Information',
text:data.message,
icon: 'success',
loader: true, // Change it to false to disable loader
loaderBg: '#9EC600',
position: 'top-right',
class: 'custom_toast'
});
var href = $('#logout').attr('href');
setTimeout(function(){
window.location.href = href;
}, 3000);
setTimeout(function(){
location.reload();
}, 4000);
}
else{
$('#dele_nul_otp').hide();
$('#dele_otp_err').show();
}
}
});
}
}