Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some error treatment #8

  • Loading branch information...
commit 0e2b5bea6f0761e8317cb9fa18d4685496d90333 1 parent 931f903
Zeno Rocha authored
Showing with 30 additions and 32 deletions.
  1. +30 −32 scripts/hub.me.js
View
62 scripts/hub.me.js
@@ -20,11 +20,9 @@
// minified (especially when both are regularly referenced in your plugin).
// Create the defaults once
- var hubMe = 'defaultHubMe',
+ var hubMe = 'hubMe',
defaults = {
- propertyName: 'value',
- username: 'github',
- //sortBy: 'language' //popularity
+ username: 'github'
};
// The actual plugin constructor
@@ -49,32 +47,32 @@
Plugin.prototype.getRepos = function () {
- var self = this;
+ var self = this;
var repos = [];
$.getJSON('https://api.github.com/users/' + this.options.username + '/repos?callback=?', function (result) {
-
- $.each(result.data, function(i, field) {
- if (field.language != null)
- repos.push(field);
- });
+
+ $.each(result.data, function(i, field) {
+ if (field.language != null)
+ repos.push(field);
+ });
- repos = orderByLanguages(repos);
+ repos = orderByLanguages(repos);
- $.each(repos, function(i, field) {
-
- if (i > 0) {
- if (repos[i].language != repos[i-1].language) {
- self.createCategory(repos[i].language);
- }
- }
- else {
- self.createCategory(repos[i].language);
- }
+ $.each(repos, function(i, field) {
+
+ if (i > 0) {
+ if (repos[i].language != repos[i-1].language) {
+ self.createCategory(repos[i].language);
+ }
+ }
+ else {
+ self.createCategory(repos[i].language);
+ }
- self.createRepo(repos[i]);
+ self.createRepo(repos[i]);
- });
+ });
});
};
@@ -104,18 +102,18 @@
};
var orderByLanguages = function(repos) {
-
+
return repos.sort(function(a, b) {
-
- var langA = a.language,
- langB = b.language;
+
+ var langA = a.language,
+ langB = b.language;
- if (langA < langB)
- return -1;
- if (langA > langB)
- return 1;
+ if (langA < langB)
+ return -1;
+ if (langA > langB)
+ return 1;
- });
+ });
}
// A really lightweight plugin wrapper around the constructor,
Please sign in to comment.
Something went wrong with that request. Please try again.