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