Subversion Repositories SmartDukaan

Rev

Rev 17070 | Blame | Compare with Previous | Last modification | View Log | RSS feed

$.fn.stars = function() {
    return $(this).each(function() {
        // Get the value
        var val = parseFloat($(this).html());
        // Make sure that the value is in 0 - 5 range, multiply to get width
        val = Math.round(val * 2) / 2;
        var size = Math.max(0, (Math.min(5, val))) * 16;
        // Create stars holder
        var $span = $('<span />').width(size);
        // Replace the numerical value with stars
        $(this).html($span);
    });
}
$(function() {
    $('span.stars').stars();
        $('.getapp').on('click',function(e){
                $('#loadingModal').modal('show');
                var that = $(this);
                var req = $.ajax({
                        url: apihost+'appAffiliates/generateRedirectUrl/'+$(that).data('me')+'/'+$(that).data('id'),
                        // Tell jQuery we're expecting JSONP
                        dataType: "jsonp",
                        // Tell YQL what we want and that we want JSON                  
                        method: 'get',
                        // timeout: 30000,
                        // Work with the response
                        success: function( response ) {
                                //$('#loadingModal').modal('hide');
                                if(response.message=='Success'){
                                        document.location = response.url;
                                }
                        }
                },'json');
                ga('send', 'event', 'app', 'click',$(that).data('name'));
                setTimeout(function(){$('#loadingModal').modal('hide');},10000);
        });
});