Subversion Repositories SmartDukaan

Rev

Rev 3406 | Rev 4143 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3406 Rev 3830
Line 7... Line 7...
7
	
7
	
8
	$('#forgot_username_link').tipsy({gravity: 'w'});
8
	$('#forgot_username_link').tipsy({gravity: 'w'});
9
 
9
 
10
	$("#zipcode").val($("#defaultpincode").val());
10
	$("#zipcode").val($("#defaultpincode").val());
11
 
11
 
12
    updateEstimate($("#colorselector option:selected").val());
12
    updateEstimate(getSeletectedItemId());
13
    
13
    
14
    var prodid = $("#product_id").val();
14
    var prodid = $("#product_id").val();
15
    
15
    
16
	add_to_storage_set("histitems", prodid);
16
	add_to_storage_set("histitems", prodid);
17
    
17
    
Line 21... Line 21...
21
    
21
    
22
    load_most_compared_widget();
22
    load_most_compared_widget();
23
 
23
 
24
    myNotes.getNotes();
24
    myNotes.getNotes();
25
    
25
    
-
 
26
    function getSeletectedItemId(){
-
 
27
    	 return $("#item_id").val();
-
 
28
    }
-
 
29
    
-
 
30
    
26
    /**
31
    /**
27
     * Code to track user clicks on Product slides and 'Proceed to Payment' option
32
     * Code to track user clicks on Product slides and 'Proceed to Payment' option
28
     */
33
     */
29
	$('a.vt').click(function(){
34
	$('a.vt').click(function(){
30
		trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
35
		trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
31
	});
36
	});
32
	
37
	
-
 
38
	$('#computeShippingEstimate').click(function(){
-
 
39
		updateEstimate(getSeletectedItemId());
-
 
40
	});
-
 
41
	
33
    $("#addcart").click(function(){
42
    $("#addToCart").click(function(){
34
    	jQuery.ajax({
43
    	jQuery.ajax({
35
			type: "POST",
44
			type: "POST",
36
			url: "/addtocart",
45
			url: "/addtocart",
37
			data: "productid=" + $("#item_id").val(),
46
			data: "productid=" + getSeletectedItemId(),
38
			success: function(msg)	{
47
			success: function(msg)	{
39
	   			 if(msg==""){
48
	   			 if(msg==""){
40
	   				 trackEventWithGA('Order', 'Add to Cart', $("#item_id").val() + '');
49
	   				 trackEventWithGA('Order', 'Add to Cart', getSeletectedItemId() + '');
41
					 window.location = "/cart";
50
					 window.location = "/cart";
42
				 }else{
51
				 }else{
43
					 displayRelatedProducts(msg);
52
					 displayRelatedProducts(msg);
44
				 }			
53
				 }			
45
	   		}
54
	   		}
46
		});
55
		});
47
	});
56
	});
48
	
57
	
49
	$("#colorselector").change(function(){
58
	$("#colorSelector").change(function(){
50
		var itemid = $("#colorselector option:selected").val();
59
		var itemid = $("#colorSelector option:selected").val();
51
		$('#sp').html(PARAMETERS[itemid].SP);
60
		$('#sp').html(PARAMETERS[itemid].SP);
52
		$('#mrp').html(PARAMETERS[itemid].MRP);
61
		$('#mrp').html(PARAMETERS[itemid].MRP);
53
		$('#saving').html(PARAMETERS[itemid].SAVING);
62
		$('#saving').html(PARAMETERS[itemid].SAVING);
54
		$("#item_id").val(itemid);
63
		$("#item_id").val(itemid);
55
		updateEstimate(itemid);
64
		updateEstimate(itemid);
56
		return false;
65
		return false;
57
	});
66
	});
58
	
67
	
