github.js: simplify code

This commit is contained in:
XhmikosR 2013-03-02 08:43:09 +02:00 committed by Daniel Marjamäki
parent 9d195144ea
commit c807b12b37
2 changed files with 4 additions and 9 deletions

View File

@ -5,19 +5,14 @@ jQuery.fn.listCommits = function(username, repository, branch) {
var target = this; var target = this;
$.getJSON('https://api.github.com/repos/' + username + '/' + repository + '/commits?sha=' + branch + '&callback=?', function(response) { $.getJSON('https://api.github.com/repos/' + username + '/' + repository + '/commits?sha=' + branch + '&callback=?', function(response) {
var commits = response.data; var commits = response.data,
list = $('<ul class="rssfeeditems"/>');
var list = $('<ul class="rssfeeditems"/>');
target.empty().append(list); target.empty().append(list);
$(commits).each(function(i) { $(commits).each(function(i) {
var githubUrl = 'https://github.com/' + username + '/' + repository + '/commit/' + this.sha, var githubUrl = 'https://github.com/' + username + '/' + repository + '/commit/' + this.sha,
shortMessage = cutLines(this.commit.message), shortMessage = cutLines(this.commit.message),
commitAuthor; commitAuthor = (this.author !== null) ? this.author.login : '';
if (this.author !== null) {
commitAuthor = this.author.login;
}
if (commitAuthor) { if (commitAuthor) {
list.append('<li><a href="' + githubUrl + '">' + shortMessage + '</a> <em>by <strong>' + commitAuthor + '</strong></em></li>'); list.append('<li><a href="' + githubUrl + '">' + shortMessage + '</a> <em>by <strong>' + commitAuthor + '</strong></em></li>');

File diff suppressed because one or more lines are too long