Subversion Repositories SmartDukaan

Rev

Rev 13579 | Rev 13599 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13579 Rev 13583
Line 3... Line 3...
3
		loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
3
		loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
4
	    autoTriggerUntil: 3,
4
	    autoTriggerUntil: 3,
5
	    padding: 20,
5
	    padding: 20,
6
	});
6
	});
7
	$('.scroll').on('click','.viewproduct',function(e){
7
	$('.scroll').on('click','.viewproduct',function(e){
8
		console.log(e.target);
-
 
9
		var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
8
		var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
10
		$.ajax({
9
		$.ajax({
11
			url: url,
10
			url: url,
12
			// The name of the callback parameter, as specified by the YQL service
11
			// The name of the callback parameter, as specified by the YQL service
13
			jsonp: "callback",
12
			jsonp: "callback",
Line 22... Line 21...
22
				if(response.success && response.type=='redirect'){
21
				if(response.success && response.type=='redirect'){
23
					document.location = response.url;
22
					document.location = response.url;
24
				}
23
				}
25
			}
24
			}
26
		});
25
		});
-
 
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
		});
27
	})
80
	});
28
});
81
});
29
82