Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1c5003

Browse files
committed
final upload of homework changes
1 parent e1fef8b commit a1c5003

File tree

2 files changed

+62
-16
lines changed

2 files changed

+62
-16
lines changed

homework/src/index.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@
3030
});
3131
return elem;
3232
}
33-
33+
3434

3535
function main(url) {
3636
while (root.firstChild) {
3737
root.removeChild(root.firstChild);
3838
}
3939

4040
fetchJSON( HYF_REPOS_URL, (err, data) => {
41-
let newArray = [];
41+
if (err) {
42+
createAndAppend('div', root, { text: err.message, class: 'alert-error' });
43+
}
44+
const newArray = [];
4245
let forkArray = [];
4346
let languageArray = [];
4447
let descriptionArray = [];
@@ -89,26 +92,39 @@
8992
} //end removeNodes
9093

9194
selectList.onchange = function(selectedIndex){
92-
let RepoName = createAndAppend('li', ul, { text: "Repository: ", class: 'nameInContainer', function: removeNodes()});
93-
createAndAppend('a', RepoName, { text: newArray[this.selectedIndex], id: 'linkInContainer', target: "_blank", href: htmlArray[this.selectedIndex]});
95+
let repoName = createAndAppend('li', ul, { text: "Repository: ", class: 'nameInContainer', function: removeNodes()});
96+
createAndAppend('a', repoName, { text: newArray[this.selectedIndex], id: 'linkInContainer', target: "_blank", href: htmlArray[this.selectedIndex]});
9497
createAndAppend('li', ul, {text: "Description: " + descriptionArray[this.selectedIndex], class: 'descriptionInContainer'});
9598
createAndAppend('li', ul, { text: "Number of Forks: " + forkArray[this.selectedIndex], class: 'forksInContainer'});
9699
createAndAppend('li', ul, { text: "Language: " + languageArray[this.selectedIndex], class: 'languageInContainer'});
97100
createAndAppend('li', ul, {text: "Updated at: " + updatedAt[this.selectedIndex], id: 'updatedAtInContainer'})
98-
createAndAppend('li', contributorsUl, { text: contributorsArray[this.selectedIndex], class: 'contributorsInContainer'});
99-
}
100-
});
101+
fetchJSON('https://api.github.com/repos/HackYourFuture/' + newArray[this.selectedIndex] + '/contributors', (err, data) => {
102+
let getName = [];
103+
let getLink = [];
104+
let getBadge = [];
105+
for (let i = 0; i < data.length; i++){
106+
getName.push(data[i].avatar_url);
107+
getLink.push(data[i].html_url);
108+
getBadge.push(data[i].contributions);
109+
110+
let imageLink = createAndAppend('li', contributorsUl, {})
111+
let contributorName = createAndAppend('img', imageLink, {src: data[i].avatar_url});
112+
let contributorLink = createAndAppend('a', imageLink, {text: "click here to go to this contributor ", target: "_blank", href: data[i].html_url, id: 'link'});
113+
let contributorBadge = createAndAppend('li', imageLink, {text:"Contributions: " + data[i].contributions, class: 'badge'});
114+
} //end for
115+
data.forEach((repo) => {
116+
});//end for each
117+
}); //end fetchJSON
118+
119+
}// end of onchange
120+
}); //end of Fetch
121+
122+
101123

102-
/*
103-
fetchJSON( theContributors_URL, (err, data) => {
104-
let theContributorsUrl = [];
105-
for (let i = 0; i < data.length; i++){
106-
}
107-
});*/
124+
108125
}
109126

110127
const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
111-
const theContributors_URL = 'https://api.github.com/repos/HackYourFuture/contributors';
112128
window.onload = () => main(HYF_REPOS_URL);
113-
window.onload = () => main(theContributors_URL);
129+
114130
}

homework/src/style.css

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
.alert-error {
22
color: red;
3+
background-color:black;
4+
font-size: 4rem;
35
}
6+
img{
7+
border: 1px solid #ddd;
8+
border-radius: 4px;
9+
margin: 10px;
10+
padding: 25px;
11+
width: 150px;
12+
float: center;
13+
}
14+
415

516
.title{
617
color: white;
@@ -40,7 +51,9 @@
4051
margin: 1rem;
4152
border: 2px solid gray;
4253
background-color: darkslateblue;
43-
54+
}
55+
.card:hover {
56+
background-color: pink;
4457
}
4558

4659
.subtitle {
@@ -54,11 +67,28 @@
5467
background-color: white;
5568
color: black;
5669
}
70+
#mySelect:hover {
71+
background-color: pink;
72+
outline-color: white;
73+
}
74+
75+
#link {
76+
font-size: 20px;
77+
text-align: center;
78+
}
79+
.badge{
80+
font-size: 20px;
81+
text-align: center;
82+
}
5783

5884
#myUl{
5985
list-style-type: none;
6086
font-size: 1.5rem;
6187
}
88+
89+
#myUl:hover {
90+
background-color: pink;
91+
}
6292

6393
#contributorsUl{
6494
list-style-type: none;

0 commit comments

Comments
 (0)