-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgithub.js
41 lines (35 loc) · 1.17 KB
/
github.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
32
33
34
35
36
37
38
39
40
41
// helper function
function compare(a, b) {
if (a.watchers > b.watchers) {
return -1;
};
if (a.watchers < b.watchers) {
return 1;
};
return 0;
};
function getReposList(user) {
apirepo = `https://api.github.com/users/LeiamNashRebirth/repos`;
html_table = `<table>`;
// $.getJSON is async and does not work here
$.ajax({
url: apirepo,
dataType: 'json',
async: false,
success: function(json) {
json.forEach(repo => {
if (repo.description == null) {
return; // this is equivalent of 'continue' for jQuery loop
}
html_table += `<tr><td><a href="${repo.html_url}" target="_blank">${repo.name}</a></td>`;
descr_txt = repo.description;
if (repo.stargazers_count > 0) {
descr_txt += ` (${repo.stargazers_count}⭐️ on <a href="${repo.html_url}" target="_blank">GitHub</a>)`;
}
html_table += `<td>${descr_txt}</td></tr>`;
})
}
})
return html_table + `</table>`;
}
const repos = getReposList("LeiamNashRebirth");