Skip to content
Browse files

use $.grep (thanks henrik)

  • Loading branch information...
1 parent c91af25 commit 2f7d48d718d6f8bc9b93e3a4df73307976d37e70 @defunkt defunkt committed Dec 17, 2008
Showing with 3 additions and 5 deletions.
  1. +3 −5 index.html
View
8 index.html
@@ -44,19 +44,17 @@
var limit = 10 // how many repos to list
var login = 'defunkt' // your username
- var repos = [], list = $('#repos')
-
$.getJSON('http://github.com/api/v1/json/' + login + '?callback=?', function(data) {
- $.each(data.user.repositories, function() {
- if (!this.fork) repos.push(this)
+ var repos = $.grep(data.user.repositories, function() {
+ return !this.fork
})
repos.sort(function(a, b) {
return b.watchers - a.watchers
})
$.each(repos.slice(0, limit), function() {
- list.append('<li><a href="' + this.url + '">' + this.name + '</a></li>')
+ $('#repos').append('<li><a href="' + this.url + '">' + this.name + '</a></li>')
})
})
})

0 comments on commit 2f7d48d

Please sign in to comment.
Something went wrong with that request. Please try again.