Skip to content

Instantly share code, notes, and snippets.

@chaserx
Forked from johnboxall/github-repo-json.js
Created February 11, 2010 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaserx/301527 to your computer and use it in GitHub Desktop.
Save chaserx/301527 to your computer and use it in GitHub Desktop.
$(function() {
// Github Repo JSON Endpoint
var endpoint = "http://github.com/api/v1/json/chaserx?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>'+'<p>'+repos.description+'</p>'+'</li>';
}
});
$("#projects").append(reposHTML);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment