File "function.js"
Full Path: /home/krishnamexports/public_html/js/function.js
File size: 14.9 KB
MIME-type: text/plain; charset=us-ascii
Charset: utf-8
var baseUrl = "https://"+location.hostname+"/";
jQuery.fn.ForceNumericOnly =
function()
{
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
// home, end, period, and numpad decimal
return (
key == 8 ||
key == 9 ||
key == 13 ||
key == 46 ||
key == 110 ||
//key == 190 ||
(key >= 35 && key <= 40) ||
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105));
});
});
};
$(".regMobile").ForceNumericOnly();
$(".numberOnly").ForceNumericOnly();
$(".login").click(function(){
$(".log-in").css("display", "block");
$(".sign-up").css("display", "none");
});
$(".signup").click(function(){
$(".log-in").css("display", "none");
$(".sign-up").css("display", "block");
});
function signup()
{
$(".log-in").css("display", "none");
$(".sign-up").css("display", "block");
}
function login()
{
$(".log-in").css("display", "block");
$(".sign-up").css("display", "none");
}
$('.setCurrency').click(function(){
$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });
var currencyType = $(this).data('currency');
$.ajax({
url: baseUrl+"ajax/setCurrency.php?currencyType="+currencyType,
type: 'GET',
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1)
{
setTimeout(function(){location.reload();}, 1000);
}
}
});
});
$('#LoginCustomer').submit(function(e){
e.preventDefault();
$("#ErrorReg").html("");
$.ajax({
url: baseUrl+"ajax/LoginCustomer.php",
type: 'POST',
data:$("#LoginCustomer").serialize(),
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1)
{
$("#ErrorReg2").html(data.SuccessMsg);
setTimeout(function(){ location.reload(); }, 2000);
}
else if(data.status==2)
{
$("#ErrorReg2").html(data.ErrorMsg);
}
}
});
});
$('#RegisterCustomer').submit(function(e){
e.preventDefault();
$("#ErrorReg2").html("");
$.ajax({
url: baseUrl+"ajax/RegisterCustomer.php",
type: 'POST',
data:$("#RegisterCustomer").serialize(),
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1)
{
$("#ErrorReg").html(data.ErrorMsg);
}
else if(data.status==2)
{
$("#ErrorReg").html(data.SuccessMsg);
}
else if(data.status==3)
{
$("#ErrorReg").html(data.ErrorMsg);
}
}
});
});
$('.setPolish').click(function(){
var polishId = $(this).val();
$("#polish_id").val(polishId);
});
$('.setSize').change(function(){
var sizeId = $(this).val();
$("#size_id").val(sizeId);
});
/*$('.setStone').change(function(){
var stoneId = $(this).val();
$("#stone_id").val(stoneId);
});*/
$('.addtoCart').click(function(){
var productId = $(this).data('id');
var qty = $("#qty").val();
var polishId = $("#polish_id").val();
var sizeId = $("#size_id").val();
$(".addtoCart").html('<i class="fa fa-spinner fa-spin"></i> LOADING');
$(".addtoCart").attr('Disabled','Disabled');
$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });
$.ajax({
url: baseUrl+"ajax/addtoCart.php?productId="+productId+"&qty="+qty+"&polishId="+polishId+"&sizeId="+sizeId,
type: 'GET',
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1 || data.status==2 || data.status==3 || data.status==4)
{
$(".addtoCart").html('INSTANT ENQUIRY');
$(".addtoCart").removeAttr('Disabled');
$("#warning").html(data.msg);
$.unblockUI();
warningNotification();
}
else if(data.status==0)
{
$(".addtoCart").html('ADDED TO ENQUIRY');
$(".addtoCart").removeAttr('Disabled');
$("#success").html(data.msg);
$(".miniCart").html('');
$.each(data.productList, function(idx, obj) {
$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');
});
$(".productCount").html(data.productCount);
$(".miniCartTotal").html('');
//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');
$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> VIEW SELECTED PRODUCT</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> ENQUIRY NOW</a>');
$.unblockUI();
$("body").addClass('fix');
$(".minicart-inner").addClass('show');
successNotification();
$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {
console.log( textStatus );
});
}
}
});
});
$('.addtoCartBulk').click(function(){
$(".addtoCartBulk").html('<i class="fa fa-spinner fa-spin"></i> LOADING');
$(".addtoCartBulk").attr('Disabled','Disabled');
$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });
$.ajax({
url: baseUrl+"ajax/addtoCartBulk.php",
type: 'POST',
data:$("#addBulkOrder").serialize(),
dataType: 'html',
cache: true,
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1 || data.status==2 || data.status==3 || data.status==5)
{
$(".addtoCartBulk").html('INSTANT ENQUIRY');
$(".addtoCartBulk").removeAttr('Disabled');
$("#warning").html(data.msg);
$.unblockUI();
warningNotification();
}
else if(data.status==4)
{
$(".addtoCartBulk").html('ADDED TO ENQUIRY');
$(".addtoCartBulk").removeAttr('Disabled');
$("#success").html(data.msg);
$(".miniCart").html('');
$.each(data.productList, function(idx, obj) {
$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');
});
$(".productCount").html(data.productCount);
$(".miniCartTotal").html('');
//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');
$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> VIEW SELECTED PRODUCT</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> ENQUIRY NOW</a>');
$.unblockUI();
$("body").addClass('fix');
$(".minicart-inner").addClass('show');
successNotification();
$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {
console.log( textStatus );
});
}
else if(data.status==0)
{
$(".addtoCartBulk").html('ADDED TO ENQUIRY');
$(".addtoCartBulk").removeAttr('Disabled');
$("#success").html(data.msg);
$(".miniCart").html('');
$.each(data.productList, function(idx, obj) {
$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');
});
$(".productCount").html(data.productCount);
$(".miniCartTotal").html('');
//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');
$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> View Selected Product</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> ENQUIRY NOW</a>');
$.unblockUI();
successNotification();
$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {
console.log( textStatus );
});
}
}
});
});
$('.removeToCart').click(function(){
var productId = $(this).attr("data-productId");//$(this).data('productId');
var polishId = $(this).attr("data-polishId");//$(this).data('polishId');
var sizeId = $(this).attr("data-sizeId");//$(this).data('sizeId');
$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });
$.ajax({
url: baseUrl+"ajax/removeToCart.php?productId="+productId+"&polishId="+polishId+"&sizeId="+sizeId,
type: 'GET',
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1 || data.status==2 || data.status==3 || data.status==4)
{
$(".addtoCart").html('ADD TO ENQUIRY');
$(".addtoCart").removeAttr('Disabled');
$("#warning").html(data.msg);
$.unblockUI();
warningNotification();
}
else if(data.status==0)
{
$("#success").html(data.msg);
$(".miniCart").html('');
$.each(data.productList, function(idx, obj) {
$(".miniCart").append('<li class="minicart-item"><div class="minicart-thumb"><a href="'+baseUrl+'product/'+obj.productSlugURL+'"><img src="'+baseUrl+'products/'+obj.productPhoto+'" alt="product"></a></div><div class="minicart-content"><h3 class="product-name"><a href="product-details.html">'+obj.productName+'</a></h3><p><span class="cart-quantity">Qty - '+obj.qty+'</p></div><button class="minicart-remove removeToCart" data-productId="'+obj.productId+'" data-polishId="'+obj.polishId+'" data-sizeId="'+obj.sizeId+'"><i class="pe-7s-close"></i></button></li>');
});
$(".productCount").html(data.productCount);
if(data.productList.length>0)
{
//$(".miniCartTotal").html('<li><span><strong>Sub Total</strong></span><span><strong>'+data.subTotal+'</strong></span></li><li><span><strong>Delivery Charges</strong></span><span><strong>'+data.deliveryCharges+'</strong></span></li><li class="total"><span><strong>Total</strong></span><span><strong>'+data.orderTotal+'</strong></span></li>');
$(".miniCartTotal").html('');
$(".minicart-button").html('<a href="'+baseUrl+'cart"><i class="fa fa-shopping-cart"></i> View Selected Product</a><a href="'+baseUrl+'checkout" class="processCheckout"><i class="fa fa-share"></i> ENQUIRY NOW</a>');
}
else
{
$(".miniCart").append('<div class="empty-cart"><img src="'+baseUrl+'assets/img/icon/empty-cart.png"><p>There is no Product in your Enquery List</p></div>');
$(".miniCartTotal").html('');
$(".minicart-button").html('<a href="'+baseUrl+'"><i class="fa fa-shopping-cart"></i> Continue Enquiry</a>');
}
$.unblockUI();
successNotification();
$.getScript( baseUrl+"js/function.js" ).done(function( script, textStatus ) {
console.log( textStatus );
});
setTimeout(function(){ location.reload(); }, 1000);
}
}
});
});
$('.processCheckout').click(function(){
//e.preventDefault();
var adRemark = [];
$("input[name='additionInfo[]']").each(function () {
//alert($(this).val());
adRemark.push($(this).val());
})
var additionalInfo = adRemark.join("/");
$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });
$.ajax({
url: baseUrl+"ajax/checkLogin.php?additionalInfo="+additionalInfo,
type: 'GET',
dataType: 'html',
success: function (data) {
var data = $.parseJSON(data);
if(data.status==1)
{
setTimeout(function(){ window.location.href = baseUrl+"checkout";}, 1000);
}
else if(data.status==2)
{
//$.unblockUI();
setTimeout(function(){ window.location.href = baseUrl+"checkout";}, 1000);
//$('#modalRegisterForm').modal('show');
}
}
});
});
$('#placeOrder').submit(function(e){
e.preventDefault();
$.blockUI({ message: '<h4><img src="'+baseUrl+'assets/img/busy.gif" /> Please Wait...</h4>' });
$.ajax({
url: baseUrl+"ajax/placeOrder.php",
type: 'POST',
data:$("#placeOrder").serialize(),
dataType: 'html',
success: function (data){
var data = $.parseJSON(data);
//alert(data.status);
if(data.status==true)
{
setTimeout(function(){ window.location.href = baseUrl+"thank-you.php?orderId="+data.orderId;}, 2000);
}
else
{
setTimeout(function(){ window.location.href = baseUrl+"checkout";}, 2000);
}
}
});
});
function warningNotification() {
var x = document.getElementById("warning");
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 4000);
}
function successNotification() {
var x = document.getElementById("success");
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 4000);
}