Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #162 from trans/master

Fix paging of starred repos.
  • Loading branch information...
commit 177b3b80eaeea1354e738d942d137d3d62890b0e 2 parents 3b81ad7 + 7c7f0eb
David Coallier authored
Showing with 22 additions and 11 deletions.
  1. +22 −11 js/githubresume.js
33 js/githubresume.js
View
@@ -79,29 +79,40 @@ var github_user_orgs = function(username, callback) {
$.getJSON('https://api.github.com/users/' + username + '/orgs?callback=?', callback);
}
-var github_user_stars = function(username) {
+// Check to see if the user has starred the resume.github.com repo.
+//
+// Returns true/false.
+var github_user_starred_resume = function(username, page) {
+ var star = false;
var repos = [];
+ var page = (page ? page : 1);
+ var url = 'https://api.github.com/users/' + username + '/starred?page=' + page;
+
$.ajax({
- url: 'https://api.github.com/users/' + username + '/starred',
+ url: url,
async: false,
dataType: 'json',
- success: function(json) {
- repos = json;
+ success: function(data) {
+ repos = data;
}
});
- return repos;
-}
-var github_user_starred_resume = function(username) {
- var starred = false;
- var repos = github_user_stars(username);
$.each(repos, function(i, repo) {
if (repo.full_name == "resume/resume.github.com") {
- starred = true;
+ star = true;
return false; // stop iterating
}
});
- return starred;
+
+ if (star) {
+ return star;
+ }
+
+ if (repos.length > 0) {
+ star = github_user_starred_resume(username, page + 1);
+ }
+
+ return star;
}
var run = function() {
Please sign in to comment.
Something went wrong with that request. Please try again.