| 13579 |
anikendra |
1 |
$(function(){
|
|
|
2 |
$('.scroll').jscroll({
|
|
|
3 |
loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
|
|
|
4 |
autoTriggerUntil: 3,
|
|
|
5 |
padding: 20,
|
|
|
6 |
});
|
|
|
7 |
$('.scroll').on('click','.viewproduct',function(e){
|
|
|
8 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
|
|
|
9 |
$.ajax({
|
|
|
10 |
url: url,
|
|
|
11 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
12 |
jsonp: "callback",
|
|
|
13 |
// Tell jQuery we're expecting JSONP
|
|
|
14 |
dataType: "jsonp",
|
|
|
15 |
// Tell YQL what we want and that we want JSON
|
|
|
16 |
data: {
|
|
|
17 |
format: "json"
|
|
|
18 |
},
|
|
|
19 |
// Work with the response
|
|
|
20 |
success: function( response ) {
|
|
|
21 |
if(response.success && response.type=='redirect'){
|
|
|
22 |
document.location = response.url;
|
|
|
23 |
}
|
|
|
24 |
}
|
|
|
25 |
});
|
| 13583 |
anikendra |
26 |
});
|
|
|
27 |
$('.scroll').on('click','.likedeal',function(e){
|
|
|
28 |
var that = $(this);
|
|
|
29 |
if($(that).find('.btn',0).hasClass('active')){
|
|
|
30 |
//User has already liked it,so remove like
|
|
|
31 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/like";
|
|
|
32 |
}else{
|
|
|
33 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/like";
|
|
|
34 |
}
|
|
|
35 |
$.ajax({
|
|
|
36 |
url: url,
|
|
|
37 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
38 |
jsonp: "callback",
|
|
|
39 |
// Tell jQuery we're expecting JSONP
|
|
|
40 |
dataType: "jsonp",
|
|
|
41 |
// Tell YQL what we want and that we want JSON
|
|
|
42 |
data: {
|
|
|
43 |
format: "json"
|
|
|
44 |
},
|
|
|
45 |
// Work with the response
|
|
|
46 |
success: function( response ) {
|
|
|
47 |
if(response.success){
|
|
|
48 |
$(that).find('.btn',0).toggleClass('active');
|
|
|
49 |
$(that).parent().find('li.dislikedeal',0).find('.btn',0).removeClass('active');
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
});
|
|
|
53 |
});
|
|
|
54 |
$('.scroll').on('click','.dislikedeal',function(e){
|
|
|
55 |
var that = $(this);
|
|
|
56 |
if($(that).find('.btn',0).hasClass('active')){
|
|
|
57 |
//User has already liked it,so remove like
|
|
|
58 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
|
|
59 |
}else{
|
|
|
60 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
|
|
61 |
}
|
|
|
62 |
$.ajax({
|
|
|
63 |
url: url,
|
|
|
64 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
65 |
jsonp: "callback",
|
|
|
66 |
// Tell jQuery we're expecting JSONP
|
|
|
67 |
dataType: "jsonp",
|
|
|
68 |
// Tell YQL what we want and that we want JSON
|
|
|
69 |
data: {
|
|
|
70 |
format: "json"
|
|
|
71 |
},
|
|
|
72 |
// Work with the response
|
|
|
73 |
success: function( response ) {
|
|
|
74 |
if(response.success){
|
|
|
75 |
$(that).find('.btn',0).toggleClass('active');
|
|
|
76 |
$(that).parent().find('li.likedeal',0).find('.btn',0).removeClass('active');
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
});
|
|
|
80 |
});
|
| 13579 |
anikendra |
81 |
});
|