Subversion Repositories SmartDukaan

Rev

Rev 17070 | 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){
16767 anikendra 17
		$('#loadingModal').modal('show');
16721 anikendra 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 ) {
17070 anikendra 28
				//$('#loadingModal').modal('hide');
16721 anikendra 29
				if(response.message=='Success'){
30
					document.location = response.url;
31
				}
32
			}
33
		},'json');
17206 anikendra 34
		ga('send', 'event', 'app', 'click',$(that).data('name'));
17070 anikendra 35
		setTimeout(function(){$('#loadingModal').modal('hide');},10000);
16721 anikendra 36
	});
16730 anikendra 37
});