Skip to content

Commit

Permalink
Fix open page
Browse files Browse the repository at this point in the history
  • Loading branch information
kyungmin committed Nov 22, 2014
1 parent 4a9ce88 commit 50b744c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 55 deletions.
106 changes: 55 additions & 51 deletions static/js/balanced.js
Expand Up @@ -189,66 +189,71 @@
var completedContributorRequests = 0;

var onCompleteRepos = function(response) {
if (response.status === 200) {
var repos = response.responseJSON;
repos = repos.sort(function(a, b) {
return b.watchers_count - a.watchers_count;
});

for (var i = 0, l = repos.length; i < l; i++) {
// Don't include forks
if (repos[i].fork) {
continue;
}

totalRepos++;

// Fire off ajax request to get contributors
ajaxOptions.complete = onCompleteContributors;
jQuery.ajax(repos[i].contributors_url, ajaxOptions);
var repos = response;
repos = repos.sort(function(a, b) {
return b.watchers_count - a.watchers_count;
});

var $template = $("section.github .repos .repos-container .repo-template").clone().removeClass("repo-template");
for (var i = 0, l = repos.length; i < l; i++) {
// Don't include forks
if (repos[i].fork) {
continue;
}

if (i === 0) {
$template.addClass("first");
}
totalRepos++;

// Fire off ajax request to get contributors
$.ajax({
url: repos[i].contributors_url + "?client_id=bda58293b5d9ede74ab7&client_secret=62cfb784097a180bcb5169d9528a23538340ecf0",
dataType: 'json',
crossDomain: true,
timeout: 5000,
cache: false,
data: {
per_page: 100
},
success: onCompleteContributors
});

$template.find("p.name a").attr("href", repos[i].html_url).html(repos[i].name);
$template.find("p.description").html(repos[i].description);
$template.find("p.lang").html(repos[i].language);
$template.find("p.stars span").html(repos[i].watchers_count);
var $template = $("section.github .repos .repos-container .repo-template").clone().removeClass("repo-template");

$("section.github .repos .repos-container").append($template);
if (i === 0) {
$template.addClass("first");
}

$("section.github .repos .loading").css("display", "none");
$("section.github .repos .counts h1").html(totalRepos);
$template.find("p.name a").attr("href", repos[i].html_url).html(repos[i].name);
$template.find("p.description").html(repos[i].description);
$template.find("p.lang").html(repos[i].language);
$template.find("p.stars span").html(repos[i].watchers_count);

$("section.github .repos .repos-container").append($template);
}

$("section.github .repos .loading").css("display", "none");
$("section.github .repos .counts h1").html(totalRepos);
};

var onCompleteContributors = function(response) {
completedContributorRequests++;

if (response.status === 200) {
var contributors = response.responseJSON;
var contributors = response;

for (var i = 0; i < contributors.length; i++) {
// Don't add the same user more than once
if ($("section.github .contributors .contributors-container #" + contributors[i].id).length === 0) {
var userId = contributors[i].id;
var login = contributors[i].login;
var url = contributors[i].html_url;
var avatarUrl = contributors[i].avatar_url;
for (var i = 0; i < contributors.length; i++) {
// Don't add the same user more than once
if ($("section.github .contributors .contributors-container #" + contributors[i].id).length === 0) {
var userId = contributors[i].id;
var login = contributors[i].login;
var url = contributors[i].html_url;
var avatarUrl = contributors[i].avatar_url;

var $template = $("section.github .contributors .contributors-container .contributor-template").clone().removeClass("contributor-template");
var $template = $("section.github .contributors .contributors-container .contributor-template").clone().removeClass("contributor-template");

$template.attr("id", userId);
$template.find("a").attr("href", url);
$template.find("img.avatar").attr("src", avatarUrl).attr("alt", login);
$template.find("p.user").html(login);
$template.attr("id", userId);
$template.find("a").attr("href", url);
$template.find("img.avatar").attr("src", avatarUrl).attr("alt", login);
$template.find("p.user").html(login);

$("section.github .contributors .contributors-container").append($template);
}
$("section.github .contributors .contributors-container").append($template);
}
}

Expand All @@ -259,18 +264,17 @@
}
};

var ajaxOptions = {
crossDomain: true,
$.ajax({
url: "https://api.github.com/orgs/balanced/repos?client_id=bda58293b5d9ede74ab7&client_secret=62cfb784097a180bcb5169d9528a23538340ecf0",
dataType: 'json',
crossDomain: true,
timeout: 5000,
cache: false,
data: {
per_page: 100
}
};

ajaxOptions.complete = onCompleteRepos;
jQuery.ajax("https://api.github.com/orgs/balanced/repos?client_id=bda58293b5d9ede74ab7&client_secret=62cfb784097a180bcb5169d9528a23538340ecf0", ajaxOptions);
},
success: onCompleteRepos
});
},
payouts: function() {
animateInView(".folded-box", "slide-up");
Expand Down
8 changes: 4 additions & 4 deletions templates/open.html
Expand Up @@ -311,10 +311,10 @@ <h3>{{page.metadata.github.publicRepos}}</h3>
</div>
<div class="head">
<div class="row">
<div class="offset1 col-md-4">
<div class="col-md-offset-1 col-md-4">
<p class="project">{{page.metadata.github.project}}</p>
</div>
<div class="col-md-8">
<div class="col-md-6 pull-right">
<p class="text-right view-all">
<a href="https://github.com/balanced">{{page.metadata.github.viewAll}}</a>
</p>
Expand All @@ -328,7 +328,7 @@ <h3>{{page.metadata.github.publicRepos}}</h3>
<p class="name"><a href="#"></a></p>
<p class="description"></p>
</div>
<div class="span3">
<div class="col-md-2">
<p class="lang text-right"></p>
<p class="stars text-right"><i class="icon-star"></i><span></span></p>
</div>
Expand All @@ -337,7 +337,7 @@ <h3>{{page.metadata.github.publicRepos}}</h3>
</div>
<div class="foot med-bottom-margin ">
<div class="row">
<div class="offset5 col-md-8">
<div class="col-md-12">
<p class="text-right view-all">
<a href="https://github.com/balanced">{{page.metadata.github.viewAll}}</a>
</p>
Expand Down

0 comments on commit 50b744c

Please sign in to comment.