59
	$("a.colorselector").click(function() {
68
/*	$("a.colorselector").click(function() {
60
		$('.a.colorselector').addClass('deselect');
69
		$('.a.colorselector').addClass('deselect');
61
		$(this).addClass('deselect');
70
		$(this).addClass('deselect');
62
		var itemid = $(this).attr('itemid');
71
		var itemid = $(this).attr('itemid');
63
		$('#sp').html(" "+PARAMETERS[itemid].SP);
72
		$('#sp').html(" "+PARAMETERS[itemid].SP);
64
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
73
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
65
		$('#saving').html(PARAMETERS[itemid].SAVING);
74
		$('#saving').html(PARAMETERS[itemid].SAVING);
66
		$("#item_id").val(itemid);
75
		$("#item_id").val(itemid);
67
		return false;
76
		return false;
68
	});
77
	});*/
69
 
78
 
70
	$("#util_compare").click(function() {
79
	$(".util_compare").click(function() {
71
		$.colorbox({
80
		$.colorbox({
72
			inline:true, 
81
			inline:true, 
73
			href:"#compareLightBox",
82
			href:"#compareLightBox",
74
    		width:"350px",
83
    		width:"350px",
75
    		height:"230px",
84
    		height:"230px",
Line 80... Line 89...
80
    		onCleanup: function(){
89
    		onCleanup: function(){
81
    			$('#compareLightBox').hide();
90
    			$('#compareLightBox').hide();
82
    		}
91
    		}
83
    	});
92
    	});
84
	});
93
	});
-
 
94
	
-
 
95
	$('.util_addnewresearch').click(function(){
-
 
96
		addResearch('', 'single');
-
 
97
	});
85
 
98
	
86
	/* This code is for compare with button */
99
	/* This code is for compare with button */
87
	var availableNames = [];
100
	var availableNames = [];
88
	for (var k in productIdNames)availableNames.push(k);
101
	for (var k in productIdNames)availableNames.push(k);
89
    $("#mobilename").autocomplete({  autoFocus: true, minLength: 3, 
102
    $("#mobilename").autocomplete({  autoFocus: true, minLength: 3, 
90
        source: availableNames
103
        source: availableNames
Line 145... Line 158...
145
	}
158
	}
146
}
159
}
147
 
160
 
148
 
161
 
149
function updateEstimate(itemId)	{
162
function updateEstimate(itemId)	{
150
	itemId = itemId || $("#item_id").val();
163
	itemId = itemId || $("#colorSelector option:selected").val();
151
	
164
	
152
	jQuery.ajax({
165
	jQuery.ajax({
153
		type: "GET",
166
		type: "GET",
154
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
167
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
155
		beforeSend: function()	{
168
		beforeSend: function()	{
156
			$("#shipping_time").html("Within <img src='/images/loader_l.gif'> business days");
169
			$("#shipping_time").html("Receive in <img src='/images/loader_l.gif'> business days");
157
		},
170
		},
158
		success: function(msg)	{
171
		success: function(msg)	{
-
 
172
			var response = eval('(' + msg + ')');
-
 
173
			var deliveryEstimate = parseInt(response['delivery_estimate']);
-
 
174
			var isCODAvailableForLocation = (response['is_cod_available_for_location'] === 'true');
-
 
175
			
-
 
176
			if(deliveryEstimate == -1)	{
159
			$("#shipping_time").html(msg);
177
				$("#shipping_time").html('This Location is not serviceable');
-
 
178
			} else	{
-
 
179
				$("#shipping_time").html('Receive in <label class="red">' + deliveryEstimate + ' Business Days</label>');
-
 
180
			}
-
 
181
			
-
 
182
			if (isCODAvailableForLocation && parseInt($('#sp').html()) <= 10000)	{
-
 
183
				$('#cod').show();
-
 
184
			} else {
-
 
185
				$('#cod').hide();
-
 
186
			}
160
		}
187
		}
161
	});
188
	});
162
}
189
}
163
 
190
 
164
function load_most_compared_widget(){
191
function load_most_compared_widget(){