-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgetrepo.js
78 lines (64 loc) · 2.68 KB
/
getrepo.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function getRepo (repo) {
fetch("https://api.github.com/repos/" + repo).then(function (response) {
return response.json();
}).then(function (data) {
let name = data.name;
let owner = data.owner.login;
let owner_url = data.owner.html_url;
let repo_url = data.html_url;
let lang = data.language;
let forks = data.forks_count;
let stars = data.stargazers_count;
let desc = data.description;
let image = data.owner.avatar_url;
let frks = document.createElement("div");
frks.setAttribute("class", "forks icon");
frks.innerHTML = forks;
let strs = document.createElement("div");
strs.setAttribute("class", "stars icon");
strs.innerHTML = stars;
let lngs = document.createElement("div");
lngs.setAttribute("class", "lang icon");
lngs.innerHTML = lang;
let img = document.createElement("img");
img.setAttribute("src", image);
img.setAttribute("alt", owner);
let repo_link = document.createElement("a");
repo_link.setAttribute("href", repo_url);
repo_link.setAttribute("title", name);
repo_link.innerHTML = name;
let owner_link = document.createElement("a");
owner_link.setAttribute("href", owner_url);
owner_link.innerHTML = owner;
let rep = document.createElement("div");
rep.setAttribute("class", "repo")
rep.appendChild(repo_link);
let own = document.createElement("div");
own.setAttribute("class", "owner")
own.appendChild(owner_link);
let des = document.createElement("p");
if (desc != null && desc.length > 80) {
desc = desc.slice(0, 79) + "...";
}
des.innerHTML = desc;
let dta = document.createElement("div");
dta.setAttribute("class", "repodata");
dta.appendChild(lngs);
dta.appendChild(strs);
dta.appendChild(frks);
let the_repo = document.createElement("div");
the_repo.setAttribute("class", "repomain");
the_repo.appendChild(img);
the_repo.appendChild(rep);
the_repo.appendChild(own);
the_repo.appendChild(dta);
the_repo.appendChild(des);
document.getElementById('repo-container').appendChild(the_repo);
}).catch(error => {
console.log(error);
})
}
var repos_list = ["TheAlgorithms/C", "trekhleb/javascript-algorithms", "firstcontributions/first-contributions", "Project-Club-IIITS/club_portal", "adwait-thattey/Techfesia2019", "masterashu/TestCaseGenerator", "santoshvijapure/DS_with_hacktoberfest"];
for (i = 0; i < repos_list.length; i++) {
getRepo(repos_list[i]);
}