| Line 1... |
Line 1... |
| 1 |
var livePriceCalls = [];
|
1 |
var livePriceCalls = [];
|
| 2 |
var outOfStockCount = 0;
|
2 |
var outOfStockCount = 0;
|
| 3 |
function getcashbackstring(type,value) {
|
3 |
function getcashbackstring(type,value) {
|
| - |
|
4 |
// console.log(type+' '+value);
|
| 4 |
if(value==0){
|
5 |
if(value==0){
|
| 5 |
return '';
|
6 |
return '';
|
| 6 |
}
|
7 |
}
|
| 7 |
if(type==2){
|
8 |
if(type==2){
|
| 8 |
return ' +'+value+' Cashback';
|
9 |
return ' +'+value+' Cashback';
|
| Line 53... |
Line 54... |
| 53 |
// Tell YQL what we want and that we want JSON
|
54 |
// Tell YQL what we want and that we want JSON
|
| 54 |
method: 'get',
|
55 |
method: 'get',
|
| 55 |
// timeout: 30000,
|
56 |
// timeout: 30000,
|
| 56 |
// Work with the response
|
57 |
// Work with the response
|
| 57 |
success: function( response ) {
|
58 |
success: function( response ) {
|
| - |
|
59 |
// console.log(response);
|
| 58 |
if(response.success){
|
60 |
if(response.success){
|
| 59 |
var i = 0;
|
61 |
var i = 0;
|
| 60 |
var minpriceindex = 0;
|
62 |
var minpriceindex = 0;
|
| 61 |
if(response.products[i].in_stock == 1) {inStock = true;}
|
63 |
if(response.products[i].in_stock == 1) {inStock = true;}
|
| 62 |
if(response.products[i].in_stock == 1) {
|
64 |
if(response.products[i].in_stock == 1) {
|
| 63 |
var minprice = Math.round(response.products[i]['available_price']);
|
65 |
var minprice = Math.round(response.products[i]['available_price']);
|
| 64 |
var minpriceurl = response.products[i]['marketPlaceUrl'];
|
66 |
var minpriceurl = response.products[i]['marketPlaceUrl'];
|
| - |
|
67 |
console.log(minprice);
|
| 65 |
}
|
68 |
}
|
| 66 |
if(response.products.length>0){
|
69 |
if(response.products.length>0){
|
| 67 |
//More than one products in store
|
70 |
//More than one products in store
|
| 68 |
var variants = [];
|
71 |
var variants = [];
|
| 69 |
// var i = 0;
|
72 |
// var i = 0;
|
| 70 |
for(var i in response.products){
|
73 |
for(var i in response.products){
|
| 71 |
if(response.products[i].in_stock == 1){
|
74 |
if(response.products[i].in_stock == 1){
|
| 72 |
inStock = true;
|
75 |
inStock = true;
|
| - |
|
76 |
// console.log(response.products[i]);
|
| 73 |
if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
|
77 |
if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
|
| 74 |
globalminprice = Math.round(response.products[i].available_price);
|
78 |
globalminprice = Math.round(response.products[i].available_price);
|
| 75 |
globalminsku = response.products[i]._id;
|
79 |
globalminsku = response.products[i]._id;
|
| 76 |
var globalminsource = response.products[i].source_id;
|
80 |
var globalminsource = response.products[i].source_id;
|
| 77 |
var globalminurl = response.products[i].marketPlaceUrl;
|
81 |
var globalminurl = response.products[i].marketPlaceUrl;
|
| Line 92... |
Line 96... |
| 92 |
}
|
96 |
}
|
| 93 |
}
|
97 |
}
|
| 94 |
if(inStock){
|
98 |
if(inStock){
|
| 95 |
$(that).html(minprice).siblings('.cashbackamount').html(getcashbackstring(response.products[minpriceindex].cash_back_type,response.products[minpriceindex].cash_back)).parent().addClass('viewproduct');
|
99 |
$(that).html(minprice).siblings('.cashbackamount').html(getcashbackstring(response.products[minpriceindex].cash_back_type,response.products[minpriceindex].cash_back)).parent().addClass('viewproduct');
|
| 96 |
$('#name-'+$(that).data('id')).html(response.products[minpriceindex]['source_product_name']);
|
100 |
$('#name-'+$(that).data('id')).html(response.products[minpriceindex]['source_product_name']);
|
| - |
|
101 |
// console.log(response.products[minpriceindex]);
|
| 97 |
$('#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');
|
102 |
$('#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');
|
| - |
|
103 |
// console.log(globalminprice+' '+globalminsku);
|
| 98 |
if(globalminprice != 9999999) {
|
104 |
if(globalminprice != 9999999) {
|
| 99 |
$('#bestprice').html(globalminprice).siblings('.cashbackamount').html(globalmincashback);
|
105 |
$('#bestprice').html(globalminprice).siblings('.cashbackamount').html(globalmincashback);
|
| 100 |
$('#beststorelink').data('id',globalminsku).data('source',globalminsource).data('price',globalminprice).data('url',globalminurl).removeClass('hidden');
|
106 |
$('#beststorelink').data('id',globalminsku).data('source',globalminsource).data('price',globalminprice).data('url',globalminurl).removeClass('hidden');
|
| 101 |
$('#bestpricecontainer').removeClass('hidden');
|
107 |
$('#bestpricecontainer').removeClass('hidden');
|
| 102 |
}
|
108 |
}
|
| Line 119... |
Line 125... |
| 119 |
$(that).html(btn);
|
125 |
$(that).html(btn);
|
| 120 |
ga('send', 'event', 'liveprice', 'failure', response.products[0]._id);
|
126 |
ga('send', 'event', 'liveprice', 'failure', response.products[0]._id);
|
| 121 |
}
|
127 |
}
|
| 122 |
checkForOutStocks(outOfStockCount);
|
128 |
checkForOutStocks(outOfStockCount);
|
| 123 |
},
|
129 |
},
|
| 124 |
error: function(request, status, err) {
|
130 |
error: function(request, status, err) {
|
| - |
|
131 |
//console.log(status+' '+err+' '+request);
|
| - |
|
132 |
// if (status == "timeout") {
|
| 125 |
var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
|
133 |
var btn = $("<a class='tryagainforliveprice btn btn-xs btn-warning' title='Try Again'>Try Again</a>");
|
| 126 |
$(that).html(btn);
|
134 |
$(that).html(btn);
|
| 127 |
try{
|
135 |
try{
|
| 128 |
if(response){
|
136 |
if(response){
|
| 129 |
ga('send', 'event', 'liveprice', 'error', response.products[0]._id);
|
137 |
ga('send', 'event', 'liveprice', 'error', response.products[0]._id);
|
| 130 |
}
|
138 |
}
|
| 131 |
} catch(e){}
|
139 |
} catch(e){}
|
| - |
|
140 |
// } else {
|
| - |
|
141 |
// $(that).parent().parent().remove();
|
| - |
|
142 |
// }
|
| 132 |
}
|
143 |
}
|
| 133 |
});
|
144 |
});
|
| 134 |
livePriceCalls.push(req);
|
145 |
livePriceCalls.push(req);
|
| 135 |
};
|
146 |
};
|
| 136 |
function checkForOutStocks(count){
|
147 |
function checkForOutStocks(count){
|
| Line 144... |
Line 155... |
| 144 |
});
|
155 |
});
|
| 145 |
$(document).on('click','.variants',function(){
|
156 |
$(document).on('click','.variants',function(){
|
| 146 |
$('.storeproductinfo').empty();
|
157 |
$('.storeproductinfo').empty();
|
| 147 |
var variants = $(this).data('variants');
|
158 |
var variants = $(this).data('variants');
|
| 148 |
var minprice = $(this).data('minprice');
|
159 |
var minprice = $(this).data('minprice');
|
| - |
|
160 |
// console.log(variants);
|
| 149 |
$('#variantscount').html(variants.length);
|
161 |
$('#variantscount').html(variants.length);
|
| 150 |
for(var i in variants){
|
162 |
for(var i in variants){
|
| - |
|
163 |
// console.log(variants[i]);
|
| - |
|
164 |
// var row = $('<div class="row storeproductinfo"><div class="col-xs-7">'+variants[i].source_product_name+'</div><div class="col-xs-3">'+variants[i].available_price+'</div><div class="col-xs-2"><button class="btn btn-primary btn-xs viewproduct" type="button" data-id="'+variants[i].id+'">Buy</button></div></div>');
|
| - |
|
165 |
// $('#storeproducts').parent().append(row);
|
| - |
|
166 |
// var row = $('<div class="clearfix varnts"></div><div class="col-xs-6 varnts text-small">'+variants[i].name+'</div><div class="col-xs-4 varnts"><span class="cashbackrupee"></span> <span>'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span></div><div class="col-xs-2 viewproduct varnts text-right" data-source="'+variants[i].source_id+'" data-price="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><button type="button" class="btn-xs btn btn-success">BUY</button></div>');
|
| 151 |
if(minprice == variants[i].available_price) {
|
167 |
if(minprice == variants[i].available_price) {
|
| 152 |
var row = $('<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="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span class="storeminprice">'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span></div></div>');
|
168 |
var row = $('<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="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span class="storeminprice">'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span></div></div>');
|
| 153 |
} else {
|
169 |
} else {
|
| 154 |
var row = $('<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="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span>'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span></div></div>');
|
170 |
var row = $('<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="'+variants[i].available_price+'" data-url="'+variants[i].url+'" data-id="'+variants[i].id+'"><span class="cashbackrupee varnts text-right" ></span> <span>'+variants[i].available_price+'</span><span class="cashbackamount">'+getcashbackstring(variants[i].cash_back_type,variants[i].cash_back)+'</span><span class="pull-right arrowright"></span></div></div>');
|
| 155 |
}
|
171 |
}
|
| Line 196... |
Line 212... |
| 196 |
}
|
212 |
}
|
| 197 |
}
|
213 |
}
|
| 198 |
});
|
214 |
});
|
| 199 |
ga('send', 'event', 'preferences', 'update', me);
|
215 |
ga('send', 'event', 'preferences', 'update', me);
|
| 200 |
});
|
216 |
});
|
| - |
|
217 |
// $('.row').on('click','.viewproduct',function(e){
|
| 201 |
$(document).on('click','.viewproduct',function(e){
|
218 |
$(document).on('click','.viewproduct',function(e){
|
| 202 |
if(typeof livePriceCalls != undefined) {
|
219 |
if(typeof livePriceCalls != undefined) {
|
| 203 |
for(var i in livePriceCalls){
|
220 |
for(var i in livePriceCalls){
|
| - |
|
221 |
// console.log('killing ajax call '+i);
|
| 204 |
livePriceCalls[i].abort();
|
222 |
livePriceCalls[i].abort();
|
| 205 |
}
|
223 |
}
|
| 206 |
}
|
224 |
}
|
| 207 |
$('#loadingModal').modal();
|
225 |
$('#loadingModal').modal();
|
| 208 |
if($(this).data('source')==2){
|
226 |
if($(this).data('source')==2){
|
| 209 |
//in case of flipkart, close popup after 5 seconds
|
227 |
//in case of flipkart, close popup after 5 seconds
|
| 210 |
setTimeout(function(){ $('#loadingModal').modal('hide'); }, 1000*5);
|
228 |
setTimeout(function(){ $('#loadingModal').modal('hide'); }, 1000*5);
|
| 211 |
}
|
229 |
}
|
| 212 |
var store = $(this).data('source');
|
230 |
var store = $(this).data('source');
|
| - |
|
231 |
// console.log($(this).data('id'));
|
| 213 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
|
232 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
|
| 214 |
$.ajax({
|
233 |
$.ajax({
|
| 215 |
url: url,
|
234 |
url: url,
|
| 216 |
// The name of the callback parameter, as specified by the YQL service
|
235 |
// The name of the callback parameter, as specified by the YQL service
|
| 217 |
jsonp: "callback",
|
236 |
jsonp: "callback",
|
| Line 234... |
Line 253... |
| 234 |
setTimeout(function(){ $('#customMessageModal').modal('hide'); document.location = response.url;}, 1000*3);
|
253 |
setTimeout(function(){ $('#customMessageModal').modal('hide'); document.location = response.url;}, 1000*3);
|
| 235 |
}else{
|
254 |
}else{
|
| 236 |
document.location = response.url;
|
255 |
document.location = response.url;
|
| 237 |
}
|
256 |
}
|
| 238 |
} else if (store == 2){
|
257 |
} else if (store == 2){
|
| 239 |
document.location = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
|
258 |
fkmobileurl = 'http://mobilehotindia.com/r.html?'+Base64.encode(response.url);
|
| - |
|
259 |
if(response.showmessage == 1) {
|
| - |
|
260 |
$('#loadingModal').modal('hide');
|
| - |
|
261 |
$('#customMessage').html(response.message);
|
| - |
|
262 |
$('#customMessageModal').modal('show');
|
| - |
|
263 |
setTimeout(function(){ $('#customMessageModal').modal('hide'); document.location = fkmobileurl;}, 1000*3);
|
| - |
|
264 |
}else{
|
| - |
|
265 |
document.location = fkmobileurl;
|
| - |
|
266 |
}
|
| 240 |
} else {
|
267 |
} else {
|
| 241 |
document.location = response.url;
|
268 |
document.location = response.url;
|
| 242 |
}
|
269 |
}
|
| 243 |
}
|
270 |
}
|
| 244 |
},
|
- |
|
| 245 |
error: function() {
|
- |
|
| 246 |
document.location = url;
|
- |
|
| 247 |
}
|
271 |
}
|
| 248 |
});
|
272 |
});
|
| 249 |
ga('send', 'event', 'product', 'click', $(this).data('url'));
|
273 |
ga('send', 'event', 'product', 'click', $(this).data('url'));
|
| 250 |
});
|
274 |
});
|
| 251 |
$('.jscroll-inner').on('click','.likedeal',function(e){
|
275 |
$('.jscroll-inner').on('click','.likedeal',function(e){
|
| Line 277... |
Line 301... |
| 277 |
ga('send', 'event', 'product', 'like', $(this).data('id'));
|
301 |
ga('send', 'event', 'product', 'like', $(this).data('id'));
|
| 278 |
});
|
302 |
});
|
| 279 |
$('#myModal').on('click','#unlikebtn',function(e){
|
303 |
$('#myModal').on('click','#unlikebtn',function(e){
|
| 280 |
e.preventDefault();
|
304 |
e.preventDefault();
|
| 281 |
var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
|
305 |
var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
|
| - |
|
306 |
// console.log(url);
|
| 282 |
$.ajax({
|
307 |
$.ajax({
|
| 283 |
url: url,
|
308 |
url: url,
|
| 284 |
// The name of the callback parameter, as specified by the YQL service
|
309 |
// The name of the callback parameter, as specified by the YQL service
|
| 285 |
jsonp: "callback",
|
310 |
jsonp: "callback",
|
| 286 |
// Tell jQuery we're expecting JSONP
|
311 |
// Tell jQuery we're expecting JSONP
|
| Line 289... |
Line 314... |
| 289 |
data: {
|
314 |
data: {
|
| 290 |
format: "json"
|
315 |
format: "json"
|
| 291 |
},
|
316 |
},
|
| 292 |
// Work with the response
|
317 |
// Work with the response
|
| 293 |
success: function( response ) {
|
318 |
success: function( response ) {
|
| - |
|
319 |
// console.log(response);
|
| 294 |
}
|
320 |
}
|
| 295 |
});
|
321 |
});
|
| 296 |
$('#myModal').modal('hide');
|
322 |
$('#myModal').modal('hide');
|
| 297 |
ga('send', 'event', 'brand', 'hide', $('#myModal').find('#productToHide',0).val());
|
323 |
ga('send', 'event', 'brand', 'hide', $('#myModal').find('#productToHide',0).val());
|
| 298 |
})
|
324 |
})
|
| Line 300... |
Line 326... |
| 300 |
var that = $(this);
|
326 |
var that = $(this);
|
| 301 |
if($(that).hasClass('active')){
|
327 |
if($(that).hasClass('active')){
|
| 302 |
//User has already liked it,so remove like
|
328 |
//User has already liked it,so remove like
|
| 303 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
329 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
| 304 |
}else{
|
330 |
}else{
|
| - |
|
331 |
// console.log('show modal');
|
| 305 |
$('#myModal').find('#productToHide',0).val($(this).data('id'));
|
332 |
$('#myModal').find('#productToHide',0).val($(this).data('id'));
|
| - |
|
333 |
//$('#myModal').modal();
|
| 306 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
334 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
| 307 |
}
|
335 |
}
|
| 308 |
$.ajax({
|
336 |
$.ajax({
|
| 309 |
url: url,
|
337 |
url: url,
|
| 310 |
// The name of the callback parameter, as specified by the YQL service
|
338 |
// The name of the callback parameter, as specified by the YQL service
|
| Line 431... |
Line 459... |
| 431 |
});
|
459 |
});
|
| 432 |
$(document).on('click','.banner',function(){
|
460 |
$(document).on('click','.banner',function(){
|
| 433 |
ga('send', 'event', 'banners', 'click', $(this).data('name'));
|
461 |
ga('send', 'event', 'banners', 'click', $(this).data('name'));
|
| 434 |
});
|
462 |
});
|
| 435 |
});
|
463 |
});
|
| 436 |
function setCookie(cname, cvalue, days, forceCookie) {
|
464 |
function setCookie(cname, cvalue, days) {
|
| 437 |
if(typeof(Storage) !== "undefined" && !forceCookie) {
|
- |
|
| 438 |
localStorage.setItem(cname, cvalue);
|
- |
|
| 439 |
} else{
|
- |
|
| 440 |
var d = new Date();
|
465 |
var d = new Date();
|
| 441 |
d.setTime(d.getTime() + (days*24*60*60*1000));
|
466 |
d.setTime(d.getTime() + (days*24*60*60*1000));
|
| 442 |
var expires = "expires="+d.toUTCString();
|
467 |
var expires = "expires="+d.toUTCString();
|
| 443 |
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
|
468 |
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
|
| 444 |
}
|
- |
|
| 445 |
}
|
469 |
}
|
| 446 |
|
470 |
|
| 447 |
function getCookie(cname,forceCookie) {
|
471 |
function getCookie(cname) {
|
| 448 |
if(typeof(Storage) !== "undefined" && !forceCookie) {
|
- |
|
| 449 |
return localStorage.getItem(cname);
|
- |
|
| 450 |
} else {
|
- |
|
| 451 |
var name = cname + "=";
|
472 |
var name = cname + "=";
|
| 452 |
var ca = document.cookie.split(';');
|
473 |
var ca = document.cookie.split(';');
|
| 453 |
for(var i=0; i<ca.length; i++) {
|
474 |
for(var i=0; i<ca.length; i++) {
|
| 454 |
var c = ca[i];
|
475 |
var c = ca[i];
|
| 455 |
while (c.charAt(0)==' ') c = c.substring(1);
|
476 |
while (c.charAt(0)==' ') c = c.substring(1);
|
| 456 |
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
|
477 |
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
|
| 457 |
}
|
478 |
}
|
| 458 |
return "";
|
479 |
return "";
|
| 459 |
}
|
- |
|
| 460 |
}
|
480 |
}
|
| 461 |
|
- |
|
| 462 |
function showpopup(id,count,interval){
|
481 |
function showpopup(id,count,interval){
|
| 463 |
var cname = 'notif-count-'+me+'-'+id;
|
482 |
var cname = 'notif-count-'+me+'-'+id;
|
| 464 |
var cookieval = getCookie(cname);
|
483 |
var cookieval = getCookie(cname);
|
| 465 |
var cname = 'notif-lastshown-'+me+'-'+id;
|
484 |
var cname = 'notif-lastshown-'+me+'-'+id;
|
| 466 |
var lastshown = getCookie(cname);
|
485 |
var lastshown = getCookie(cname);
|
| 467 |
if(!cookieval || cookieval == 'NaN' || cookieval==''){
|
486 |
if(cookieval==''){
|
| 468 |
incrementPopupCount(id,0,'notif-count-');
|
487 |
incrementPopupCount(id,0,'notif-count-');
|
| 469 |
setLastShown(id,'notif-lastshown-');
|
488 |
setLastShown(id,'notif-lastshown-');
|
| 470 |
return true;
|
489 |
return true;
|
| 471 |
} else{
|
490 |
} else{
|
| 472 |
var d = new Date();
|
491 |
var d = new Date();
|
| 473 |
var t = d.getTime();
|
492 |
var t = d.getTime();
|
| - |
|
493 |
console.log(t-lastshown);
|
| - |
|
494 |
console.log(interval*60*1000);
|
| 474 |
if(t-lastshown>interval*60*1000){
|
495 |
if(t-lastshown>interval*60*1000){
|
| 475 |
if(cookieval>=count){
|
496 |
if(cookieval>=count){
|
| 476 |
return false;
|
497 |
return false;
|
| 477 |
}else{
|
498 |
}else{
|
| 478 |
setLastShown(id,'notif-lastshown-');
|
499 |
setLastShown(id,'notif-lastshown-');
|
| Line 535... |
Line 556... |
| 535 |
$(document).on('click','.applyfilter',function(){
|
556 |
$(document).on('click','.applyfilter',function(){
|
| 536 |
var brands = [];
|
557 |
var brands = [];
|
| 537 |
var brandnames = [];
|
558 |
var brandnames = [];
|
| 538 |
$('.filterbrand').each(function(){
|
559 |
$('.filterbrand').each(function(){
|
| 539 |
if($(this).prop('checked')){
|
560 |
if($(this).prop('checked')){
|
| - |
|
561 |
// console.log($(this).parent().siblings('.brandname').html());
|
| 540 |
brands.push($(this).val());
|
562 |
brands.push($(this).val());
|
| 541 |
brandnames.push($(this).parent().siblings('.brandname').html());
|
563 |
brandnames.push($(this).parent().siblings('.brandname').html());
|
| 542 |
}
|
564 |
}
|
| 543 |
});
|
565 |
});
|
| 544 |
if(brands.length==0){
|
566 |
if(brands.length==0){
|
| 545 |
$('#message').html('Please choose a few brands first').removeClass('hidden');
|
567 |
$('#message').html('Please choose a few brands first').removeClass('hidden');
|
| 546 |
setTimeout(function(){ $('#message').addClass('hidden'); }, 3000);
|
568 |
setTimeout(function(){ $('#message').addClass('hidden'); }, 3000);
|
| 547 |
return false;
|
569 |
return false;
|
| 548 |
}else{
|
570 |
}else{
|
| 549 |
setCookie('brandschosen', brands, 1, true);
|
571 |
setCookie('brandschosen', brands, 1);
|
| 550 |
var url = $('#brandselecter').prop('action');
|
572 |
var url = $('#brandselecter').prop('action');
|
| 551 |
ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
|
573 |
ga('send', 'event', 'filter', 'brand', brandnames.join('|'));
|
| 552 |
var postdata = {'user_id':me,'type':'brand','filters':brandnames.join('|')};
|
574 |
var postdata = {'user_id':me,'type':'brand','filters':brandnames.join('|')};
|
| 553 |
$.post( "/user_filters/add", postdata, function( data ) {
|
575 |
$.post( "/user_filters/add", postdata, function( data ) {
|
| 554 |
document.location = url+'&brands='+brands.join('^');
|
576 |
document.location = url+'&brands='+brands.join('^');
|
| Line 567... |
Line 589... |
| 567 |
return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
|
589 |
return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
|
| 568 |
}).removeClass('hidden','slow');
|
590 |
}).removeClass('hidden','slow');
|
| 569 |
});
|
591 |
});
|
| 570 |
$(document).on('click','.filterbrand',function(){
|
592 |
$(document).on('click','.filterbrand',function(){
|
| 571 |
var clicked = $(this).parent().parent();
|
593 |
var clicked = $(this).parent().parent();
|
| - |
|
594 |
console.log(clicked.prop('class'));
|
| - |
|
595 |
// clicked.find('.filterbrand',0).prop('checked',true);
|
| 572 |
// all the LIs above the clicked one
|
596 |
// all the LIs above the clicked one
|
| 573 |
var previousAll = clicked.prevAll();
|
597 |
var previousAll = clicked.prevAll();
|
| 574 |
|
598 |
|
| 575 |
// only proceed if it's not already on top (no previous siblings)
|
599 |
// only proceed if it's not already on top (no previous siblings)
|
| 576 |
if(previousAll.length > 0) {
|
600 |
if(previousAll.length > 0) {
|
| Line 597... |
Line 621... |
| 597 |
previousAll.css({'position': 'static', 'top': 0});
|
621 |
previousAll.css({'position': 'static', 'top': 0});
|
| 598 |
}});
|
622 |
}});
|
| 599 |
}
|
623 |
}
|
| 600 |
})
|
624 |
})
|
| 601 |
$(document).on('click','.clearfilters',function(){
|
625 |
$(document).on('click','.clearfilters',function(){
|
| 602 |
setCookie('brandschosen', '', -1, true);
|
626 |
setCookie('brandschosen', '', -1);
|
| 603 |
ga('send', 'event', 'filter', 'brand', 'clearfilters');
|
627 |
ga('send', 'event', 'filter', 'brand', 'clearfilters');
|
| 604 |
var postdata = {'user_id':me,'type':'clear'};
|
628 |
var postdata = {'user_id':me,'type':'clear'};
|
| 605 |
$.post("/user_filters/add", postdata, function( data ) {
|
629 |
$.post("/user_filters/add", postdata, function( data ) {
|
| 606 |
document.location.reload();
|
630 |
document.location.reload();
|
| 607 |
});
|
631 |
});
|
| 608 |
});
|
632 |
});
|
| 609 |
function selectChosenBrands(){
|
633 |
function selectChosenBrands(){
|
| 610 |
var brandschosen = getCookie('brandschosen',true);
|
634 |
var brandschosen = getCookie('brandschosen');
|
| 611 |
if(brandschosen && brandschosen.length>0){
|
635 |
if(brandschosen && brandschosen.length>0){
|
| 612 |
var brands = brandschosen.split(',');
|
636 |
var brands = brandschosen.split(',');
|
| 613 |
for(var i in brands){
|
637 |
for(var i in brands){
|
| 614 |
$('.brand').filter(function() {
|
638 |
$('.brand').filter(function() {
|
| 615 |
return $(this).data("brandid") == brands[i];
|
639 |
return $(this).data("brandid") == brands[i];
|
| Line 617... |
Line 641... |
| 617 |
}
|
641 |
}
|
| 618 |
}
|
642 |
}
|
| 619 |
}
|
643 |
}
|
| 620 |
$(function () {
|
644 |
$(function () {
|
| 621 |
var poid = 'popovertrigger';
|
645 |
var poid = 'popovertrigger';
|
| - |
|
646 |
/*
|
| - |
|
647 |
var popovershown = getCookie('popovershown');
|
| - |
|
648 |
if(!popovershown){
|
| - |
|
649 |
popovershown = 0;
|
| - |
|
650 |
}
|
| - |
|
651 |
if(popovershown < 2){
|
| - |
|
652 |
$('[data-toggle="popover"]').popover({'html':true});
|
| - |
|
653 |
$('[data-toggle="popover"]').trigger('click');
|
| - |
|
654 |
}
|
| - |
|
655 |
*/
|
| - |
|
656 |
$('#dropdownMenu1').on('click',function(){
|
| - |
|
657 |
$('#popovertrigger').popover('hide');
|
| - |
|
658 |
incrementPopupCount(poid,0,'popover-count-');
|
| - |
|
659 |
setLastShown(poid,'popover-lastshown-');
|
| - |
|
660 |
})
|
| - |
|
661 |
|
| 622 |
var cname = 'popover-count-'+me+'-'+poid;
|
662 |
var cname = 'popover-count-'+me+'-'+poid;
|
| 623 |
var cookieval = getCookie(cname);
|
663 |
var cookieval = getCookie(cname);
|
| 624 |
$('#dropdownMenu1').on('click',function(){
|
- |
|
| 625 |
var cname = 'popover-count-'+me+'-'+poid;
|
- |
|
| 626 |
var cookieval = getCookie(cname);
|
- |
|
| 627 |
$('#popovertrigger').popover('hide');
|
- |
|
| 628 |
if(!cookieval || cookieval == 'NaN' || cookieval == ''){
|
- |
|
| 629 |
incrementPopupCount(poid,0,'popover-count-');
|
- |
|
| 630 |
} else {
|
- |
|
| 631 |
incrementPopupCount(poid, cookieval, 'popover-count-');
|
- |
|
| 632 |
}
|
- |
|
| 633 |
setLastShown(poid,'popover-lastshown-');
|
- |
|
| 634 |
})
|
- |
|
| 635 |
|
- |
|
| 636 |
var cname = 'popover-lastshown-'+me+'-'+poid;
|
664 |
var cname = 'popover-lastshown-'+me+'-'+poid;
|
| 637 |
var lastshown = getCookie(cname);
|
665 |
var lastshown = getCookie(cname);
|
| 638 |
if(cookieval=='' || cookieval == 'NaN' || !cookieval){
|
666 |
if(cookieval==''){
|
| 639 |
showpopover(poid);
|
667 |
showpopover(poid);
|
| 640 |
} else{
|
668 |
} else{
|
| 641 |
var d = new Date();
|
669 |
var d = new Date();
|
| 642 |
var t = d.getTime();
|
670 |
var t = d.getTime();
|
| - |
|
671 |
console.log('time elapsed '+(t-lastshown));
|
| 643 |
if(t-lastshown>18*3600*1000){
|
672 |
if(t-lastshown>18*3600*1000){
|
| 644 |
if(cookieval>=2){
|
673 |
if(cookieval>2){
|
| 645 |
return false;
|
674 |
return false;
|
| 646 |
}else{
|
675 |
}else{
|
| 647 |
showpopover(poid);
|
676 |
showpopover(poid);
|
| - |
|
677 |
incrementPopupCount(poid,cookieval,'popover-count-');
|
| - |
|
678 |
setLastShown(poid,'popover-lastshown-');
|
| 648 |
}
|
679 |
}
|
| 649 |
}
|
680 |
}
|
| 650 |
}
|
681 |
}
|
| 651 |
});
|
682 |
});
|
| 652 |
function showpopover(id){
|
683 |
function showpopover(id){
|
| Line 655... |
Line 686... |
| 655 |
}
|
686 |
}
|
| 656 |
$(document).on('click','.nodeals',function(){
|
687 |
$(document).on('click','.nodeals',function(){
|
| 657 |
document.location = $(this).data('href');
|
688 |
document.location = $(this).data('href');
|
| 658 |
})
|
689 |
})
|
| 659 |
var Base64 = {
|
690 |
var Base64 = {
|
| - |
|
691 |
|
| - |
|
692 |
|
| 660 |
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
693 |
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
| - |
|
694 |
|
| - |
|
695 |
|
| 661 |
encode: function(input) {
|
696 |
encode: function(input) {
|
| 662 |
var output = "";
|
697 |
var output = "";
|
| 663 |
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
698 |
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
| 664 |
var i = 0;
|
699 |
var i = 0;
|
| - |
|
700 |
|
| 665 |
input = Base64._utf8_encode(input);
|
701 |
input = Base64._utf8_encode(input);
|
| - |
|
702 |
|
| 666 |
while (i < input.length) {
|
703 |
while (i < input.length) {
|
| - |
|
704 |
|
| 667 |
chr1 = input.charCodeAt(i++);
|
705 |
chr1 = input.charCodeAt(i++);
|
| 668 |
chr2 = input.charCodeAt(i++);
|
706 |
chr2 = input.charCodeAt(i++);
|
| 669 |
chr3 = input.charCodeAt(i++);
|
707 |
chr3 = input.charCodeAt(i++);
|
| 670 |
|
708 |
|
| 671 |
enc1 = chr1 >> 2;
|
709 |
enc1 = chr1 >> 2;
|
| 672 |
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
710 |
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
| 673 |
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
711 |
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
| 674 |
enc4 = chr3 & 63;
|
712 |
enc4 = chr3 & 63;
|
| - |
|
713 |
|
| 675 |
if (isNaN(chr2)) {
|
714 |
if (isNaN(chr2)) {
|
| 676 |
enc3 = enc4 = 64;
|
715 |
enc3 = enc4 = 64;
|
| 677 |
} else if (isNaN(chr3)) {
|
716 |
} else if (isNaN(chr3)) {
|
| 678 |
enc4 = 64;
|
717 |
enc4 = 64;
|
| 679 |
}
|
718 |
}
|
| - |
|
719 |
|
| 680 |
output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
720 |
output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
| - |
|
721 |
|
| 681 |
}
|
722 |
}
|
| - |
|
723 |
|
| 682 |
return output;
|
724 |
return output;
|
| 683 |
},
|
725 |
},
|
| 684 |
|
726 |
|
| 685 |
|
727 |
|
| 686 |
decode: function(input) {
|
728 |
decode: function(input) {
|
| 687 |
var output = "";
|
729 |
var output = "";
|
| 688 |
var chr1, chr2, chr3;
|
730 |
var chr1, chr2, chr3;
|
| 689 |
var enc1, enc2, enc3, enc4;
|
731 |
var enc1, enc2, enc3, enc4;
|
| 690 |
var i = 0;
|
732 |
var i = 0;
|
| - |
|
733 |
|
| 691 |
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
734 |
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
| - |
|
735 |
|
| 692 |
while (i < input.length) {
|
736 |
while (i < input.length) {
|
| - |
|
737 |
|
| 693 |
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
738 |
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
| 694 |
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
739 |
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
| 695 |
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
740 |
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
| 696 |
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
741 |
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
| - |
|
742 |
|
| 697 |
chr1 = (enc1 << 2) | (enc2 >> 4);
|
743 |
chr1 = (enc1 << 2) | (enc2 >> 4);
|
| 698 |
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
744 |
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
| 699 |
chr3 = ((enc3 & 3) << 6) | enc4;
|
745 |
chr3 = ((enc3 & 3) << 6) | enc4;
|
| - |
|
746 |
|
| 700 |
output = output + String.fromCharCode(chr1);
|
747 |
output = output + String.fromCharCode(chr1);
|
| - |
|
748 |
|
| 701 |
if (enc3 != 64) {
|
749 |
if (enc3 != 64) {
|
| 702 |
output = output + String.fromCharCode(chr2);
|
750 |
output = output + String.fromCharCode(chr2);
|
| 703 |
}
|
751 |
}
|
| 704 |
if (enc4 != 64) {
|
752 |
if (enc4 != 64) {
|
| 705 |
output = output + String.fromCharCode(chr3);
|
753 |
output = output + String.fromCharCode(chr3);
|
| 706 |
}
|
754 |
}
|
| - |
|
755 |
|
| 707 |
}
|
756 |
}
|
| - |
|
757 |
|
| 708 |
output = Base64._utf8_decode(output);
|
758 |
output = Base64._utf8_decode(output);
|
| - |
|
759 |
|
| 709 |
return output;
|
760 |
return output;
|
| - |
|
761 |
|
| 710 |
},
|
762 |
},
|
| 711 |
|
763 |
|
| 712 |
_utf8_encode: function(string) {
|
764 |
_utf8_encode: function(string) {
|
| 713 |
string = string.replace(/\r\n/g, "\n");
|
765 |
string = string.replace(/\r\n/g, "\n");
|
| 714 |
var utftext = "";
|
766 |
var utftext = "";
|
| - |
|
767 |
|
| 715 |
for (var n = 0; n < string.length; n++) {
|
768 |
for (var n = 0; n < string.length; n++) {
|
| - |
|
769 |
|
| 716 |
var c = string.charCodeAt(n);
|
770 |
var c = string.charCodeAt(n);
|
| - |
|
771 |
|
| 717 |
if (c < 128) {
|
772 |
if (c < 128) {
|
| 718 |
utftext += String.fromCharCode(c);
|
773 |
utftext += String.fromCharCode(c);
|
| 719 |
}
|
774 |
}
|
| 720 |
else if ((c > 127) && (c < 2048)) {
|
775 |
else if ((c > 127) && (c < 2048)) {
|
| 721 |
utftext += String.fromCharCode((c >> 6) | 192);
|
776 |
utftext += String.fromCharCode((c >> 6) | 192);
|
| Line 724... |
Line 779... |
| 724 |
else {
|
779 |
else {
|
| 725 |
utftext += String.fromCharCode((c >> 12) | 224);
|
780 |
utftext += String.fromCharCode((c >> 12) | 224);
|
| 726 |
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
781 |
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
| 727 |
utftext += String.fromCharCode((c & 63) | 128);
|
782 |
utftext += String.fromCharCode((c & 63) | 128);
|
| 728 |
}
|
783 |
}
|
| - |
|
784 |
|
| 729 |
}
|
785 |
}
|
| - |
|
786 |
|
| 730 |
return utftext;
|
787 |
return utftext;
|
| 731 |
},
|
788 |
},
|
| 732 |
|
789 |
|
| 733 |
_utf8_decode: function(utftext) {
|
790 |
_utf8_decode: function(utftext) {
|
| 734 |
var string = "";
|
791 |
var string = "";
|
| 735 |
var i = 0;
|
792 |
var i = 0;
|
| 736 |
var c = c1 = c2 = 0;
|
793 |
var c = c1 = c2 = 0;
|
| - |
|
794 |
|
| 737 |
while (i < utftext.length) {
|
795 |
while (i < utftext.length) {
|
| - |
|
796 |
|
| 738 |
c = utftext.charCodeAt(i);
|
797 |
c = utftext.charCodeAt(i);
|
| - |
|
798 |
|
| 739 |
if (c < 128) {
|
799 |
if (c < 128) {
|
| 740 |
string += String.fromCharCode(c);
|
800 |
string += String.fromCharCode(c);
|
| 741 |
i++;
|
801 |
i++;
|
| 742 |
}
|
802 |
}
|
| 743 |
else if ((c > 191) && (c < 224)) {
|
803 |
else if ((c > 191) && (c < 224)) {
|
| Line 749... |
Line 809... |
| 749 |
c2 = utftext.charCodeAt(i + 1);
|
809 |
c2 = utftext.charCodeAt(i + 1);
|
| 750 |
c3 = utftext.charCodeAt(i + 2);
|
810 |
c3 = utftext.charCodeAt(i + 2);
|
| 751 |
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
811 |
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
| 752 |
i += 3;
|
812 |
i += 3;
|
| 753 |
}
|
813 |
}
|
| - |
|
814 |
|
| 754 |
}
|
815 |
}
|
| - |
|
816 |
|
| 755 |
return string;
|
817 |
return string;
|
| 756 |
}
|
818 |
}
|
| - |
|
819 |
|
| 757 |
}
|
820 |
}
|
| 758 |
|
821 |
|