Subversion Repositories SmartDukaan

Rev

Rev 13599 | Rev 13682 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
	});
13599 anikendra 7
	$('.row').on('click','.viewproduct',function(e){
13579 anikendra 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
	});
13599 anikendra 27
	$('.row').on('click','.likedeal',function(e){		
13583 anikendra 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){
13672 anikendra 48
					$(that).toggleClass('active');
49
					$(that).parent().find('li.dislikedeal',0).removeClass('active');
13583 anikendra 50
				}
51
			}
52
		});
53
	});
13599 anikendra 54
	$('.row').on('click','.dislikedeal',function(e){		
13583 anikendra 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){
13672 anikendra 75
					$(that).toggleClass('active');
76
					$(that).parent().find('li.likedeal',0).removeClass('active');
13583 anikendra 77
				}
78
			}
79
		});
80
	});
13599 anikendra 81
});