-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub_api.js
31 lines (31 loc) · 1.13 KB
/
github_api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
console.log("github_api loaded");
$(document).ready(function() {
users = []
repos = []
$(".ghbtn").each( function () {
var user = $(this).attr('user');
var repo = $(this).attr('repo');
repos.push(user + '/' + repo);
if (users.indexOf($(this).attr('user')) === -1) {
users.push($(this).attr('user'))
}
})
//console.log(1, repos)
for (var i = 0; i < repos.length; i++) {
//console.log("URL: "+"https://api.github.com/repos/" + repos[i]);
$.ajax({
type: "GET",
url: "https://api.github.com/repos/" + repos[i],
tryCount : 0,
retryLimit : 3,
async: true,
dataType: "json",
success: function (data) {
x = data.name;
//console.log("User/Repo: " + data.full_name + " Star: " + data.stargazers_count+ " Forks: "+data.forks_count + " Watchers: "+data.watchers_count);
$("div[repo='" + x + "']").find("span[class='star']").html(" "+data.stargazers_count);
$("div[repo='" + x + "']").find("span[class='fork']").html(" "+data.forks_count);
$("div[repo='" + x + "']").find("span[class='watchers']").html(" "+data.watchers_count);
}
})}
});