| Line 26... |
Line 26... |
| 26 |
var x = a[key]; var y = b[key];
|
26 |
var x = a[key]; var y = b[key];
|
| 27 |
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
27 |
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
| 28 |
});
|
28 |
});
|
| 29 |
};
|
29 |
};
|
| 30 |
function fetchLivePrice(obj){
|
30 |
function fetchLivePrice(obj){
|
| 31 |
console.log(obj);
|
31 |
// console.log(obj);
|
| 32 |
var inStock = false;
|
32 |
var inStock = false;
|
| 33 |
var that = obj;
|
33 |
var that = obj;
|
| 34 |
var req = $.ajax({
|
34 |
var req = $.ajax({
|
| 35 |
url: '/store_products/getliveprice/'+$(that).data('bundle_id')+'/'+$(that).data('id'),
|
35 |
url: '/store_products/getliveprice/'+$(that).data('bundle_id')+'/'+$(that).data('id'),
|
| 36 |
// Tell jQuery we're expecting JSONP
|
36 |
// Tell jQuery we're expecting JSONP
|
| Line 103... |
Line 103... |
| 103 |
$(document).on('click','.variants',function(){
|
103 |
$(document).on('click','.variants',function(){
|
| 104 |
$('.storeproductinfo').empty();
|
104 |
$('.storeproductinfo').empty();
|
| 105 |
var variants = $(this).data('variants');
|
105 |
var variants = $(this).data('variants');
|
| 106 |
$('#variantscount').html(variants.length);
|
106 |
$('#variantscount').html(variants.length);
|
| 107 |
for(var i in variants){
|
107 |
for(var i in variants){
|
| 108 |
console.log(variants[i]);
|
108 |
// console.log(variants[i]);
|
| 109 |
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>');
|
109 |
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>');
|
| 110 |
$('#storeproducts').parent().append(row);
|
110 |
$('#storeproducts').parent().append(row);
|
| 111 |
}
|
111 |
}
|
| 112 |
// console.log($(this).parent());
|
112 |
// console.log($(this).parent());
|
| 113 |
$('#storename').html($(this).parent().data('storename'));
|
113 |
$('#storename').html($(this).parent().data('storename'));
|
| Line 154... |
Line 154... |
| 154 |
});
|
154 |
});
|
| 155 |
// $('.row').on('click','.viewproduct',function(e){
|
155 |
// $('.row').on('click','.viewproduct',function(e){
|
| 156 |
$(document).on('click','.viewproduct',function(e){
|
156 |
$(document).on('click','.viewproduct',function(e){
|
| 157 |
if(typeof livePriceCalls != undefined) {
|
157 |
if(typeof livePriceCalls != undefined) {
|
| 158 |
for(var i in livePriceCalls){
|
158 |
for(var i in livePriceCalls){
|
| 159 |
console.log('killing ajax call '+i);
|
159 |
// console.log('killing ajax call '+i);
|
| 160 |
livePriceCalls[i].abort();
|
160 |
livePriceCalls[i].abort();
|
| 161 |
}
|
161 |
}
|
| 162 |
}
|
162 |
}
|
| 163 |
$('#loadingModal').modal();
|
163 |
$('#loadingModal').modal();
|
| 164 |
console.log($(this).data('id'));
|
164 |
// console.log($(this).data('id'));
|
| 165 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
|
165 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id')+'/'+$(this).data('source')+'/?url='+encodeURIComponent($(this).data('url'))+'&price='+$(this).data('price');
|
| 166 |
$.ajax({
|
166 |
$.ajax({
|
| 167 |
url: url,
|
167 |
url: url,
|
| 168 |
// The name of the callback parameter, as specified by the YQL service
|
168 |
// The name of the callback parameter, as specified by the YQL service
|
| 169 |
jsonp: "callback",
|
169 |
jsonp: "callback",
|
| Line 211... |
Line 211... |
| 211 |
ga('send', 'event', 'product', 'like', $(this).data('id'));
|
211 |
ga('send', 'event', 'product', 'like', $(this).data('id'));
|
| 212 |
});
|
212 |
});
|
| 213 |
$('#myModal').on('click','#unlikebtn',function(e){
|
213 |
$('#myModal').on('click','#unlikebtn',function(e){
|
| 214 |
e.preventDefault();
|
214 |
e.preventDefault();
|
| 215 |
var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
|
215 |
var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
|
| 216 |
console.log(url);
|
216 |
// console.log(url);
|
| 217 |
$.ajax({
|
217 |
$.ajax({
|
| 218 |
url: url,
|
218 |
url: url,
|
| 219 |
// The name of the callback parameter, as specified by the YQL service
|
219 |
// The name of the callback parameter, as specified by the YQL service
|
| 220 |
jsonp: "callback",
|
220 |
jsonp: "callback",
|
| 221 |
// Tell jQuery we're expecting JSONP
|
221 |
// Tell jQuery we're expecting JSONP
|
| Line 236... |
Line 236... |
| 236 |
var that = $(this);
|
236 |
var that = $(this);
|
| 237 |
if($(that).hasClass('active')){
|
237 |
if($(that).hasClass('active')){
|
| 238 |
//User has already liked it,so remove like
|
238 |
//User has already liked it,so remove like
|
| 239 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
239 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
| 240 |
}else{
|
240 |
}else{
|
| 241 |
console.log('show modal');
|
241 |
// console.log('show modal');
|
| 242 |
$('#myModal').find('#productToHide',0).val($(this).data('id'));
|
242 |
$('#myModal').find('#productToHide',0).val($(this).data('id'));
|
| 243 |
//$('#myModal').modal();
|
243 |
//$('#myModal').modal();
|
| 244 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
244 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
| 245 |
}
|
245 |
}
|
| 246 |
$.ajax({
|
246 |
$.ajax({
|