content/js/feeds.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
function format_date(d){
return $.timeago(Date.parse(d));
}
function get_json_data(uri, options){
$.getJSON(uri,
function(data){
var list = $("<ul></ul>");
for (var i=0; i<options.max; i++){
var item = github_entry(data.commits[i], options.repo)
item.appendTo(list);
}
list.appendTo(options.element).fadeIn(1000);
});
}
function github_entry(commit, repo){
var it = $("<li></li>").addClass('commit-data');
var dt = $("<span></span>").addClass('commit-date').html(format_date(commit.committed_date)+" · ");
var link = $("<span></span><br />").addClass('commit-link').append($('<a></a>').attr('href', commit.url).html("» VIEW"));
var tx = $("<span></span>").addClass('commit-text').html(commit.message
.replace(/(closes) #(\d+)/ig, "$1 <a href='http://github.com/h3rald/"+repo+"/issues/#issue/$2'>#$2</a>")+"<br />");
it.append(tx);
it.append(dt);
it.append(link);
return it
}
/*
http://github.com/api/v2/json/commits/list/h3rald/concatenative/master
http://github.com/api/v2/json/commits/list/h3rald/redbook/master
http://github.com/api/v2/json/commits/list/h3rald/glyph/master
http://github.com/api/v2/json/commits/list/h3rald/stash/master
http://github.com/api/v2/json/commits/list/h3rald/rawline/master
http://github.com/api/v2/json/commits/list/h3rald/h3rald/master
*/
function display_commits(max, repo)
{
get_json_data("/data/"+repo+".json", {max: max, element: '#github', repo: repo})
}
|