Skip to content

Instantly share code, notes, and snippets.

@johnboxall
Created March 6, 2009 08:43
Show Gist options
  • Save johnboxall/74826 to your computer and use it in GitHub Desktop.
Save johnboxall/74826 to your computer and use it in GitHub Desktop.
$(function() {
// Github Repo JSON Endpoint
var endpoint = "http://github.com/api/v1/json/johnboxall?callback=?";
$.fn.sort = function() {return this.pushStack(jQuery.makeArray([].sort.apply(this, arguments)));};
$.getJSON(ENDPOINT, function(data) {
// Remove all the old projects!
$("#projects li").remove();
// Sort the Repo JSON data by name.
data.user.repositories.sort(function(a, b) {return a.name > b.name;});
// Build up the Repo HTML to insert into the page.
var reposHTML = '';
$.each(data.user.repositories, function(i, repos) {
if (!repos.private) {
reposHTML += '<li><a href="'+repos.url+'">'+repos.name+'</a> - '+repos.description+'</li>';
}
});
$("#projects").append(reposHTML);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment