Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
16721 anikendra 1
$.fn.stars = function() {
2
    return $(this).each(function() {
3
        // Get the value
4
        var val = parseFloat($(this).html());
5
        // Make sure that the value is in 0 - 5 range, multiply to get width
6
        val = Math.round(val * 2) / 2;
7
        var size = Math.max(0, (Math.min(5, val))) * 16;
8
        // Create stars holder
9
        var $span = $('<span />').width(size);
10
        // Replace the numerical value with stars
11
        $(this).html($span);
12
    });
13
}
14
$(function() {
15
    $('span.stars').stars();
16
	$('.getapp').on('click',function(e){
17
		console.log(e);
18
		var that = $(this);
19
		var req = $.ajax({
16730 anikendra 20
			url: apihost+'appAffiliates/generateRedirectUrl/'+$(that).data('me')+'/'+$(that).data('id'),
16721 anikendra 21
			// Tell jQuery we're expecting JSONP
22
			dataType: "jsonp",
23
			// Tell YQL what we want and that we want JSON			
24
			method: 'get',
25
			// timeout: 30000,
26
			// Work with the response
27
			success: function( response ) {
28
				if(response.message=='Success'){
29
					document.location = response.url;
30
				}
31
			}
32
		},'json');
33
	});
16730 anikendra 34
});