| 14386 |
anikendra |
1 |
var livePriceCalls = [];
|
| 14432 |
anikendra |
2 |
var outOfStockCount = 0;
|
| 14773 |
anikendra |
3 |
function getcashbackstring(type,value) {
|
| 18220 |
naman |
4 |
if(value==0){
|
|
|
5 |
return '';
|
|
|
6 |
}
|
|
|
7 |
if(type==2){
|
|
|
8 |
return ' +'+value+' Cashback';
|
|
|
9 |
}else if(type==1){
|
|
|
10 |
return ' +'+value+'% Cashback';
|
|
|
11 |
}else{
|
|
|
12 |
return '';
|
|
|
13 |
}
|
| 15926 |
anikendra |
14 |
};
|
|
|
15 |
function showShopcluesPopup(url){
|
| 18220 |
naman |
16 |
$('#shopcluesUrl').prop('href',url);
|
|
|
17 |
$('#shopcluesModal').modal('show');
|
|
|
18 |
return;
|
| 15926 |
anikendra |
19 |
};
|
| 16397 |
anikendra |
20 |
function showPaytmPopup(url){
|
| 18220 |
naman |
21 |
$('#paytmUrl').prop('href',url);
|
|
|
22 |
$('#paytmModal').modal('show');
|
|
|
23 |
return;
|
| 16397 |
anikendra |
24 |
};
|
| 16485 |
anikendra |
25 |
function showPaytmHelpPopup() {
|
| 18220 |
naman |
26 |
$('#loadingModal').modal('hide');
|
|
|
27 |
$('#paytmHelpModal').modal('show');
|
| 16485 |
anikendra |
28 |
}
|
|
|
29 |
function redirectToPaytm(url){
|
| 18220 |
naman |
30 |
url = 'http://mobilehotindia.com/r.html?'+Base64.encode(url);
|
|
|
31 |
$('#paytmHelpModal').modal('hide');
|
|
|
32 |
//check if paytm is active or not
|
|
|
33 |
var paytmactive = getCookie('paytmActive',1);
|
|
|
34 |
if(paytmactive && paytmactive == 'true'){
|
|
|
35 |
document.location = url;
|
|
|
36 |
pma.send('apk','paytm','active',me,null);
|
|
|
37 |
}else{
|
|
|
38 |
pma.send('apk','paytm','inactive',me,null);
|
|
|
39 |
$('#loadingModal').modal('hide');
|
|
|
40 |
showPaytmPopup(url);
|
|
|
41 |
}
|
| 16485 |
anikendra |
42 |
}
|
| 17006 |
naman |
43 |
|
|
|
44 |
function redirectTohomeShop18(url){
|
| 18220 |
naman |
45 |
url = 'http://mobilehotindia.com/r.html?'+Base64.encode(url);
|
|
|
46 |
//check if paytm is active or not
|
|
|
47 |
var homeShop18active = getCookie('homeshop18',1);
|
|
|
48 |
if(homeShop18active && homeShop18active == 'true'){
|
|
|
49 |
document.location = url;
|
|
|
50 |
pma.send('apk','homeShop18','active',me,null);
|
|
|
51 |
}else{
|
|
|
52 |
pma.send('apk','homeShop18','inactive',me,null);
|
|
|
53 |
$('#loadingModal').modal('hide');
|
|
|
54 |
showhomeShop18Popup(url);
|
|
|
55 |
}
|
| 17006 |
naman |
56 |
}
|
|
|
57 |
|
|
|
58 |
function showhomeShop18Popup(url){
|
| 18220 |
naman |
59 |
$('#homeShop18Url').prop('href',url);
|
|
|
60 |
$('#homeShop18Modal').modal('show');
|
|
|
61 |
return;
|
| 17006 |
naman |
62 |
};
|
|
|
63 |
|
| 18759 |
naman |
64 |
$(function(){
|
| 19244 |
amit.gupta |
65 |
if($('div.scrollselector').find('.card').length>0) {
|
| 18759 |
naman |
66 |
setTimeout(function(){ document.location.reload(); }, 1000*15*60);
|
| 19887 |
naman |
67 |
if(typeof noscrolling == 'undefined' && $('.nodeals').length <1) {
|
| 18759 |
naman |
68 |
$('.scrollselector').jscroll({
|
|
|
69 |
loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
|
|
|
70 |
autoTriggerUntil: 3,
|
|
|
71 |
padding: 20,
|
|
|
72 |
callback:loadCartDetails
|
|
|
73 |
});
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
if($('.storeminprice').length>0) {
|
|
|
77 |
var globalminprice = 9999999;
|
|
|
78 |
var globalminsku;
|
|
|
79 |
var globalmincashback = '';
|
|
|
80 |
var globalminoffer = '';
|
|
|
81 |
var calls = [];
|
| 18763 |
naman |
82 |
var priceRange = "";
|
| 19163 |
naman |
83 |
var saholic_cash = "";
|
|
|
84 |
var globalminpriceshow;
|
| 19328 |
naman |
85 |
var useroffertext = "";
|
| 18759 |
naman |
86 |
$('.storeminprice').each(function(){
|
|
|
87 |
var temp = {'sort':$(this).data('searchorder'),'val':$(this)};
|
|
|
88 |
calls.push(temp);
|
|
|
89 |
});
|
|
|
90 |
calls = sortByKey(calls,'sort');
|
|
|
91 |
for(var i in calls){
|
|
|
92 |
fetchLivePrice(calls[i]['val'])
|
|
|
93 |
}
|
|
|
94 |
};
|
|
|
95 |
function sortByKey(array, key) {
|
|
|
96 |
return array.sort(function(a, b) {
|
|
|
97 |
var x = a[key]; var y = b[key];
|
|
|
98 |
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
|
|
99 |
});
|
|
|
100 |
};
|
|
|
101 |
function getCouponText(coupon){
|
|
|
102 |
return "<span class='red'>"+coupon+"</span>";
|
|
|
103 |
};
|
|
|
104 |
function getGrossPriceText(gross_price,available_price){
|
|
|
105 |
if(gross_price == available_price)
|
|
|
106 |
return "";
|
|
|
107 |
return "Paytm cashback - "+(gross_price-available_price)+"<br>Net Price = <span class='red text-bigger'>"+available_price+"</span>"
|
|
|
108 |
}
|
|
|
109 |
function fetchLivePrice(obj){
|
|
|
110 |
ga('send', 'event', 'liveprice', 'fetch',$('#bestpriceproductname').html());
|
|
|
111 |
var properties = {};
|
|
|
112 |
properties.bundle_id = String($(obj).data('bundle_id'));
|
|
|
113 |
properties.product_name = String($('#bestpriceproductname').html());
|
|
|
114 |
pma.send('products','livesprice','fetch',me,properties);
|
|
|
115 |
var that = obj;
|
|
|
116 |
var inStock = false;
|
|
|
117 |
var priceToCompare = 0;
|
| 19163 |
naman |
118 |
var priceToShow = 0;
|
| 18759 |
naman |
119 |
var req = $.ajax({
|
|
|
120 |
url: '/store_products/getliveprice/'+$(that).data('bundle_id')+'/'+$(that).data('id'),
|
|
|
121 |
// Tell jQuery we're expecting JSONP
|
|
|
122 |
dataType: "json",
|
|
|
123 |
// Tell YQL what we want and that we want JSON
|
|
|
124 |
method: 'get',
|
|
|
125 |
// timeout: 30000,
|
|
|
126 |
// Work with the response
|
|
|
127 |
success: function( response ) {
|
|
|
128 |
if(response.success){
|
|
|
129 |
var i = 0;
|
|
|
130 |
var minpriceindex = 0;
|
|
|
131 |
if(response.products[i].in_stock == 1) {
|
|
|
132 |
inStock = true;
|
|
|
133 |
var minprice = 9999999;//Math.round(response.products[i]['available_price']);
|
|
|
134 |
var minpriceurl = response.products[i]['marketPlaceUrl'];
|
|
|
135 |
}
|
|
|
136 |
if(response.products.length>0){
|
|
|
137 |
//More than one products in store
|
|
|
138 |
var variants = [];
|
|
|
139 |
var j = 0;
|
|
|
140 |
for(var i in response.products){
|
|
|
141 |
if(response.products[i].in_stock == 1){
|
|
|
142 |
if(response.products[i].gross_price && response.products[i].gross_price > response.products[i].available_price) {
|
| 19163 |
naman |
143 |
// priceToCompare = response.products[i].gross_price;
|
|
|
144 |
priceToCompare = response.products[i].netPriceAfterCashBack;
|
|
|
145 |
priceToShow = response.products[i].gross_price;
|
| 18759 |
naman |
146 |
}else{
|
|
|
147 |
if (response.products[i].source_id == 4 && response.products[i].cheapestBulkPrice != 0) {
|
| 19328 |
naman |
148 |
useroffertext = response.offertext;
|
| 18759 |
naman |
149 |
priceToCompare = response.products[i].cheapestBulkPrice;
|
|
|
150 |
if(response.products[i].packQuantity>1){
|
|
|
151 |
priceRange =(Math.round((response.products[i].cheapestBulkPrice/response.products[i].packQuantity) * 100) / 100) + " - "
|
| 19175 |
naman |
152 |
+ (Math.round((response.products[i].available_price/response.products[i].packQuantity) * 100) / 100) + " /- per unit";
|
| 18759 |
naman |
153 |
}
|
|
|
154 |
else{
|
|
|
155 |
priceRange = response.products[i].cheapestBulkPrice
|
|
|
156 |
+ " - "
|
| 19175 |
naman |
157 |
+ Math.round(response.products[i].available_price);
|
| 18759 |
naman |
158 |
}
|
|
|
159 |
|
| 18290 |
naman |
160 |
|
| 18759 |
naman |
161 |
} else {
|
| 19328 |
naman |
162 |
useroffertext = response.offertext;
|
| 19163 |
naman |
163 |
priceToCompare = response.products[i].netPriceAfterCashBack;
|
|
|
164 |
priceToShow = response.products[i].available_price;
|
|
|
165 |
if(response.products[i].source_id == 4 && response.products[i].showNetPrice == 1 && response.products[i].cash_back >0 && response.products[i].cash_back_type > 0){
|
|
|
166 |
priceToShow = response.products[i].netPriceAfterCashBack;
|
| 19167 |
naman |
167 |
saholic_cash = '<span style="font-size:10px;color:#555;">(</span><span style="font-size:10px;color:red;">₹ '+response.products[i].available_price+'</span> <span style="font-size:10px;color:#555;">less </span>';
|
| 19163 |
naman |
168 |
if(response.products[i].cash_back_type == 2){
|
| 19167 |
naman |
169 |
saholic_cash = saholic_cash+'<span style="font-size:10px;color:green">₹ '+response.products[i].cash_back+' Cashback</span><span style="font-size:10px;color:#555;">)</span>';
|
| 19163 |
naman |
170 |
}
|
|
|
171 |
if(response.products[i].cash_back_type == 1){
|
| 19167 |
naman |
172 |
saholic_cash = saholic_cash+'<span style="font-size:10px;color:green">'+response.products[i].cash_back+'% Cashback</span><span style="font-size:10px;color:#555;">)</span>';
|
| 19163 |
naman |
173 |
}
|
|
|
174 |
}
|
| 18759 |
naman |
175 |
}
|
|
|
176 |
}
|
|
|
177 |
inStock = true;
|
|
|
178 |
if(priceToCompare && priceToCompare <= globalminprice) {
|
|
|
179 |
if (typeof globalminsource != "undefined" && globalminsource==4 && priceToCompare==globalminprice){
|
|
|
180 |
} else {
|
|
|
181 |
globalminprice = Math.round(priceToCompare);
|
| 19168 |
naman |
182 |
globalminpriceshow = Math.round(priceToShow);
|
| 18759 |
naman |
183 |
globalminsku = response.products[i]._id;
|
|
|
184 |
globalminsource = response.products[i].source_id;
|
|
|
185 |
globalminurl = response.products[i].marketPlaceUrl;
|
|
|
186 |
globalminoffer = response.products[i].offer;
|
| 19163 |
naman |
187 |
if(globalminsource == 4 && saholic_cash !=""){
|
|
|
188 |
globalmincashback = saholic_cash;
|
|
|
189 |
}else{
|
|
|
190 |
globalmincashback = getcashbackstring(response.products[i].cash_back_type,response.products[i].cash_back);
|
|
|
191 |
}
|
|
|
192 |
|
| 18759 |
naman |
193 |
}
|
|
|
194 |
}
|
|
|
195 |
if(typeof minprice == 'undefined' || priceToCompare < minprice) {
|
| 19163 |
naman |
196 |
// minprice = Math.round(priceToCompare);
|
|
|
197 |
minprice = Math.round(priceToShow);
|
| 18759 |
naman |
198 |
minpriceindex = j;
|
|
|
199 |
}
|
|
|
200 |
if(response.products[i].tagline && response.products[i].tagline.length>0 && $('#productoneliner').html().length==0) {
|
|
|
201 |
$('#productoneliner').html(response.products[i].tagline).removeClass('hidden').show();
|
|
|
202 |
}
|
|
|
203 |
variants.push({'name' : response.products[i].source_product_name, 'source_id' : response.products[i].source_id, 'available_price' : Math.round(response.products[i].available_price), 'url' : response.products[i].marketPlaceUrl,'source_product_name' : response.products[i].source_product_name,'id' : response.products[i]._id,'cash_back_type' : response.products[i].cash_back_type,'cash_back' : response.products[i].cash_back,'coupon': response.products[i].coupon,'codAvailable' : response.products[i].codAvailable,'offer' : response.products[i].offer,'gross_price' : response.products[i].gross_price});
|
|
|
204 |
}
|
|
|
205 |
j++;
|
|
|
206 |
}
|
|
|
207 |
if(variants.length>1){
|
|
|
208 |
variants.splice(minpriceindex,1);
|
|
|
209 |
var variantslink = $('<span class="variants"> '+(variants.length+1)+' Options</span>');
|
|
|
210 |
$(that).parent().parent().find('.pull-left',0).append(variantslink);
|
|
|
211 |
$(variantslink).data('variants',variants).data('minprice',minprice);
|
|
|
212 |
}
|
|
|
213 |
}
|
|
|
214 |
if(inStock){
|
|
|
215 |
$(that).html(minprice).siblings('.cashbackamount').html(getcashbackstring(response.products[minpriceindex].cash_back_type,response.products[minpriceindex].cash_back)).parent().addClass('viewproduct');
|
|
|
216 |
|
|
|
217 |
if($(that).parent().data('storename') == "Saholic")
|
|
|
218 |
{
|
| 19328 |
naman |
219 |
if(useroffertext != "")
|
|
|
220 |
{
|
| 19330 |
naman |
221 |
$(that).html(minprice).siblings('.userofferinlist').html('<div style="font-size:12px;color:maroon;"><a href="'+apihost+'categories/target" style="color:maroon;"><span class="glyphicon glyphicon-tags"></span> <u>'+useroffertext+'</u></a></div>');
|
| 19328 |
naman |
222 |
}
|
| 19163 |
naman |
223 |
if(saholic_cash !=""){
|
| 19167 |
naman |
224 |
$(that).html(minprice).siblings('.cashbackamount').html("<div>"+saholic_cash+"</div>");
|
| 19163 |
naman |
225 |
}
|
| 18759 |
naman |
226 |
if (priceRange != "") {
|
|
|
227 |
$(that).html(priceRange);
|
|
|
228 |
}
|
|
|
229 |
var url = minpriceurl;
|
|
|
230 |
var value = url.substring(url.lastIndexOf('-') + 1);
|
|
|
231 |
$(that).parent().attr('data-identifier', value);
|
|
|
232 |
$(that).parent().attr('data-proid', response.products[minpriceindex]['_id']);
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
$('#name-'+$(that).data('id')).html(response.products[minpriceindex]['source_product_name']);
|
|
|
236 |
if(response.products[minpriceindex]['coupon'] && response.products[minpriceindex]['coupon'].length>0){
|
|
|
237 |
$('#couponcode-'+$(that).data('id')).show().find('span.red',0).html(getCouponText(response.products[minpriceindex]['coupon']));
|
|
|
238 |
}
|
|
|
239 |
if(!response.products[minpriceindex]['codAvailable']){
|
|
|
240 |
$('#codstatus-'+$(that).data('id')).show().removeClass('codstatus');
|
|
|
241 |
}
|
|
|
242 |
if(response.products[minpriceindex]['gross_price'] && response.products[minpriceindex]['gross_price'] > 0){
|
|
|
243 |
$('#gross_price-'+$(that).data('id')).show().removeClass('gross_price').html(getGrossPriceText(response.products[minpriceindex]['gross_price'],response.products[minpriceindex]['available_price']));
|
|
|
244 |
}
|
|
|
245 |
if(response.products[minpriceindex]['offer'].length>0){
|
|
|
246 |
$('#itemoffer-'+$(that).data('id')).show().html(response.products[minpriceindex]['offer']);
|
|
|
247 |
}
|
|
|
248 |
$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).data('source',response.products[minpriceindex]['source_id']).data('price',response.products[minpriceindex]['available_price']).data('url',response.products[minpriceindex]['marketPlaceUrl']).removeClass('hidden');
|
|
|
249 |
if(globalminprice != 9999999) {
|
| 19163 |
naman |
250 |
$('#bestprice').html(globalminpriceshow).siblings('.cashbackamount').html(globalmincashback).siblings('.productoffer').html(globalminoffer);
|
|
|
251 |
$('#beststorelink').data('id',globalminsku).data('source',globalminsource).data('price',globalminpriceshow).data('url',globalminurl).removeClass('hidden');
|
| 18759 |
naman |
252 |
$('#bestpricecontainer').removeClass('hidden');
|
| 18763 |
naman |
253 |
|
| 18759 |
naman |
254 |
if(typeof globalminsource!= "undefined") {
|
|
|
255 |
if (globalminsource==4){
|
| 19163 |
naman |
256 |
// $('#bestprice').html(globalminprice);
|
| 19328 |
naman |
257 |
if(useroffertext != "")
|
|
|
258 |
{
|
| 19330 |
naman |
259 |
$('#useroffer').html('<div style="font-size:12px;color:maroon;"><a href="'+apihost+'categories/target" style="color:maroon;"><span class="glyphicon glyphicon-tags"></span> <u>'+useroffertext+'</u></a></div>');
|
| 19328 |
naman |
260 |
}
|
|
|
261 |
|
| 18759 |
naman |
262 |
if (priceRange != "") {
|
|
|
263 |
$('#bestprice').html(priceRange);
|
|
|
264 |
}
|
|
|
265 |
var value = globalminurl.substring(globalminurl.lastIndexOf('-') + 1);
|
|
|
266 |
$('#beststorelink').attr('data-identifier', value);
|
|
|
267 |
$('#beststorelink').attr('data-proid', globalminsku);
|
|
|
268 |
} else {
|
|
|
269 |
$('#beststorelink').removeAttr('data-identifier');
|
|
|
270 |
$('#beststorelink').removeAttr('data-proid');
|
| 19330 |
naman |
271 |
$('#useroffer').empty();
|
| 18759 |
naman |
272 |
}
|
|
|
273 |
}
|
|
|
274 |
}
|
|
|
275 |
} else{
|
|
|
276 |
ga('send', 'event', 'liveprice', 'outofstock', $('#bestpriceproductname').html());
|
|
|
277 |
var properties = {};
|
|
|
278 |
properties.sku = String(response.products[0]._id);
|
|
|
279 |
properties.source = String(response.products[0].source_id);
|
|
|
280 |
properties.product_name = String($('#bestpriceproductname').html());
|
|
|
281 |
pma.send('products','liveprice','outofstock',me,properties);
|
|
|
282 |
outOfStockCount++;
|
|
|
283 |
$(that).parent().parent().remove();
|
|
|
284 |
}
|
| 19163 |
naman |
285 |
if(!response.products[minpriceindex].available_price){
|
| 18759 |
naman |
286 |
// outOfStockCount++;
|
|
|
287 |
// $(that).parent().parent().remove();
|
|
|
288 |
var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
|
|
|
289 |
$(that).html(btn);
|
|
|
290 |
// ga('send', 'event', 'liveprice', 'failed', response.products[0]._id);
|
|
|
291 |
// console.log('failed for '+ response);
|
|
|
292 |
// properties = {};
|
|
|
293 |
// properties.sku = String(response.products[0]._id);
|
|
|
294 |
// pma.send('products','liveprice','failed',me,properties);
|
|
|
295 |
}
|
|
|
296 |
} else{
|
|
|
297 |
// outOfStockCount++;
|
|
|
298 |
// $(that).parent().parent().remove();
|
|
|
299 |
var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
|
|
|
300 |
$(that).html(btn);
|
|
|
301 |
ga('send', 'event', 'liveprice', 'failure', response.products[0]._id);
|
|
|
302 |
properties = {};
|
|
|
303 |
properties.sku = String(response.products[0]._id);
|
|
|
304 |
pma.send('products','liveprice','failure',me,properties);
|
|
|
305 |
}
|
|
|
306 |
checkForOutStocks(outOfStockCount);
|
|
|
307 |
},
|
|
|
308 |
error: function(request, status, err) {
|
|
|
309 |
var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
|
|
|
310 |
$(that).html(btn);
|
|
|
311 |
try{
|
|
|
312 |
if(response){
|
|
|
313 |
ga('send', 'event', 'liveprice', 'error', response.products[0]._id);
|
|
|
314 |
var properties = {};
|
|
|
315 |
properties.sku = String(response.products[0]._id);
|
|
|
316 |
pma.send('products','livescore','error',me,properties);
|
|
|
317 |
}
|
|
|
318 |
} catch(e){}
|
| 18710 |
naman |
319 |
}
|
| 18759 |
naman |
320 |
});
|
|
|
321 |
livePriceCalls.push(req);
|
|
|
322 |
};
|
|
|
323 |
function checkForOutStocks(count){
|
|
|
324 |
if(count>=livePriceCalls.length){
|
|
|
325 |
$('#bestpricecontainer').html('<h4>Out of stock</h4>').removeClass('hidden');
|
|
|
326 |
}
|
|
|
327 |
};
|
|
|
328 |
$(document).on('click','.showless',function(){
|
|
|
329 |
$(this).addClass('hidden').siblings('.varnts').hide();
|
|
|
330 |
$(this).parent().find('.variants',0).removeClass('hidden').addClass('justshow');
|
|
|
331 |
});
|
|
|
332 |
$(document).on('click','.variants',function(){
|
|
|
333 |
$('.storeproductinfo').empty();
|
|
|
334 |
var variants = $(this).data('variants');
|
|
|
335 |
var minprice = $(this).data('minprice');
|
|
|
336 |
$('#variantscount').html(variants.length);
|
|
|
337 |
for(var i in variants){
|
|
|
338 |
if(variants[i].gross_price && variants[i].gross_price > variants[i].available_price) {
|
|
|
339 |
var priceToDisplay = variants[i].gross_price;
|
|
|
340 |
}else{
|
|
|
341 |
var priceToDisplay = variants[i].available_price;
|
|
|
342 |
}
|
|
|
343 |
if(minprice == priceToDisplay) {
|
|
|
344 |
var html = '<div class="clearfix varnts"></div><div class="col-xs-6 varnts text-small">'+variants[i].name+'</div><div class="col-xs-6 varnts viewproduct" data-source="'+variants[i].source_id+'" data-price="'+priceToDisplay+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span class="storeminprice">'+priceToDisplay+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span>';
|
|
|
345 |
} else {
|
|
|
346 |
var html = '<div class="clearfix varnts"></div><div class="col-xs-6 varnts text-small">'+variants[i].name+'</div><div class="col-xs-6 varnts viewproduct" data-source="'+variants[i].source_id+'" data-price="'+priceToDisplay+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span class="text-small">'+priceToDisplay+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span>';
|
|
|
347 |
}
|
|
|
348 |
if(variants[i].gross_price && variants[i].gross_price>0){
|
|
|
349 |
html += '<p class="text-small">'+getGrossPriceText(variants[i].gross_price,variants[i].available_price)+'</p>';
|
|
|
350 |
}
|
|
|
351 |
if(variants[i].offer.length>0){
|
|
|
352 |
html += '<p class="text-small">'+variants[i].offer+'</p>';
|
|
|
353 |
}
|
|
|
354 |
if(variants[i].coupon && variants[i].coupon.length>0){
|
|
|
355 |
html += '<p class="text-small">Use Coupon <span class="red">'+variants[i].coupon+'</span></p>';
|
|
|
356 |
}
|
|
|
357 |
if(!variants[i].codAvailable){
|
|
|
358 |
html += '<p class="text-small">COD not available</p>';
|
|
|
359 |
}
|
|
|
360 |
html += '</div></div>';
|
|
|
361 |
var row = $(html);
|
|
|
362 |
$(this).parent().parent().append(row);
|
|
|
363 |
}
|
|
|
364 |
var showless = $('<div class="showless col-xs-9 text-right">Less <i class="glyphicon glyphicon-chevron-up"></i></span>');
|
|
|
365 |
$(this).parent().parent().append(showless);
|
|
|
366 |
$(this).addClass('hidden');
|
|
|
367 |
});
|
|
|
368 |
$('.categorytab').on('click','.categorytabcontrol.active',function(){
|
|
|
369 |
$(this).toggleClass('active');
|
|
|
370 |
$('#preferences-'+$(this).data('id')).addClass('hidden');
|
|
|
371 |
$(this).parent().parent().children().find('.savecategorypreferences',0).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
|
|
|
372 |
});
|
|
|
373 |
$('.categorytab').on('click','.categorytabcontrol:not(.active)',function(){
|
|
|
374 |
$(this).parent().parent().find('.btn',0).click();
|
|
|
375 |
});
|
|
|
376 |
$('.categorytab').on('click','.editcategorypreferences',function(e){
|
|
|
377 |
var that = $(this);
|
|
|
378 |
$(that).removeClass('editcategorypreferences').addClass('savecategorypreferences').html('Done').addClass('btn-success');
|
|
|
379 |
$('#togglepreferences-'+$(that).data('id')).toggleClass('active');
|
|
|
380 |
$('#preferences-'+$(that).data('id')).removeClass('hidden');
|
|
|
381 |
$('.brandselector').each(function(){
|
|
|
382 |
if($(this).data('catid')==$(that).data('id')){
|
|
|
383 |
$(this).addClass('active');
|
|
|
384 |
}
|
|
|
385 |
});
|
|
|
386 |
$('.subcategoryselector').each(function(){
|
|
|
387 |
if($(this).data('catid')==$(that).data('id')){
|
|
|
388 |
$(this).addClass('active');
|
|
|
389 |
}
|
|
|
390 |
});
|
|
|
391 |
});
|
|
|
392 |
$('.categorytab').on('click','.savecategorypreferences',function(e){
|
|
|
393 |
var that = $(this);
|
|
|
394 |
$(that).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
|
|
|
395 |
$('#togglepreferences-'+$(that).data('id')).toggleClass('active');
|
|
|
396 |
$.ajax({
|
|
|
397 |
url: $('#categorypreference-'+$(that).data('id')).attr('action'),
|
|
|
398 |
data: $('#categorypreference-'+$(that).data('id')).serialize(),
|
|
|
399 |
// Tell jQuery we're expecting JSONP
|
|
|
400 |
dataType: "json",
|
|
|
401 |
// Tell YQL what we want and that we want JSON
|
|
|
402 |
method: 'post',
|
|
|
403 |
// Work with the response
|
|
|
404 |
success: function( response ) {
|
|
|
405 |
if(response.success){
|
|
|
406 |
$('#preferences-'+$(that).data('id')).addClass('hidden');
|
|
|
407 |
}
|
|
|
408 |
}
|
|
|
409 |
});
|
|
|
410 |
active = getCookie('shopcluesActive',1);
|
|
|
411 |
if(active && active == 'true'){
|
|
|
412 |
$('.firsttimemsg').removeClass('hidden').show();
|
|
|
413 |
}
|
|
|
414 |
ga('send', 'event', 'preferences', 'update', me);
|
|
|
415 |
properties = pma.formDataToObject($('#categorypreference-'+$(this).data('id')).serializeArray());
|
|
|
416 |
pma.send('preferences', 'update', 'set', me, properties);
|
|
|
417 |
});
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
$(document).on('click','.accsproduct',function(){
|
| 19244 |
amit.gupta |
421 |
setCookie('fresh', "0", .1, true);
|
| 18759 |
naman |
422 |
if (typeof(Storage) !== "undefined") {
|
| 19244 |
amit.gupta |
423 |
localStorage.pages = $('div.scrollselector').html();
|
| 18759 |
naman |
424 |
localStorage.removeItem("productdetail");
|
|
|
425 |
localStorage.setItem("productdetail", $(this).closest(".card").html());
|
|
|
426 |
}
|
|
|
427 |
$('#loadingModal').modal();
|
|
|
428 |
var redirect_url = $(this).data('url');
|
|
|
429 |
var properties = {};
|
|
|
430 |
properties.sku = String($(this).data('id'));
|
|
|
431 |
properties.source = String($(this).data('source'));
|
|
|
432 |
properties.url = encodeURIComponent($(this).data('url'));
|
|
|
433 |
properties.price = String($(this).data('price'));
|
|
|
434 |
pma.send('products','url','click',me,properties);
|
|
|
435 |
var call = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
|
|
|
436 |
$.ajax({
|
|
|
437 |
url: call,
|
|
|
438 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
439 |
jsonp: "callback",
|
|
|
440 |
// Tell jQuery we're expecting JSONP
|
|
|
441 |
dataType: "jsonp",
|
|
|
442 |
// Tell YQL what we want and that we want JSON
|
|
|
443 |
data: {
|
|
|
444 |
format: "json"
|
|
|
445 |
},
|
|
|
446 |
// Work with the response
|
|
|
447 |
success: function( response ) {
|
|
|
448 |
// console.log(response);
|
|
|
449 |
window.location = redirect_url;
|
|
|
450 |
},
|
|
|
451 |
error: function() {
|
|
|
452 |
window.location = redirect_url;
|
|
|
453 |
}
|
|
|
454 |
});
|
|
|
455 |
});
|
|
|
456 |
|
|
|
457 |
$(document).on('click','.viewproduct',function(e){
|
| 20758 |
amit.gupta |
458 |
localStorage.pages = $('div.scrollselector').html();
|
| 19244 |
amit.gupta |
459 |
setCookie('fresh', "0", .1, true);
|
| 20753 |
amit.gupta |
460 |
var proid = $(this).data("proid");
|
|
|
461 |
var identifier = $(this).data("identifier");
|
| 18759 |
naman |
462 |
|
|
|
463 |
if(typeof livePriceCalls != undefined) {
|
|
|
464 |
for(var i in livePriceCalls){
|
|
|
465 |
livePriceCalls[i].abort();
|
|
|
466 |
}
|
|
|
467 |
}
|
|
|
468 |
$('#loadingModal').modal();
|
| 20753 |
amit.gupta |
469 |
var store = $(this).data('source');
|
|
|
470 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
|
| 18759 |
naman |
471 |
$.ajax({
|
|
|
472 |
url: url,
|
|
|
473 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
474 |
jsonp: "callback",
|
|
|
475 |
// Tell jQuery we're expecting JSONP
|
|
|
476 |
dataType: "jsonp",
|
|
|
477 |
// Tell YQL what we want and that we want JSON
|
|
|
478 |
data: {
|
|
|
479 |
format: "json"
|
|
|
480 |
},
|
|
|
481 |
// Work with the response
|
|
|
482 |
success: function( response ) {
|
|
|
483 |
if(response.success && response.type=='redirect'){
|
|
|
484 |
if(store == 5) {
|
|
|
485 |
//check if shopclues is active or not
|
|
|
486 |
active = getCookie('shopcluesActive',1);
|
|
|
487 |
response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
|
|
|
488 |
if(active && active == 'true'){
|
|
|
489 |
document.location = response.url;
|
|
|
490 |
pma.send('apk','shopclues','active',me,null);
|
|
|
491 |
}else{
|
|
|
492 |
pma.send('apk','shopclues','inactive',me,null);
|
|
|
493 |
$('#loadingModal').modal('hide');
|
|
|
494 |
showShopcluesPopup(response.url);
|
|
|
495 |
}
|
|
|
496 |
} else if(store == 6 ) {
|
| 20504 |
amit.gupta |
497 |
redirectToPaytm(response.url);
|
|
|
498 |
}//for homeshop 18
|
|
|
499 |
else if(store == 7){
|
|
|
500 |
redirectTohomeShop18(response.url);
|
|
|
501 |
} else if (store == 3 || store == 2) {
|
| 18220 |
naman |
502 |
if (store == 2){
|
|
|
503 |
response.url = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
|
|
|
504 |
}
|
|
|
505 |
if (store == 3){
|
|
|
506 |
response.url = '/r.html?'+Base64.encode(response.url);
|
|
|
507 |
}
|
| 18290 |
naman |
508 |
} else if (store == 4) {
|
| 18759 |
naman |
509 |
var urll = apihost+"categories/saholicdeal/"+proid;
|
|
|
510 |
$.ajax({
|
| 18290 |
naman |
511 |
method: "GET",
|
|
|
512 |
url: urll,
|
|
|
513 |
},'json')
|
|
|
514 |
.done(function(msg){
|
| 18759 |
naman |
515 |
if (typeof(Storage) !== "undefined") {
|
|
|
516 |
localStorage.removeItem("productdetail");
|
|
|
517 |
localStorage.setItem("productdetail",msg);
|
|
|
518 |
document.location = apihost+"categories/dealdetail/"+identifier;
|
|
|
519 |
}
|
| 18290 |
naman |
520 |
});
|
| 20504 |
amit.gupta |
521 |
}
|
| 18759 |
naman |
522 |
else{
|
|
|
523 |
response.url = '/r.html?'+Base64.encode(response.url);
|
|
|
524 |
}
|
| 20673 |
amit.gupta |
525 |
if(store !=4){
|
|
|
526 |
if(response.showmessage == 1) {
|
|
|
527 |
$('#loadingModal').modal('hide');
|
|
|
528 |
$('#customMessage').html(response.message);
|
|
|
529 |
$('#customMessageModal').modal('show');
|
|
|
530 |
setTimeout(function(){ document.location = response.url;}, 1000*3);
|
|
|
531 |
} else{
|
|
|
532 |
document.location = response.url;
|
|
|
533 |
}
|
|
|
534 |
}
|
| 18220 |
naman |
535 |
}
|
|
|
536 |
},
|
|
|
537 |
error: function() {
|
|
|
538 |
document.location = url;
|
|
|
539 |
}
|
|
|
540 |
});
|
| 20753 |
amit.gupta |
541 |
ga('send', 'event', 'product', 'click', $(this).data('url'));
|
| 18220 |
naman |
542 |
var properties = {};
|
| 20753 |
amit.gupta |
543 |
properties.sku = String($(this).data('id'));
|
|
|
544 |
properties.source = String($(this).data('source'));
|
|
|
545 |
properties.url = encodeURIComponent($(this).data('url'));
|
|
|
546 |
properties.price = String($(this).data('price'));
|
| 18220 |
naman |
547 |
pma.send('products','url','click',me,properties);
|
|
|
548 |
});
|
|
|
549 |
$(document).on('click','.likeit',function(e){
|
|
|
550 |
var that = $(this);
|
|
|
551 |
if($(that).find('span.likedeal').hasClass('active')){
|
|
|
552 |
//User has already liked it,so remove like
|
|
|
553 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/like";
|
|
|
554 |
}else{
|
|
|
555 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/like";
|
|
|
556 |
}
|
|
|
557 |
$.ajax({
|
|
|
558 |
url: url,
|
|
|
559 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
560 |
jsonp: "callback",
|
|
|
561 |
// Tell jQuery we're expecting JSONP
|
|
|
562 |
dataType: "jsonp",
|
|
|
563 |
// Tell YQL what we want and that we want JSON
|
|
|
564 |
data: {
|
|
|
565 |
format: "json"
|
|
|
566 |
},
|
|
|
567 |
// Work with the response
|
|
|
568 |
success: function( response ) {
|
|
|
569 |
if(response.success){
|
|
|
570 |
that.find('span.likedeal').toggleClass('active');
|
|
|
571 |
$(".img-overlay div[name='dislikediv_"+that.data('id')+"']").find('span.dislikedeal').removeClass('active');
|
|
|
572 |
}
|
|
|
573 |
}
|
|
|
574 |
});
|
|
|
575 |
ga('send', 'event', 'product', 'like', $(this).data('id'));
|
|
|
576 |
var properties = {};
|
|
|
577 |
properties.sku = String($(this).data('id'));
|
|
|
578 |
pma.send('products','favourites','like',me,properties);
|
|
|
579 |
});
|
|
|
580 |
$('#myModal').on('click','#unlikebtn',function(e){
|
|
|
581 |
e.preventDefault();
|
|
|
582 |
var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
|
|
|
583 |
$.ajax({
|
|
|
584 |
url: url,
|
|
|
585 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
586 |
jsonp: "callback",
|
|
|
587 |
// Tell jQuery we're expecting JSONP
|
|
|
588 |
dataType: "jsonp",
|
|
|
589 |
// Tell YQL what we want and that we want JSON
|
|
|
590 |
data: {
|
|
|
591 |
format: "json"
|
|
|
592 |
},
|
|
|
593 |
// Work with the response
|
|
|
594 |
success: function( response ) {
|
|
|
595 |
}
|
|
|
596 |
});
|
|
|
597 |
$('#myModal').modal('hide');
|
|
|
598 |
ga('send', 'event', 'brand', 'hide', $('#myModal').find('#productToHide',0).val());
|
|
|
599 |
pma.send('brands','hide',$('#myModal').find('#productToHide',0).val(),me);
|
|
|
600 |
})
|
| 18066 |
naman |
601 |
$(document).on('click','.dislikeit',function(e){
|
| 18220 |
naman |
602 |
var that = $(this);
|
|
|
603 |
if($(that).find('span.dislikedeal').hasClass('active')){
|
|
|
604 |
//User has already liked it,so remove like
|
|
|
605 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
|
|
606 |
}else{
|
|
|
607 |
$('#myModal').find('#productToHide',0).val($(this).data('id'));
|
|
|
608 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
|
|
609 |
}
|
|
|
610 |
$.ajax({
|
|
|
611 |
url: url,
|
|
|
612 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
613 |
jsonp: "callback",
|
|
|
614 |
// Tell jQuery we're expecting JSONP
|
|
|
615 |
dataType: "jsonp",
|
|
|
616 |
// Tell YQL what we want and that we want JSON
|
|
|
617 |
data: {
|
|
|
618 |
format: "json"
|
|
|
619 |
},
|
|
|
620 |
// Work with the response
|
|
|
621 |
success: function( response ) {
|
|
|
622 |
if(response.success){
|
|
|
623 |
that.find('span.dislikedeal').toggleClass('active');
|
|
|
624 |
$(".img-overlay div[name='likediv_"+that.data('id')+"']").find('span.likedeal').removeClass('active');
|
|
|
625 |
}
|
|
|
626 |
}
|
|
|
627 |
});
|
|
|
628 |
ga('send', 'event', 'product', 'dislike', $(this).data('id'));
|
|
|
629 |
var properties = {};
|
|
|
630 |
properties.sku = String($(this).data('id'));
|
|
|
631 |
pma.send('products','favourites','dislike',me,properties);
|
|
|
632 |
});
|
|
|
633 |
$('.deletefav').on('click',function(){
|
|
|
634 |
var that = $(this);
|
|
|
635 |
$('#loadingModal').modal();
|
|
|
636 |
var url = apihost+"/user_actions/deletefav/"+me+"/"+$(this).data('id');
|
|
|
637 |
$.ajax({
|
|
|
638 |
url: url,
|
|
|
639 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
640 |
jsonp: "callback",
|
|
|
641 |
// Tell jQuery we're expecting JSONP
|
|
|
642 |
dataType: "jsonp",
|
|
|
643 |
// Tell YQL what we want and that we want JSON
|
|
|
644 |
data: {
|
|
|
645 |
format: "json"
|
|
|
646 |
},
|
|
|
647 |
// Work with the response
|
|
|
648 |
success: function( response ) {
|
|
|
649 |
$('#loadingModal').modal('hide');
|
|
|
650 |
if(response.success){
|
|
|
651 |
$('#fav-'+$(that).data('id')).hide('slow');
|
|
|
652 |
}
|
|
|
653 |
}
|
|
|
654 |
});
|
|
|
655 |
ga('send', 'event', 'favourites', 'remove', $(this).data('id'));
|
|
|
656 |
var properties = {};
|
|
|
657 |
properties.sku = String($(this).data('id'));
|
|
|
658 |
pma.send('products','favourites','remove',me,properties);
|
|
|
659 |
});
|
|
|
660 |
$('.clearfavs').on('click',function(){
|
|
|
661 |
var that = $(this);
|
|
|
662 |
$('#loadingModal').modal();
|
|
|
663 |
var url = apihost+"/user_actions/deleteallfavs/"+me+'/'+$(this).data('type');
|
|
|
664 |
$.ajax({
|
|
|
665 |
url: url,
|
|
|
666 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
667 |
jsonp: "callback",
|
|
|
668 |
// Tell jQuery we're expecting JSONP
|
|
|
669 |
dataType: "jsonp",
|
|
|
670 |
// Tell YQL what we want and that we want JSON
|
|
|
671 |
data: {
|
|
|
672 |
format: "json"
|
|
|
673 |
},
|
|
|
674 |
// Work with the response
|
|
|
675 |
success: function( response ) {
|
|
|
676 |
$('#loadingModal').modal('hide');
|
|
|
677 |
if(response.success){
|
|
|
678 |
$('.deletefav').each(function(){
|
|
|
679 |
$('#fav-'+$(this).data('id')).hide('slow');
|
|
|
680 |
})
|
|
|
681 |
}
|
|
|
682 |
$(that).hide();
|
|
|
683 |
}
|
|
|
684 |
});
|
|
|
685 |
ga('send', 'event', 'favourites', 'removeall', me);
|
|
|
686 |
pma.send('products','favourites','removeall',me);
|
|
|
687 |
});
|
|
|
688 |
$('.revealbrands').on('click',function(){
|
|
|
689 |
$(this).parent().find('.notfeatured').toggleClass('hidden');
|
|
|
690 |
if($(this).html()=='Others'){
|
|
|
691 |
$(this).html('Hide');
|
|
|
692 |
}else{
|
|
|
693 |
$(this).html('Others');
|
|
|
694 |
}
|
|
|
695 |
});
|
|
|
696 |
$(document).on('click','.showtips',function(){
|
|
|
697 |
$('.apptips').toggleClass('hidden');
|
|
|
698 |
});
|
|
|
699 |
$(document).on('click','.creditedcashbacks',function(){
|
|
|
700 |
if($(this).find('.glyphicon-plus',0).length>0){
|
|
|
701 |
$(this).find('.glyphicon-plus',0).removeClass('glyphicon-plus').addClass('glyphicon-minus');
|
|
|
702 |
}else{
|
|
|
703 |
$(this).find('.glyphicon-minus',0).removeClass('glyphicon-minus').addClass('glyphicon-plus');
|
|
|
704 |
}
|
|
|
705 |
$(this).next().toggleClass('hidden');
|
|
|
706 |
});
|
|
|
707 |
$(document).on('click','.panel-heading a',function(){
|
|
|
708 |
if($(this).find('.glyphicon-plus',0).length>0){
|
|
|
709 |
$(this).find('.glyphicon-plus',0).removeClass('glyphicon-plus').addClass('glyphicon-minus');
|
|
|
710 |
}else{
|
|
|
711 |
$(this).find('.glyphicon-minus',0).removeClass('glyphicon-minus').addClass('glyphicon-plus');
|
|
|
712 |
}
|
|
|
713 |
});
|
|
|
714 |
$(document).on('click','.prefcatselect',function(){
|
|
|
715 |
$('.prefcatselect').removeClass('active')
|
|
|
716 |
$(this).addClass('active');
|
|
|
717 |
$('.categorypreferences').addClass('hidden');
|
|
|
718 |
$('#cat-'+$(this).data('id')).toggleClass('hidden');
|
|
|
719 |
});
|
|
|
720 |
$(document).on('click','.refresh',function(){
|
|
|
721 |
document.location.reload();
|
|
|
722 |
});
|
|
|
723 |
$(document).on('click','.hasmoretext',function(){
|
|
|
724 |
$('#fulltext').html($(this).data('fulltext'));
|
|
|
725 |
$('#fullTextModal').modal();
|
|
|
726 |
});
|
|
|
727 |
$(document).on('click','.favswitch',function(){
|
|
|
728 |
$('.favswitch').removeClass('active')
|
|
|
729 |
$(this).addClass('active');
|
|
|
730 |
$('.clearfavs').addClass('hidden');
|
|
|
731 |
$('.card').addClass('hidden');
|
|
|
732 |
$('.'+$(this).data('type')).removeClass('hidden');
|
|
|
733 |
});
|
|
|
734 |
$(document).on('click','.brandpreferences .brands',function(){
|
|
|
735 |
$(this).parents('.row').siblings('.controls').find('.editcategorypreferences',0).click();
|
|
|
736 |
});
|
| 19163 |
naman |
737 |
$(document).on('click','.tryagainforliveprice',function(e){
|
|
|
738 |
e.stopPropagation();
|
| 18220 |
naman |
739 |
fetchLivePrice($(this).parent());
|
|
|
740 |
$(this).parent().html('Getting Live Prices');
|
|
|
741 |
});
|
|
|
742 |
$(document).on('click','.alert > a',function(){
|
|
|
743 |
ga('send', 'event', 'notifications', 'click', $(this).html());
|
|
|
744 |
pma.send('notifications','click',$(this).html(),me);
|
|
|
745 |
});
|
|
|
746 |
$(document).on('click','.banner',function(){
|
|
|
747 |
ga('send', 'event', 'banners', 'click', $(this).data('name'));
|
|
|
748 |
pma.send('banners','click',$(this).data('name'),me);
|
|
|
749 |
});
|
| 13992 |
anikendra |
750 |
});
|
| 15310 |
anikendra |
751 |
function setCookie(cname, cvalue, days, forceCookie) {
|
| 18220 |
naman |
752 |
if(typeof(Storage) !== "undefined" && !forceCookie) {
|
|
|
753 |
localStorage.setItem(cname, cvalue);
|
|
|
754 |
} else{
|
|
|
755 |
var d = new Date();
|
|
|
756 |
d.setTime(d.getTime() + (days*24*60*60*1000));
|
|
|
757 |
var expires = "expires="+d.toUTCString();
|
|
|
758 |
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
|
|
|
759 |
}
|
| 14849 |
anikendra |
760 |
}
|
|
|
761 |
|
| 15310 |
anikendra |
762 |
function getCookie(cname,forceCookie) {
|
| 18220 |
naman |
763 |
if(typeof(Storage) !== "undefined" && !forceCookie) {
|
|
|
764 |
return localStorage.getItem(cname);
|
|
|
765 |
} else {
|
|
|
766 |
var name = cname + "=";
|
|
|
767 |
var ca = document.cookie.split(';');
|
|
|
768 |
for(var i=0; i<ca.length; i++) {
|
|
|
769 |
var c = ca[i];
|
|
|
770 |
while (c.charAt(0)==' ') c = c.substring(1);
|
|
|
771 |
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
|
|
|
772 |
}
|
|
|
773 |
return "";
|
|
|
774 |
}
|
| 14849 |
anikendra |
775 |
}
|
| 15310 |
anikendra |
776 |
|
| 16495 |
anikendra |
777 |
function needToDisplayPaytmPopup(me){
|
| 18220 |
naman |
778 |
var id = 'tip'
|
|
|
779 |
var cname = 'paytm-help-count-'+me+'-'+id;
|
|
|
780 |
var cookieval = getCookie(cname,1);
|
|
|
781 |
if(!cookieval || cookieval == 'NaN' || cookieval==''){
|
|
|
782 |
incrementPopupCount(id,0,'paytm-help-count-');
|
|
|
783 |
return true;
|
|
|
784 |
} else if(cookieval < 5) {
|
|
|
785 |
incrementPopupCount(id,cookieval,'paytm-help-count-');
|
|
|
786 |
return true;
|
|
|
787 |
} else{
|
|
|
788 |
return false;
|
|
|
789 |
}
|
| 16495 |
anikendra |
790 |
};
|
|
|
791 |
|
| 14849 |
anikendra |
792 |
function showpopup(id,count,interval){
|
| 18220 |
naman |
793 |
var cname = 'notif-count-'+me+'-'+id;
|
|
|
794 |
var cookieval = getCookie(cname,1);
|
|
|
795 |
var cname = 'notif-lastshown-'+me+'-'+id;
|
|
|
796 |
var lastshown = getCookie(cname,1);
|
|
|
797 |
if(!cookieval || cookieval == 'NaN' || cookieval==''){
|
|
|
798 |
incrementPopupCount(id,0,'notif-count-');
|
|
|
799 |
setLastShown(id,'notif-lastshown-');
|
|
|
800 |
return true;
|
|
|
801 |
} else{
|
|
|
802 |
var d = new Date();
|
|
|
803 |
var t = d.getTime();
|
|
|
804 |
if(t-lastshown>interval*60*1000){
|
|
|
805 |
if(cookieval>=count){
|
|
|
806 |
return false;
|
|
|
807 |
}else{
|
|
|
808 |
setLastShown(id,'notif-lastshown-');
|
|
|
809 |
incrementPopupCount(id,cookieval,'notif-count-');
|
|
|
810 |
return true;
|
|
|
811 |
}
|
|
|
812 |
}
|
|
|
813 |
}
|
| 14849 |
anikendra |
814 |
}
|
| 15077 |
anikendra |
815 |
function setLastShown(id,cookiename){
|
| 18220 |
naman |
816 |
var cname = cookiename+me+'-'+id;
|
|
|
817 |
var d = new Date();
|
|
|
818 |
setCookie(cname, d.getTime(), 365, 1);
|
| 14849 |
anikendra |
819 |
}
|
| 15077 |
anikendra |
820 |
function incrementPopupCount(id,currentCount,cookiename) {
|
| 18220 |
naman |
821 |
var cname = cookiename+me+'-'+id;
|
|
|
822 |
setCookie(cname, parseInt(currentCount)+1, 365, 1);
|
| 14858 |
anikendra |
823 |
}
|
|
|
824 |
var hidden, visibilityChange;
|
|
|
825 |
function handleVisibilityChange() {
|
|
|
826 |
if (document[hidden]) {
|
| 18220 |
naman |
827 |
// pagetitle = document.title;
|
| 14858 |
anikendra |
828 |
} else {
|
| 18220 |
naman |
829 |
// document.title = pagetitle;
|
| 14858 |
anikendra |
830 |
}
|
|
|
831 |
}
|
|
|
832 |
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
|
|
|
833 |
hidden = "hidden";
|
|
|
834 |
visibilityChange = "visibilitychange";
|
|
|
835 |
} else if (typeof document.mozHidden !== "undefined") {
|
|
|
836 |
hidden = "mozHidden";
|
|
|
837 |
visibilityChange = "mozvisibilitychange";
|
|
|
838 |
} else if (typeof document.msHidden !== "undefined") {
|
|
|
839 |
hidden = "msHidden";
|
|
|
840 |
visibilityChange = "msvisibilitychange";
|
|
|
841 |
} else if (typeof document.webkitHidden !== "undefined") {
|
|
|
842 |
hidden = "webkitHidden";
|
|
|
843 |
visibilityChange = "webkitvisibilitychange";
|
|
|
844 |
}
|
|
|
845 |
if (typeof document.addEventListener === "undefined" ||
|
|
|
846 |
typeof document[hidden] === "undefined") {
|
| 18119 |
amit.gupta |
847 |
//console.log("This feature requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.");
|
| 14858 |
anikendra |
848 |
} else {
|
|
|
849 |
// Handle page visibility change
|
|
|
850 |
document.addEventListener(visibilityChange, handleVisibilityChange, false);
|
|
|
851 |
}
|
| 14936 |
anikendra |
852 |
$('.notificationok').on('click',function(e){
|
| 18220 |
naman |
853 |
e.preventDefault();
|
|
|
854 |
$('.notificationmodal').modal('hide');
|
|
|
855 |
// setTimeout(function(){ $('.notificationmodal').modal('hide'); }, 1000);
|
|
|
856 |
ga('send', 'event', 'popupnotification-'+$(this).parent().data('id'), 'ok', me);
|
|
|
857 |
var properties = {};
|
|
|
858 |
properties.id = String($(this).parent().data('id'));
|
|
|
859 |
pma.send('popupnotification','click','ok',me,properties);
|
|
|
860 |
document.location = $(this).parent().prop('href');
|
| 15015 |
anikendra |
861 |
});
|
| 18220 |
naman |
862 |
$(document).on('click','.clearfilter',function(){
|
|
|
863 |
$('.filterbrand').each(function(){
|
|
|
864 |
$(this).prop('checked',false);
|
|
|
865 |
});
|
|
|
866 |
ga('send', 'event', 'filter', 'brand', 'reset');
|
|
|
867 |
pma.send('filters','brands','reset',me);
|
| 15015 |
anikendra |
868 |
});
|
| 17691 |
naman |
869 |
|
| 18220 |
naman |
870 |
$(document).on('click','.clearfiltersubcategory',function(){
|
|
|
871 |
$('.filtersubcategory').each(function(){
|
|
|
872 |
$(this).prop('checked',false);
|
|
|
873 |
});
|
|
|
874 |
ga('send', 'event', 'filter', 'subcategory', 'reset');
|
|
|
875 |
pma.send('filters','subcategory','reset',me);
|
| 17691 |
naman |
876 |
});
|
| 18391 |
naman |
877 |
|
|
|
878 |
function getJsonFromUrl() {
|
| 18759 |
naman |
879 |
var query = location.search.substr(1);
|
|
|
880 |
var result = {};
|
|
|
881 |
query.split("&").forEach(function(part) {
|
|
|
882 |
var item = part.split("=");
|
|
|
883 |
result[item[0]] = decodeURIComponent(item[1]);
|
|
|
884 |
});
|
|
|
885 |
return result;
|
|
|
886 |
}
|
| 18391 |
naman |
887 |
|
|
|
888 |
$(document).on('click','.applyfilter',function(){
|
| 18759 |
naman |
889 |
var str = window.location.search;
|
| 18391 |
naman |
890 |
var urlplus = '';
|
|
|
891 |
var urldet = getJsonFromUrl();
|
|
|
892 |
|
| 19608 |
naman |
893 |
var whatfirst = "";
|
|
|
894 |
if(urldet['whatfirst'] !=undefined){
|
|
|
895 |
whatfirst = urldet['whatfirst'];
|
|
|
896 |
}
|
|
|
897 |
|
| 18220 |
naman |
898 |
$(this).prop('disabled',true);
|
|
|
899 |
$('#loadingModal').modal();
|
|
|
900 |
var brands = [];
|
|
|
901 |
var brandnames = [];
|
|
|
902 |
var subcategories = [];
|
|
|
903 |
var subcatnames = [];
|
| 19608 |
naman |
904 |
|
|
|
905 |
if($("#brandselecter").length == 0 && urldet['brands'] != undefined && urldet['brands'] != ''){
|
|
|
906 |
brands = urldet['brands'].split("^");
|
|
|
907 |
}
|
|
|
908 |
if($("#subcategoryselecter").length == 0 && urldet['subcategories'] != undefined && urldet['subcategories'] != ''){
|
|
|
909 |
subcategories = urldet['subcategories'].split("^");;
|
|
|
910 |
}
|
|
|
911 |
|
| 18220 |
naman |
912 |
$('.filterbrand').each(function(){
|
|
|
913 |
if($(this).prop('checked')){
|
|
|
914 |
brands.push($(this).val());
|
|
|
915 |
brandnames.push($(this).parent().siblings('.brandname').html());
|
|
|
916 |
}
|
|
|
917 |
});
|
|
|
918 |
|
|
|
919 |
$('.filtersubcategory').each(function(){
|
|
|
920 |
if($(this).prop('checked')){
|
|
|
921 |
subcategories.push($(this).val());
|
|
|
922 |
subcatnames.push($(this).parent().siblings('.subcategoryname').html());
|
|
|
923 |
}
|
|
|
924 |
});
|
| 18391 |
naman |
925 |
|
|
|
926 |
|
| 19608 |
naman |
927 |
if($('#brandselecter').prop('action') !== undefined )
|
|
|
928 |
{
|
|
|
929 |
url = $('#brandselecter').prop('action');
|
|
|
930 |
}
|
|
|
931 |
if($('#subcategoryselecter').prop('action') !== undefined )
|
|
|
932 |
{
|
|
|
933 |
url = $('#subcategoryselecter').prop('action');
|
|
|
934 |
}
|
| 17691 |
naman |
935 |
|
| 18391 |
naman |
936 |
if(brands.length==0 && subcategories.length==0){
|
| 18759 |
naman |
937 |
$('#loadingModal').modal('hide');
|
|
|
938 |
var url = '';
|
|
|
939 |
document.location = url;
|
| 18391 |
naman |
940 |
|
|
|
941 |
}else if(brands.length==0 && subcategories.length>0 ){
|
|
|
942 |
ga('send', 'event', 'filter', 'subcategory', subcatnames.join('|'));
|
|
|
943 |
properties = {};
|
|
|
944 |
for(var i in subcatnames){
|
|
|
945 |
properties['subcategories_'+i] = subcatnames[i];
|
|
|
946 |
}
|
|
|
947 |
pma.send('filters','subcategories','addfilter',me,properties);
|
|
|
948 |
var postdata = {'user_id':me,'type':'subcategory','filters':subcatnames.join('|')};
|
|
|
949 |
$.post( "/user_filters/add", postdata, function( data ) {
|
|
|
950 |
$('#loadingModal').modal('hide');
|
|
|
951 |
$(this).prop('disabled',false);
|
| 19608 |
naman |
952 |
document.location = url.split("?")[0]+'?filter=subcategory&subcategories='+subcategories.join('^')+"&whatfirst=subCategory";
|
| 18391 |
naman |
953 |
});
|
|
|
954 |
}else if(brands.length>0 && subcategories.length==0 ){
|
|
|
955 |
ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
|
|
|
956 |
properties = {};
|
|
|
957 |
for(var i in brandnames){
|
|
|
958 |
properties['brand_'+i] = brandnames[i];
|
|
|
959 |
}
|
|
|
960 |
pma.send('filters','brands','addfilter',me,properties);
|
|
|
961 |
var postdata = {'user_id':me,'type':'brand','filters':brandnames.join('|')};
|
|
|
962 |
$.post( "/user_filters/add", postdata, function( data ) {
|
|
|
963 |
$('#loadingModal').modal('hide');
|
|
|
964 |
$(this).prop('disabled',false);
|
| 19608 |
naman |
965 |
document.location = url.split("?")[0]+'?filter=brand&brands='+brands.join('^')+"&whatfirst=brand";
|
| 18391 |
naman |
966 |
});
|
|
|
967 |
}else if(brands.length>0 && subcategories.length>0 ){
|
|
|
968 |
setCookie('brandschosen', brands, 0.25, true);
|
|
|
969 |
setCookie('subcategorieschosen', subcategories, 0.25, true);
|
|
|
970 |
ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
|
|
|
971 |
ga('send', 'event', 'filter', 'subcategory', subcatnames.join('|'));
|
|
|
972 |
properties = {};
|
|
|
973 |
for(var i in brandnames){
|
|
|
974 |
properties['brand_'+i] = brandnames[i];
|
|
|
975 |
}
|
|
|
976 |
for(var i in subcatnames){
|
|
|
977 |
properties['subcategory_'+i] = subcatnames[i];
|
|
|
978 |
}
|
|
|
979 |
pma.send('filters','brandsnsubcategories','addfilter',me,properties);
|
|
|
980 |
var dataStr = brandnames.join('|');
|
|
|
981 |
dataStr = dataStr + subcatnames.join('|');
|
|
|
982 |
var postdata = {'user_id':me,'type':'brandnsubcategory','filters':dataStr};
|
|
|
983 |
$.post( "/user_filters/add", postdata, function( data ) {
|
|
|
984 |
$('#loadingModal').modal('hide');
|
|
|
985 |
$(this).prop('disabled',false);
|
|
|
986 |
if($("#brandselecter").length == 0 && urldet['brands'] != undefined && urldet['brands'] != ''){
|
| 18759 |
naman |
987 |
url = $("#subcategoryselecter").prop('action');
|
| 19608 |
naman |
988 |
document.location = url.split('?')[0]+'?brands='+brands.join('^')+"&subcategories="+subcategories.join("^")+"&whatfirst="+whatfirst;
|
| 18391 |
naman |
989 |
}
|
|
|
990 |
else if($("#subcategoryselecter").length == 0 && urldet['subcategories'] != undefined && urldet['subcategories'] != ''){
|
| 18759 |
naman |
991 |
url = $('#brandselecter').prop('action');
|
| 19608 |
naman |
992 |
document.location = url.split('?')[0]+'?brands='+brands.join('^')+"&subcategories="+subcategories.join('^')+"&whatfirst="+whatfirst;
|
| 18391 |
naman |
993 |
}
|
|
|
994 |
});
|
| 18220 |
naman |
995 |
}
|
| 17691 |
naman |
996 |
|
| 20504 |
amit.gupta |
997 |
|
| 15015 |
anikendra |
998 |
});
|
| 18066 |
naman |
999 |
|
|
|
1000 |
|
| 18220 |
naman |
1001 |
$(document).on('click','#showallbrands',function(){
|
|
|
1002 |
$('.brand').removeClass('hidden');
|
| 18066 |
naman |
1003 |
$('.subcategory').removeClass('hidden');
|
| 18220 |
naman |
1004 |
$(this).hide();
|
| 15019 |
anikendra |
1005 |
});
|
| 18220 |
naman |
1006 |
$(document).on('input','#brandfilter',function(){
|
|
|
1007 |
$('.brand').addClass('hidden');
|
|
|
1008 |
$('#showallbrands').hide();
|
|
|
1009 |
var that = $(this);
|
|
|
1010 |
$('li.brand').filter(function() {
|
|
|
1011 |
return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
|
|
|
1012 |
}).removeClass('hidden','slow');
|
| 15042 |
anikendra |
1013 |
});
|
| 17707 |
naman |
1014 |
|
| 18220 |
naman |
1015 |
$(document).on('input','#subcatfilter',function(){
|
|
|
1016 |
$('.subcategory').addClass('hidden');
|
|
|
1017 |
$('#showallbrands').hide();
|
|
|
1018 |
var that = $(this);
|
|
|
1019 |
$('li.subcategory').filter(function() {
|
|
|
1020 |
return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
|
|
|
1021 |
}).removeClass('hidden','slow');
|
| 17707 |
naman |
1022 |
});
|
|
|
1023 |
|
|
|
1024 |
|
| 15077 |
anikendra |
1025 |
$(document).on('click','.filterbrand',function(){
|
| 18220 |
naman |
1026 |
var clicked = $(this).parent().parent();
|
|
|
1027 |
// all the LIs above the clicked one
|
|
|
1028 |
var previousAll = clicked.prevAll();
|
| 15042 |
anikendra |
1029 |
|
| 18220 |
naman |
1030 |
// only proceed if it's not already on top (no previous siblings)
|
|
|
1031 |
if(previousAll.length > 0) {
|
|
|
1032 |
// top LI
|
|
|
1033 |
var top = $(previousAll[previousAll.length - 1]);
|
| 15042 |
anikendra |
1034 |
|
| 18220 |
naman |
1035 |
// immediately previous LI
|
|
|
1036 |
var previous = $(previousAll[0]);
|
| 15042 |
anikendra |
1037 |
|
| 18220 |
naman |
1038 |
// how far up do we need to move the clicked LI?
|
|
|
1039 |
var moveUp = clicked.attr('offsetTop') - top.attr('offsetTop');
|
| 15042 |
anikendra |
1040 |
|
| 18220 |
naman |
1041 |
// how far down do we need to move the previous siblings?
|
|
|
1042 |
var moveDown = (clicked.offset().top + clicked.outerHeight()) - (previous.offset().top + previous.outerHeight());
|
| 15042 |
anikendra |
1043 |
|
| 18220 |
naman |
1044 |
// let's move stuff
|
|
|
1045 |
clicked.css('position', 'relative');
|
|
|
1046 |
previousAll.css('position', 'relative');
|
|
|
1047 |
clicked.animate({'top': -moveUp});
|
|
|
1048 |
previousAll.animate({'top': moveDown}, {complete: function() {
|
|
|
1049 |
// rearrange the DOM and restore positioning when we're done moving
|
|
|
1050 |
clicked.parent().prepend(clicked);
|
|
|
1051 |
clicked.css({'position': 'static', 'top': 0});
|
|
|
1052 |
previousAll.css({'position': 'static', 'top': 0});
|
|
|
1053 |
}});
|
|
|
1054 |
}
|
| 15042 |
anikendra |
1055 |
})
|
| 17691 |
naman |
1056 |
$(document).on('click','.filtersubcategory',function(){
|
| 18220 |
naman |
1057 |
var clicked = $(this).parent().parent();
|
|
|
1058 |
// all the LIs above the clicked one
|
|
|
1059 |
var previousAll = clicked.prevAll();
|
| 17691 |
naman |
1060 |
|
| 18220 |
naman |
1061 |
// only proceed if it's not already on top (no previous siblings)
|
|
|
1062 |
if(previousAll.length > 0) {
|
|
|
1063 |
// top LI
|
|
|
1064 |
var top = $(previousAll[previousAll.length - 1]);
|
| 17691 |
naman |
1065 |
|
| 18220 |
naman |
1066 |
// immediately previous LI
|
|
|
1067 |
var previous = $(previousAll[0]);
|
| 17691 |
naman |
1068 |
|
| 18220 |
naman |
1069 |
// how far up do we need to move the clicked LI?
|
|
|
1070 |
var moveUp = clicked.attr('offsetTop') - top.attr('offsetTop');
|
| 17691 |
naman |
1071 |
|
| 18220 |
naman |
1072 |
// how far down do we need to move the previous siblings?
|
|
|
1073 |
var moveDown = (clicked.offset().top + clicked.outerHeight()) - (previous.offset().top + previous.outerHeight());
|
| 17691 |
naman |
1074 |
|
| 18220 |
naman |
1075 |
// let's move stuff
|
|
|
1076 |
clicked.css('position', 'relative');
|
|
|
1077 |
previousAll.css('position', 'relative');
|
|
|
1078 |
clicked.animate({'top': -moveUp});
|
|
|
1079 |
previousAll.animate({'top': moveDown}, {complete: function() {
|
|
|
1080 |
// rearrange the DOM and restore positioning when we're done moving
|
|
|
1081 |
clicked.parent().prepend(clicked);
|
|
|
1082 |
clicked.css({'position': 'static', 'top': 0});
|
|
|
1083 |
previousAll.css({'position': 'static', 'top': 0});
|
|
|
1084 |
}});
|
|
|
1085 |
}
|
| 17691 |
naman |
1086 |
})
|
| 15042 |
anikendra |
1087 |
$(document).on('click','.clearfilters',function(){
|
| 18391 |
naman |
1088 |
// setCookie('brandschosen', '', -1, true);
|
|
|
1089 |
// setCookie('subcategorieschosen','',-1, true);
|
| 18220 |
naman |
1090 |
ga('send', 'event', 'filter', 'brand', 'clearfilters');
|
|
|
1091 |
ga('send', 'event', 'filter', 'subcategory', 'clearfilters');
|
|
|
1092 |
pma.send('filters','brands','clearfilters',me);
|
|
|
1093 |
pma.send('filters','subcategory','clearfilters',me);
|
|
|
1094 |
var postdata = {'user_id':me,'type':'clear'};
|
|
|
1095 |
$('#loadingModal').modal('show');
|
|
|
1096 |
$.post("/user_filters/add", postdata, function( data ) {
|
|
|
1097 |
// document.location.reload();
|
|
|
1098 |
window.location.replace(window.location.href.split('?')[0]);
|
|
|
1099 |
});
|
| 15042 |
anikendra |
1100 |
});
|
|
|
1101 |
function selectChosenBrands(){
|
| 18391 |
naman |
1102 |
|
|
|
1103 |
var urldet = getJsonFromUrl();
|
|
|
1104 |
|
|
|
1105 |
if (urldet['brands'] !=undefined && urldet['brands'] !="") {
|
| 18759 |
naman |
1106 |
var brands = urldet['brands'].split('^');
|
|
|
1107 |
for(var i in brands){
|
|
|
1108 |
$('[data-brandid="'+brands[i]+'"]').removeClass('hidden').find('.filterbrand',0).trigger( "click" );
|
|
|
1109 |
}
|
|
|
1110 |
}
|
| 18391 |
naman |
1111 |
|
|
|
1112 |
if (urldet['subcategories'] != undefined && urldet['subcategories'] != "") {
|
| 18759 |
naman |
1113 |
var subcategories = urldet['subcategories'].split('^');
|
|
|
1114 |
for(var i in subcategories){
|
|
|
1115 |
$('.subcategory').filter(function() {
|
|
|
1116 |
return $(this).data("brandid") == subcategories[i];
|
|
|
1117 |
}).removeClass('hidden').find('.filtersubcategory',0).trigger( "click" );
|
|
|
1118 |
}
|
|
|
1119 |
}
|
| 18391 |
naman |
1120 |
|
| 15065 |
anikendra |
1121 |
}
|
| 18190 |
amit.gupta |
1122 |
|
|
|
1123 |
function clearFilters(){
|
| 18759 |
naman |
1124 |
setCookie('brandschosen', '', -1, true);
|
|
|
1125 |
setCookie('subcategorieschosen','',-1, true);
|
| 18190 |
amit.gupta |
1126 |
}
|
| 15585 |
anikendra |
1127 |
function showPosition(position) {
|
| 15586 |
anikendra |
1128 |
setCookie('latitude',position.coords.latitude,1,true);
|
| 18220 |
naman |
1129 |
setCookie('longitude',position.coords.longitude,1,true);
|
| 15585 |
anikendra |
1130 |
}
|
| 15065 |
anikendra |
1131 |
$(function () {
|
| 19382 |
amit.gupta |
1132 |
$('div.see_more_link:first').append('<a id="popovertrigger7" data-container="body" data-toggle="popover" data-placement="right" data-content="View more"> </a>');
|
| 18759 |
naman |
1133 |
$("#popovertrigger5").popover('hide').remove();
|
|
|
1134 |
$('.data-up:first').append('<a id="popovertrigger5" data-container="body" data-toggle="popover" data-placement="left" data-content="Quick buy multiple items together"></a>');
|
| 19382 |
amit.gupta |
1135 |
trigger5Onfade = function(){setPopOver("popovertrigger7", "div.see_more_link:first a", 'click', 4000);}
|
|
|
1136 |
setPopOver("popovertrigger5", ".plusqtybutton", 'click', 3000, trigger5Onfade);
|
|
|
1137 |
setPopOver("popovertrigger", ".dropdown", 'click', 3000);
|
| 18759 |
naman |
1138 |
callBackFunction = function(){
|
|
|
1139 |
return document.location.pathname=="/category/6";
|
|
|
1140 |
};
|
|
|
1141 |
setPopOver("popovertrigger4", callBackFunction,undefined,3000);
|
|
|
1142 |
//$('[data-toggle="popover"]#'+id).popover('show');
|
|
|
1143 |
if (navigator.geolocation) {
|
| 18023 |
amit.gupta |
1144 |
navigator.geolocation.getCurrentPosition(showPosition);
|
|
|
1145 |
}
|
|
|
1146 |
});
|
|
|
1147 |
|
| 19382 |
amit.gupta |
1148 |
function setPopOver(poid, callBack1, eventString, fadeAfter, onFade){
|
| 18759 |
naman |
1149 |
var cname = 'popover-count-'+me+'-'+poid;
|
|
|
1150 |
var cookieval = getCookie(cname,1);
|
|
|
1151 |
if(typeof callBack1=="function"){
|
|
|
1152 |
if (callBack1()){
|
|
|
1153 |
var cname = 'popover-count-'+me+'-'+poid;
|
|
|
1154 |
var cookieval = getCookie(cname,1);
|
|
|
1155 |
$('#' + poid).popover('hide');
|
|
|
1156 |
if(!cookieval || cookieval == 'NaN' || cookieval == ''){
|
|
|
1157 |
incrementPopupCount(poid,0,'popover-count-');
|
|
|
1158 |
} else if(cookieval > 0) {
|
|
|
1159 |
incrementPopupCount(poid, cookieval, 'popover-count-');
|
|
|
1160 |
}
|
|
|
1161 |
setLastShown(poid,'popover-lastshown-');
|
|
|
1162 |
}
|
|
|
1163 |
} else {
|
| 19023 |
amit.gupta |
1164 |
$('div.container').on(eventString, callBack1, function(){
|
| 18759 |
naman |
1165 |
var cname = 'popover-count-'+me+'-'+poid;
|
|
|
1166 |
var cookieval = getCookie(cname,1);
|
|
|
1167 |
$('#' + poid).popover('hide');
|
|
|
1168 |
if(!cookieval || cookieval == 'NaN' || cookieval == ''){
|
|
|
1169 |
incrementPopupCount(poid,0,'popover-count-');
|
|
|
1170 |
} else if(cookieval > 0) {
|
|
|
1171 |
incrementPopupCount(poid, cookieval, 'popover-count-');
|
|
|
1172 |
}
|
|
|
1173 |
setLastShown(poid,'popover-lastshown-');
|
|
|
1174 |
});
|
|
|
1175 |
}
|
|
|
1176 |
|
|
|
1177 |
if(typeof fadeAfter!="undefined"){
|
|
|
1178 |
var s = setInterval(function(){
|
|
|
1179 |
if($('#' + poid +':in-viewport').length>0) {
|
|
|
1180 |
setTimeout(function(){
|
|
|
1181 |
$('#' + poid).popover('hide');
|
| 19382 |
amit.gupta |
1182 |
if (typeof onFade== "function"){
|
|
|
1183 |
onFade();
|
|
|
1184 |
}
|
| 18759 |
naman |
1185 |
}, fadeAfter);
|
|
|
1186 |
clearInterval(s);
|
|
|
1187 |
}
|
| 19382 |
amit.gupta |
1188 |
}, 500);
|
| 18759 |
naman |
1189 |
}
|
|
|
1190 |
|
|
|
1191 |
var cname = 'popover-lastshown-'+me+'-'+poid;
|
|
|
1192 |
var lastshown = getCookie(cname,1);
|
|
|
1193 |
if(cookieval=='' || cookieval == 'NaN' || !cookieval){
|
|
|
1194 |
showpopover(poid);
|
|
|
1195 |
}
|
|
|
1196 |
//Donot show popover anymore as long as we don't find a suitable solution
|
|
|
1197 |
else{
|
|
|
1198 |
var d = new Date();
|
|
|
1199 |
var t = d.getTime();
|
|
|
1200 |
if(t-lastshown>18*3600*1000){
|
|
|
1201 |
if(cookieval>=2){
|
|
|
1202 |
return false;
|
|
|
1203 |
}else{
|
|
|
1204 |
showpopover(poid);
|
|
|
1205 |
}
|
|
|
1206 |
}
|
|
|
1207 |
}
|
|
|
1208 |
ga('send', 'event', 'popover', me, cookieval);
|
| 18023 |
amit.gupta |
1209 |
}
|
| 16656 |
anikendra |
1210 |
$('.getapp').on('click',function(){
|
| 18220 |
naman |
1211 |
/*var that = $(this);
|
|
|
1212 |
var req = $.ajax({
|
|
|
1213 |
url: 'http://104.200.25.40:8057/appAffiliates/generateRedirectUrl/'+me+'/'+$(that).data('id'),
|
|
|
1214 |
// Tell jQuery we're expecting JSONP
|
|
|
1215 |
dataType: "jsonp",
|
|
|
1216 |
// Tell YQL what we want and that we want JSON
|
|
|
1217 |
method: 'get',
|
|
|
1218 |
// timeout: 30000,
|
|
|
1219 |
// Work with the response
|
|
|
1220 |
success: function( response ) {
|
|
|
1221 |
console.log(response);
|
|
|
1222 |
}
|
|
|
1223 |
});*/
|
|
|
1224 |
$('#loadingModal').modal('show');
|
|
|
1225 |
document.location = '/abouts/apphint';
|
| 16656 |
anikendra |
1226 |
});
|
| 15077 |
anikendra |
1227 |
function showpopover(id){
|
| 18220 |
naman |
1228 |
try {
|
|
|
1229 |
$('[data-toggle="popover"]#'+id).popover({html:true,viewport:{container:'body'}, trigger:'manual'});
|
|
|
1230 |
$('[data-toggle="popover"]#'+id).popover('show');
|
|
|
1231 |
}catch(err){
|
|
|
1232 |
//
|
|
|
1233 |
}
|
| 15085 |
anikendra |
1234 |
}
|
|
|
1235 |
$(document).on('click','.nodeals',function(){
|
| 18220 |
naman |
1236 |
document.location = $(this).data('href');
|
| 16018 |
anikendra |
1237 |
});
|
|
|
1238 |
$(document).on('click','.selectbrand',function(e){
|
| 18220 |
naman |
1239 |
e.preventDefault();
|
|
|
1240 |
var brands = $(this).data('id');
|
|
|
1241 |
var brandname = $(this).html();
|
| 19833 |
naman |
1242 |
var catid = $(this).data('catid');
|
|
|
1243 |
|
|
|
1244 |
var urldet = getJsonFromUrl();
|
|
|
1245 |
var brandarr = [];
|
|
|
1246 |
var url = "/category/"+catid;
|
| 17703 |
naman |
1247 |
|
| 19833 |
naman |
1248 |
if(urldet['brands'] != undefined){
|
|
|
1249 |
brandarr = urldet['brands'].split("^");
|
|
|
1250 |
}
|
|
|
1251 |
|
|
|
1252 |
brandarr.push(brands);
|
|
|
1253 |
url = url + "?brands="+brandarr.join('^');
|
|
|
1254 |
|
| 18220 |
naman |
1255 |
ga('send', 'event', 'selectbrand', 'brand', brandname);
|
|
|
1256 |
properties = {};
|
|
|
1257 |
properties['brand'] = brandname;
|
|
|
1258 |
pma.send('filters','brands','selectbrand',me,properties);
|
|
|
1259 |
var postdata = {'user_id':me,'type':'brand','filters':brandname};
|
|
|
1260 |
$.post( "/user_filters/add", postdata, function( data ) {
|
|
|
1261 |
$('#loadingModal').modal('hide');
|
|
|
1262 |
$(this).addClass('activebrand');
|
| 18391 |
naman |
1263 |
// document.location = url+'&brands='+brands;
|
|
|
1264 |
document.location = url;
|
| 18220 |
naman |
1265 |
});
|
| 16018 |
anikendra |
1266 |
});
|
| 17703 |
naman |
1267 |
|
|
|
1268 |
|
| 18391 |
naman |
1269 |
|
| 16495 |
anikendra |
1270 |
$(document).on('click','.shownexttip',function(e){
|
| 18220 |
naman |
1271 |
$(this).addClass('hidden').remove();
|
|
|
1272 |
$('#firsttip').addClass('hidden').remove();
|
|
|
1273 |
$('#secondtip').removeClass('hidden');
|
|
|
1274 |
$('.gotit').removeClass('hidden');
|
| 16495 |
anikendra |
1275 |
});
|
| 15128 |
anikendra |
1276 |
var Base64 = {
|
|
|
1277 |
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
|
1278 |
encode: function(input) {
|
|
|
1279 |
var output = "";
|
|
|
1280 |
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
|
|
1281 |
var i = 0;
|
|
|
1282 |
input = Base64._utf8_encode(input);
|
|
|
1283 |
while (i < input.length) {
|
|
|
1284 |
chr1 = input.charCodeAt(i++);
|
|
|
1285 |
chr2 = input.charCodeAt(i++);
|
|
|
1286 |
chr3 = input.charCodeAt(i++);
|
|
|
1287 |
|
|
|
1288 |
enc1 = chr1 >> 2;
|
|
|
1289 |
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
|
1290 |
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
|
1291 |
enc4 = chr3 & 63;
|
|
|
1292 |
if (isNaN(chr2)) {
|
|
|
1293 |
enc3 = enc4 = 64;
|
|
|
1294 |
} else if (isNaN(chr3)) {
|
|
|
1295 |
enc4 = 64;
|
|
|
1296 |
}
|
|
|
1297 |
output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
|
|
1298 |
}
|
|
|
1299 |
return output;
|
|
|
1300 |
},
|
|
|
1301 |
|
|
|
1302 |
|
|
|
1303 |
decode: function(input) {
|
|
|
1304 |
var output = "";
|
|
|
1305 |
var chr1, chr2, chr3;
|
|
|
1306 |
var enc1, enc2, enc3, enc4;
|
|
|
1307 |
var i = 0;
|
|
|
1308 |
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
|
|
1309 |
while (i < input.length) {
|
|
|
1310 |
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
|
|
1311 |
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
|
|
1312 |
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
|
|
1313 |
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
|
|
1314 |
chr1 = (enc1 << 2) | (enc2 >> 4);
|
|
|
1315 |
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
|
1316 |
chr3 = ((enc3 & 3) << 6) | enc4;
|
|
|
1317 |
output = output + String.fromCharCode(chr1);
|
|
|
1318 |
if (enc3 != 64) {
|
|
|
1319 |
output = output + String.fromCharCode(chr2);
|
|
|
1320 |
}
|
|
|
1321 |
if (enc4 != 64) {
|
|
|
1322 |
output = output + String.fromCharCode(chr3);
|
|
|
1323 |
}
|
|
|
1324 |
}
|
|
|
1325 |
output = Base64._utf8_decode(output);
|
|
|
1326 |
return output;
|
|
|
1327 |
},
|
|
|
1328 |
|
|
|
1329 |
_utf8_encode: function(string) {
|
|
|
1330 |
string = string.replace(/\r\n/g, "\n");
|
|
|
1331 |
var utftext = "";
|
|
|
1332 |
for (var n = 0; n < string.length; n++) {
|
|
|
1333 |
var c = string.charCodeAt(n);
|
|
|
1334 |
if (c < 128) {
|
|
|
1335 |
utftext += String.fromCharCode(c);
|
|
|
1336 |
}
|
|
|
1337 |
else if ((c > 127) && (c < 2048)) {
|
|
|
1338 |
utftext += String.fromCharCode((c >> 6) | 192);
|
|
|
1339 |
utftext += String.fromCharCode((c & 63) | 128);
|
|
|
1340 |
}
|
|
|
1341 |
else {
|
|
|
1342 |
utftext += String.fromCharCode((c >> 12) | 224);
|
|
|
1343 |
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
|
1344 |
utftext += String.fromCharCode((c & 63) | 128);
|
|
|
1345 |
}
|
|
|
1346 |
}
|
|
|
1347 |
return utftext;
|
|
|
1348 |
},
|
|
|
1349 |
|
|
|
1350 |
_utf8_decode: function(utftext) {
|
|
|
1351 |
var string = "";
|
|
|
1352 |
var i = 0;
|
|
|
1353 |
var c = c1 = c2 = 0;
|
|
|
1354 |
while (i < utftext.length) {
|
|
|
1355 |
c = utftext.charCodeAt(i);
|
|
|
1356 |
if (c < 128) {
|
|
|
1357 |
string += String.fromCharCode(c);
|
|
|
1358 |
i++;
|
|
|
1359 |
}
|
|
|
1360 |
else if ((c > 191) && (c < 224)) {
|
|
|
1361 |
c2 = utftext.charCodeAt(i + 1);
|
|
|
1362 |
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
|
|
1363 |
i += 2;
|
|
|
1364 |
}
|
|
|
1365 |
else {
|
|
|
1366 |
c2 = utftext.charCodeAt(i + 1);
|
|
|
1367 |
c3 = utftext.charCodeAt(i + 2);
|
|
|
1368 |
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
|
|
1369 |
i += 3;
|
|
|
1370 |
}
|
|
|
1371 |
}
|
|
|
1372 |
return string;
|
|
|
1373 |
}
|
| 15550 |
anikendra |
1374 |
}
|
|
|
1375 |
|
|
|
1376 |
|
|
|
1377 |
var pma = new function() {
|
| 15584 |
anikendra |
1378 |
this.apiurl = "http://45.33.50.227:8081/";
|
| 15550 |
anikendra |
1379 |
this.endpoints = {'identify':'identify','profile':'profile','track':'track'};
|
|
|
1380 |
|
|
|
1381 |
this.send = function (category,action,label,user_id,properties) {
|
| 18220 |
naman |
1382 |
if(!properties){
|
|
|
1383 |
properties = {};
|
|
|
1384 |
}
|
|
|
1385 |
properties.location = window.location.href;
|
|
|
1386 |
// properties.appCodeName = navigator.appCodeName;
|
|
|
1387 |
// properties.appName = navigator.appName;
|
|
|
1388 |
// properties.appVersion = navigator.appVersion;
|
|
|
1389 |
properties.cookieEnabled = String(navigator.cookieEnabled);
|
|
|
1390 |
properties.platform = navigator.platform;
|
|
|
1391 |
properties.userAgent = navigator.userAgent;
|
|
|
1392 |
properties.ip = ip;
|
|
|
1393 |
if (navigator.geolocation) {
|
|
|
1394 |
if(getCookie('latitude',true)){
|
|
|
1395 |
properties.latitude = getCookie('latitude');
|
|
|
1396 |
}
|
|
|
1397 |
if(getCookie('longitude',true)){
|
|
|
1398 |
properties.longitude = getCookie('longitude');
|
|
|
1399 |
}
|
|
|
1400 |
}
|
|
|
1401 |
properties.screenHeight = String(screen.height);
|
|
|
1402 |
properties.screenWidth = String(screen.width);
|
|
|
1403 |
// console.log(properties);
|
|
|
1404 |
$.ajax({
|
|
|
1405 |
url: this.apiurl + this.endpoints.track,
|
|
|
1406 |
data: {'category':category,'action':action,'label':label,'user_id':user_id,'properties':cassandraMAP.stringify(properties)},
|
|
|
1407 |
// Tell jQuery we're expecting JSONP
|
|
|
1408 |
dataType: "json",
|
|
|
1409 |
// Tell YQL what we want and that we want JSON
|
|
|
1410 |
method: 'post',
|
|
|
1411 |
// Work with the response
|
|
|
1412 |
success: function( response ) {
|
|
|
1413 |
//Well, well, well :)
|
|
|
1414 |
}
|
|
|
1415 |
});
|
| 15550 |
anikendra |
1416 |
};
|
|
|
1417 |
|
|
|
1418 |
this.formDataToObject = function(formdata){
|
| 18220 |
naman |
1419 |
var properties = {};
|
|
|
1420 |
var keys = [];
|
|
|
1421 |
var formdata = JSON.parse(JSON.stringify(formdata));
|
|
|
1422 |
for (var i in formdata) {
|
|
|
1423 |
var key = formdata[i].name;
|
|
|
1424 |
if(index = keys.indexOf(key)==-1){
|
|
|
1425 |
properties[key] = formdata[i].value;
|
|
|
1426 |
}else{
|
|
|
1427 |
properties[key+'_'+i] = formdata[i].value;
|
|
|
1428 |
}
|
|
|
1429 |
keys.push(key);
|
|
|
1430 |
};
|
|
|
1431 |
return properties;
|
|
|
1432 |
}
|
| 16704 |
anikendra |
1433 |
}
|
|
|
1434 |
//App page
|
|
|
1435 |
$.fn.stars = function() {
|
|
|
1436 |
return $(this).each(function() {
|
|
|
1437 |
// Get the value
|
|
|
1438 |
var val = parseFloat($(this).html());
|
|
|
1439 |
// Make sure that the value is in 0 - 5 range, multiply to get width
|
|
|
1440 |
val = Math.round(val * 2) / 2;
|
|
|
1441 |
var size = Math.max(0, (Math.min(5, val))) * 16;
|
|
|
1442 |
// Create stars holder
|
|
|
1443 |
var $span = $('<span />').width(size);
|
|
|
1444 |
// Replace the numerical value with stars
|
|
|
1445 |
$(this).html($span);
|
|
|
1446 |
});
|
|
|
1447 |
}
|
|
|
1448 |
$(function() {
|
| 18220 |
naman |
1449 |
$('span.stars').stars();
|
| 18023 |
amit.gupta |
1450 |
});
|
|
|
1451 |
|
|
|
1452 |
function sendCartChangeEvent(){
|
| 18220 |
naman |
1453 |
var cart_details_old = localStorage.getItem('cart_details_old');
|
|
|
1454 |
var cart_details = localStorage.getItem('cart_details');
|
|
|
1455 |
if (cart_details_old == cart_details){
|
|
|
1456 |
return;
|
|
|
1457 |
} else if(cart_details!=null){
|
|
|
1458 |
JSON.parse(cart_details);
|
|
|
1459 |
|
|
|
1460 |
}
|
| 18023 |
amit.gupta |
1461 |
}
|
|
|
1462 |
|
| 19619 |
naman |
1463 |
$(document).on('click','.quickclick',function(){
|
|
|
1464 |
$('#loadingModal').modal('show');
|
|
|
1465 |
});
|
| 18023 |
amit.gupta |
1466 |
//setInterval(30000, )
|