var breeze_prefetch = {"local_url":"https:\/\/hobbylegends.com","ignore_remote_prefetch":"1","ignore_list":["\/cart\/","\/checkout\/","\/my-account\/","wp-admin","wp-login.php"]};
var wc_add_to_cart_params = {"ajax_url":"\/wp-admin\/admin-ajax.php","wc_ajax_url":"\/?wc-ajax=%%endpoint%%","i18n_view_cart":"View cart","cart_url":"https:\/\/hobbylegends.com\/cart\/","is_cart":"","cart_redirect_after_add":"no"};
function paypaltogglePopup() {
jQuery(".paypalemailid").toggle();
}
function validatePhone(txtPhone) {
var phonenumber = txtPhone;
var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/;
if (filter.test(phonenumber)) {
return true;
} else {
return false;
}
}
//validating address field on register page so that user cant enter random data
function validateAddress(addressInput, e) {
if (typeof placeId === 'undefined' || placeId === null || !placeId) {
// User hasn't selected an address from the suggestions
console.log('Please select an address from the suggestions.');
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please select a valid address from the autocomplete suggestions.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault(); // Prevent form submission if the address is empty
jQuery('html, body').animate({
scrollTop: jQuery('.woocommerce-error').offset().top - 300
}, 1000);
return false;
} else {
// User has selected an address from the suggestions
// Proceed with your further validation or processing
console.log('Address is validated. Place ID: ' + placeId);
// var user_address = addressInput.val();
if (user_address === '') {
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please select a valid address from the autocomplete suggestions.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault(); // Prevent form submission if the address is empty
jQuery('html, body').animate({
scrollTop: jQuery('.woocommerce-error').offset().top - 300
}, 1000);
return false;
} else {
// Make a synchronous API request to the Google Geocoding API
var apiKey = 'AIzaSyB0mAr0TtwwE4kSoCh42pquepIYhDw3VBs'; // Replace with your Google API key
var geocodingApiUrl = 'https://maps.googleapis.com/maps/api/geocode/json';
// Prepare the parameters for the API request
var requestData = {
address: user_address,
key: apiKey
};
var isValid = false;
// Send the API request
$.ajax({
url: geocodingApiUrl,
data: requestData,
async: false, // Make the request synchronous
success: function(response) {
if (response.status === 'OK') {
// Address is valid
isValid = true;
var location = response.results[0].geometry.location;
var latitude = location.lat;
var longitude = location.lng;
console.log('Latitude: ' + latitude);
console.log('Longitude: ' + longitude);
e.preventDefault();
} else {
// Address is not valid, display an error message
var errorMessage = 'Invalid or incomplete address. Please select a valid address.';
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> ' + errorMessage + '</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault();
// Scroll to the error message
jQuery('html, body').animate({
scrollTop: jQuery('.woocommerce-error').offset().top - 300
}, 1000); // You can adjust the scrolling duration (1000ms = 1 second)
}
}
});
return isValid;
}
}
}
jQuery(document).ready(function() {
//jQuery('form.woocommerce-EditAccountForm fieldset').remove();
jQuery('form.woocommerce-form-register').on('submit', function(e) {
var reg_username = jQuery('form.woocommerce-form-register input#reg_username').val();
var reg_email = jQuery('form.woocommerce-form-register input#reg_email').val();
var reg_password = jQuery('form.woocommerce-form-register input#reg_password').val();
var phonenumber = jQuery('form.woocommerce-form-register input#phone_number').val();
//var user_address = jQuery('form.woocommerce-form-register textarea#user_address').val();
var addressInput = jQuery('form.woocommerce-form-register textarea#user_address');
jQuery('.woocommerce-error').remove();
if (reg_username == '') {
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please provide a username.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault();
} else if (reg_email == '') {
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please provide a valid email address.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault();
} else if (phonenumber != '' || phonenumber == '') {
if (phonenumber == '') {
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please provide a phone number.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault();
} else {
if (!validatePhone(phonenumber)) {
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please provide a valid phone number.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault();
} else {
// if (user_address == '' ) {
// var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please provide address.</li></ul>';
// jQuery(html).insertBefore("form.woocommerce-form-register");
// e.preventDefault();
// }
if (!validateAddress(addressInput, e)) {
e.preventDefault(); // Prevent form submission if the address is not valid
}
}
}
} else if (user_address == '') {
var html = '<ul class="woocommerce-error"><li><strong>Error:</strong> Please provide address.</li></ul>';
jQuery(html).insertBefore("form.woocommerce-form-register");
e.preventDefault();
} else {
}
})
jQuery('.paymentGateway button').click(function() {
jQuery('body').addClass('popup-body');
});
jQuery('.paypalemailid .close-btn').click(function() {
jQuery('body').removeClass('popup-body');
});
jQuery('#paypalemailbutton').click(function() {
var paypalemail = jQuery('#paypalemail').val();
if (paypalemail) {
jQuery('.loadingImg').show();
var ajax_url = "https://hobbylegends.com/wp-admin/admin-ajax.php";
var datas = {
'action': 'verificationPaypalEmail',
'paypalemail': paypalemail
};
jQuery.ajax({
url: ajax_url,
type: 'POST',
data: datas,
success: function(response) {
jQuery('.loadingImg').hide();
jQuery('#requestresponse').html(response);
setTimeout(function() {
location.reload();
}, 1500);
}
});
} else {
jQuery('#paypalemail').css('border', '1px solid red');
}
})
});
var video = document.getElementById('banner-vdo');
function toggleMutes() {
video.muted = !video.muted;
}
jQuery(document).ready(function($) {
//var video=document.getElementById("banner-vdo") ;
$(video).on("click", function(e) {
video.muted = !video.muted;
});
})
var wc_order_attribution = {"params":{"lifetime":1.0e-5,"session":30,"base64":false,"ajaxurl":"https:\/\/hobbylegends.com\/wp-admin\/admin-ajax.php","prefix":"wc_order_attribution_","allowTracking":true},"fields":{"source_type":"current.typ","referrer":"current_add.rf","utm_campaign":"current.cmp","utm_source":"current.src","utm_medium":"current.mdm","utm_content":"current.cnt","utm_id":"current.id","utm_term":"current.trm","utm_source_platform":"current.plt","utm_creative_format":"current.fmt","utm_marketing_tactic":"current.tct","session_entry":"current_add.ep","session_start_time":"current_add.fd","session_pages":"session.pgs","session_count":"udata.vst","user_agent":"udata.uag"}};
//paste this code under the head tag or in a separate js file.
// Wait for window load
$(document).ready(function(){
// Animate loader off screen
$(".se-pre-con").fadeOut("slow");
});