/* * Parameters: * limit: (integer) How many commits to render, starting with the most recent commit * width: (integer) Width of the widget * height: (integer) Height of the widget * heading: (string) Text in the header of the widget */ $(function(){ var $commitsList = $('.commits-list'); var keyValuePairs = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&"); var x, params = {}; $.each(keyValuePairs, function(i, keyValue){ x = keyValue.split('='); params[x[0]] = x[1]; }); if( params.width ) { $('.widget-container').css('width', params.width + 'px'); } if( params.height ) { $('.widget-container').css('height', params.height + 'px'); $('.widget-container .commits-list').css('height', (params.height - 31) + 'px'); } if( params.heading ) { $('.widget-container h1').text( decodeURIComponent(params.heading) ); } $('.widget-container .header').click(function(){ window.open('https://github.com/discourse/discourse'); }); $.ajax( "https://api.github.com/repos/discourse/discourse/commits?callback=callback", { dataType: 'jsonp', type: 'get', data: { per_page: params.limit || 10 }, success: function(response, textStatus, jqXHR) { var data = response.data; $.each(data, function(i, commit){ var $li = $('
').appendTo( $commitsList ); if( commit.sha && commit.commit && commit.commit.message && commit.commit.author && commit.commit.committer && commit.commit.committer.date ) { if( commit.author && commit.author.gravatar_id ) { $('').appendTo( $li ); } else { $('').appendTo( $li ); } $right = $('').appendTo( $li ); $('