From 3a6fc4ed387c0b7f1e060dcd348defc8aa1b2be7 Mon Sep 17 00:00:00 2001 From: A T Date: Fri, 9 Aug 2019 12:18:15 +0200 Subject: [PATCH 01/12] select --- .vscode/settings.json | 3 ++- homework/index.html | 46 +++++++++++++++++++++++++------------------ homework/index.js | 17 +++++++++++++--- homework/style.css | 13 ++++++++++++ 4 files changed, 56 insertions(+), 23 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f7a55df12..c2e11f417 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,6 @@ "editor.tabSize": 2, "cSpell.words": [ "tabindex" - ] + ], + "workbench.colorCustomizations": {} } \ No newline at end of file diff --git a/homework/index.html b/homework/index.html index 9c8f80c1a..e0551797c 100644 --- a/homework/index.html +++ b/homework/index.html @@ -1,23 +1,31 @@ + + + + + + + + + + HYF-GITHUB + + + - - - - - - - - - - HYF-GITHUB - - - + + - -
- - - - \ No newline at end of file + + + + diff --git a/homework/index.js b/homework/index.js index d3a97645e..f62c0fe98 100644 --- a/homework/index.js +++ b/homework/index.js @@ -31,13 +31,24 @@ } function main(url) { - fetchJSON(url, (err, data) => { + fetchJSON(url, (err, repositories) => { const root = document.getElementById('root'); + console.log(err, repositories); if (err) { createAndAppend('div', root, { text: err.message, class: 'alert-error' }); - } else { - createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) }); + const div = document.createElement('div'); + div.textContent = err.message; + div.setAttribute('class', 'alert-error'); + root.appendChild(div); + return; } + createAndAppend('pre', root, { text: JSON.stringify(repositories, null, 2) }); + + /* //getting the names + repositories.forEach(repo => { + console.log(repo.name); + createAndAppend('div', root, { text: repo.name }); + }); */ }); } diff --git a/homework/style.css b/homework/style.css index a8985a8a5..acd2ce189 100644 --- a/homework/style.css +++ b/homework/style.css @@ -1,3 +1,16 @@ +body { + background-color: seagreen; + color: whitesmoke; + font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; + font-size: 1rem; + padding-right: 10px; +} + .alert-error { color: red; +} + +select { + font-size: .9rem; + padding: 2px 5px; } \ No newline at end of file From 195e99e6dd0341b75fdfffb9ab6a75f5b8ce081b Mon Sep 17 00:00:00 2001 From: A T Date: Fri, 9 Aug 2019 12:56:07 +0200 Subject: [PATCH 02/12] some select css --- homework/index.html | 16 ++++++++++------ homework/index.js | 4 ++-- homework/style.css | 14 +++++++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/homework/index.html b/homework/index.html index e0551797c..27b55263e 100644 --- a/homework/index.html +++ b/homework/index.html @@ -16,16 +16,20 @@ - - - - - +
+ +
+ + + + +

The repositories will be displayed here

+ diff --git a/homework/index.js b/homework/index.js index f62c0fe98..99d06a5fd 100644 --- a/homework/index.js +++ b/homework/index.js @@ -47,8 +47,8 @@ /* //getting the names repositories.forEach(repo => { console.log(repo.name); - createAndAppend('div', root, { text: repo.name }); - }); */ + createAndAppend('div', root, { text: repo.name });*/ + }); }); } diff --git a/homework/style.css b/homework/style.css index acd2ce189..0ba81fb3a 100644 --- a/homework/style.css +++ b/homework/style.css @@ -1,6 +1,12 @@ +header { + background-color: rgb(116, 56, 13); + color: white; + padding: 1rem; +} + body { - background-color: seagreen; - color: whitesmoke; + background-color:rgb(197, 197, 197); + color: black; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size: 1rem; padding-right: 10px; @@ -12,5 +18,7 @@ body { select { font-size: .9rem; - padding: 2px 5px; + padding: 4px 25px; + margin-left: 25px; + border-radius: 20px; } \ No newline at end of file From e3b7592645c178dfc2b3fd776e117d0da342941b Mon Sep 17 00:00:00 2001 From: A T Date: Fri, 16 Aug 2019 16:49:21 +0200 Subject: [PATCH 03/12] starting to make it work with js! --- homework/index.html | 19 +++++++++------- homework/index.js | 55 ++++++++++++++++++++++++++++++++------------- homework/style.css | 18 ++++++++++++++- 3 files changed, 68 insertions(+), 24 deletions(-) diff --git a/homework/index.html b/homework/index.html index 27b55263e..0acb52925 100644 --- a/homework/index.html +++ b/homework/index.html @@ -17,19 +17,22 @@
- - + etc + -->
- + -

The repositories will be displayed here

- + +
+
+ + + diff --git a/homework/index.js b/homework/index.js index 99d06a5fd..fb1ba1e07 100644 --- a/homework/index.js +++ b/homework/index.js @@ -31,24 +31,46 @@ } function main(url) { - fetchJSON(url, (err, repositories) => { - const root = document.getElementById('root'); - console.log(err, repositories); + fetchJSON(url, (err, data) => { + const root = document.getElementById('root','forRepoBlock', 'forContributorsBlock'); if (err) { createAndAppend('div', root, { text: err.message, class: 'alert-error' }); - const div = document.createElement('div'); - div.textContent = err.message; - div.setAttribute('class', 'alert-error'); - root.appendChild(div); - return; - } - createAndAppend('pre', root, { text: JSON.stringify(repositories, null, 2) }); + } else { + //createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) }); + const select = createAndAppend('select', root); + createAndAppend('option', select, { text: 'Click here to choose a Repository' }); + data.forEach(repo => { + const name = repo.name; + createAndAppend('option', select, { text: name }); + }); + + const repoInfo = createAndAppend('div', forRepoBlock); + const contribs = createAndAppend('div', forContributorsBlock); + select.addEventListener('change', evt => { + const selectedRepo = evt.target.value; + const repo = data.filter(r => r.name == selectedRepo)[0]; + console.log(repo); + repoInfo.innerHTML = ''; + contribs.innerHTML = ''; + + const addInfo = (label, value) => { + const container = createAndAppend('div', repoInfo); + createAndAppend('span', container, { text: label }); + createAndAppend('span', container, { text: value }); + }; + addInfo('Name: ', repo.name); + addInfo('Desciption: ', repo.description); + addInfo('Number of forks: ', repo.forks); + addInfo('Updated: ', repo.updated_at); - /* //getting the names - repositories.forEach(repo => { - console.log(repo.name); - createAndAppend('div', root, { text: repo.name });*/ - }); + const contribsUrl = repo.contributors_url; + fetchJSON(contribsUrl, (err, contribData) => { + contribData.forEach(contributor => { + createAndAppend('div', contribs, { text: contributor.login }); + }); + }); + }); + } }); } @@ -56,3 +78,6 @@ window.onload = () => main(HYF_REPOS_URL); } + + + diff --git a/homework/style.css b/homework/style.css index 0ba81fb3a..c8ef0bf11 100644 --- a/homework/style.css +++ b/homework/style.css @@ -9,14 +9,30 @@ body { color: black; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size: 1rem; - padding-right: 10px; + padding-right: 1px; } .alert-error { color: red; } + select { + font-size: .9rem; + padding: 4px 25px; + margin-left: 10px; + border-radius: 20px; +} + +#forRepoBlock { + color: purple; + font-size: .9rem; + padding: 1px 25px; + margin-left: 2px; + border-radius: 20px; +} +#forContributorsBlock { + color: brown; font-size: .9rem; padding: 4px 25px; margin-left: 25px; From e8f9896e1bf69a6bb24c355dd9948800d909e762 Mon Sep 17 00:00:00 2001 From: AaaaT Date: Mon, 19 Aug 2019 09:20:40 +0200 Subject: [PATCH 04/12] Create README.md --- homework/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 homework/README.md diff --git a/homework/README.md b/homework/README.md new file mode 100644 index 000000000..ca3851b22 --- /dev/null +++ b/homework/README.md @@ -0,0 +1,2 @@ +The visual result-----> +https://aaaat.github.io/JavaScript3/homework/ From c0b51651e83f6b1bbb5b0ebbab0bff8742d38ce2 Mon Sep 17 00:00:00 2001 From: A T Date: Tue, 20 Aug 2019 16:21:03 +0200 Subject: [PATCH 05/12] contributors info and more css --- homework/index.html | 19 ++++++++++++++----- homework/index.js | 8 ++++++-- homework/style.css | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/homework/index.html b/homework/index.html index 0acb52925..a5d5e7d2a 100644 --- a/homework/index.html +++ b/homework/index.html @@ -16,8 +16,11 @@ +
-
+
+ +
-
-
+
+

Repositories

+ +

Contributors

+
+
+ +
+ + diff --git a/homework/index.js b/homework/index.js index fb1ba1e07..b12b7b26e 100644 --- a/homework/index.js +++ b/homework/index.js @@ -32,7 +32,7 @@ function main(url) { fetchJSON(url, (err, data) => { - const root = document.getElementById('root','forRepoBlock', 'forContributorsBlock'); + const root = document.getElementById('root'); if (err) { createAndAppend('div', root, { text: err.message, class: 'alert-error' }); } else { @@ -66,8 +66,12 @@ const contribsUrl = repo.contributors_url; fetchJSON(contribsUrl, (err, contribData) => { contribData.forEach(contributor => { - createAndAppend('div', contribs, { text: contributor.login }); + createAndAppend('p', contribs, { text: ':' }); + createAndAppend('img', contribs, { src: contributor.avatar_url, height: 30, class: 'picture' }); + createAndAppend('div', contribs, { text: contributor.login, class: 'contributorName' }); + createAndAppend('div', contribs, { text: contributor.contributions, class: 'numberContributions' }); }); + }); }); } diff --git a/homework/style.css b/homework/style.css index c8ef0bf11..2882cef62 100644 --- a/homework/style.css +++ b/homework/style.css @@ -24,17 +24,48 @@ select { border-radius: 20px; } +#container { + display: flex; + flex-direction: row; + align-items: flex-start; + margin: 1 rem; +} + #forRepoBlock { color: purple; font-size: .9rem; - padding: 1px 25px; + padding: 4px 4px; margin-left: 2px; - border-radius: 20px; + + float: center; + margin-top: 1rem; + width: 60%; + + border-style: bold; + border-radius: 0%; + padding: 10px; + background:rgb(216, 142, 188); + opacity: 0.8; + + box-shadow: 10px 5px 5px grey; } #forContributorsBlock { - color: brown; + color: rgb(112, 13, 13); font-size: .9rem; - padding: 4px 25px; - margin-left: 25px; - border-radius: 20px; + padding: 4px 4px; + margin-left: 2px; + + display: flex; + flex-direction: row; + + margin: 1rem; + width: 40%; + + border-style: bold; + border-radius: 0%; + padding: 10px; + background:rgb(155, 118, 92); + opacity: 0.8; + + box-shadow: 10px 5px 5px grey; } \ No newline at end of file From e5b24d05abe5505f27a4c653ac3a6fdb4a16760c Mon Sep 17 00:00:00 2001 From: AaaaT Date: Wed, 21 Aug 2019 15:08:31 +0200 Subject: [PATCH 06/12] Update README.md --- Week2/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Week2/README.md b/Week2/README.md index e55018f74..b49e3d79e 100644 --- a/Week2/README.md +++ b/Week2/README.md @@ -18,7 +18,11 @@ Here are resources that we like you to read as a preparation for the second lect ### Fundamentals - [Event Loop](../../../../fundamentals/blob/master/fundamentals/event_loop.md) +WORKING LINK: +https://github.com/foocoding/fundamentals/blob/master/fundamentals/event_loop.md - [Promises](../../../../fundamentals/blob/master/fundamentals/promises.md) +WORKING LINK: +https://github.com/foocoding/fundamentals/blob/master/fundamentals/promises.md _Please go through the material and come to class prepared!_ From caa6a5ff05b1bcaade04f11e35bd334ed21caa50 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Aug 2019 15:10:36 +0200 Subject: [PATCH 07/12] some tinkering --- homework/index.html | 18 ++++++++++-------- homework/index.js | 3 ++- homework/style.css | 21 +++++++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/homework/index.html b/homework/index.html index a5d5e7d2a..c4a7769bd 100644 --- a/homework/index.html +++ b/homework/index.html @@ -21,11 +21,7 @@
- +
@@ -33,13 +29,19 @@

Repositories

-

Contributors

+
+

Picture

+

Name

+

Number of contributions

+ + +
+ diff --git a/homework/index.js b/homework/index.js index b12b7b26e..335090591 100644 --- a/homework/index.js +++ b/homework/index.js @@ -39,6 +39,7 @@ //createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) }); const select = createAndAppend('select', root); createAndAppend('option', select, { text: 'Click here to choose a Repository' }); + data.forEach(repo => { const name = repo.name; createAndAppend('option', select, { text: name }); @@ -66,7 +67,7 @@ const contribsUrl = repo.contributors_url; fetchJSON(contribsUrl, (err, contribData) => { contribData.forEach(contributor => { - createAndAppend('p', contribs, { text: ':' }); + createAndAppend('p', contribs, { text: '' }); createAndAppend('img', contribs, { src: contributor.avatar_url, height: 30, class: 'picture' }); createAndAppend('div', contribs, { text: contributor.login, class: 'contributorName' }); createAndAppend('div', contribs, { text: contributor.contributions, class: 'numberContributions' }); diff --git a/homework/style.css b/homework/style.css index 2882cef62..8ad6007cf 100644 --- a/homework/style.css +++ b/homework/style.css @@ -28,11 +28,13 @@ select { display: flex; flex-direction: row; align-items: flex-start; + flex-flow: row nowrap; + margin: 1 rem; } #forRepoBlock { - color: purple; + color: rgb(43, 0, 43); font-size: .9rem; padding: 4px 4px; margin-left: 2px; @@ -44,28 +46,31 @@ select { border-style: bold; border-radius: 0%; padding: 10px; - background:rgb(216, 142, 188); - opacity: 0.8; + background:rgba(230, 178, 210, 0.5); + opacity: 1; box-shadow: 10px 5px 5px grey; } #forContributorsBlock { - color: rgb(112, 13, 13); + color: rgb(48, 0, 20); font-size: .9rem; padding: 4px 4px; margin-left: 2px; - display: flex; - flex-direction: row; + display: grid; + grid-template-columns: 33.3333% 33.3333% 33.3333%; + grid-template-rows: auto; + margin: 1rem; width: 40%; + border-style: bold; border-radius: 0%; padding: 10px; - background:rgb(155, 118, 92); - opacity: 0.8; + background:rgba(231, 185, 152, 0.5); + opacity: 1; box-shadow: 10px 5px 5px grey; } \ No newline at end of file From c135c93747005874cf9e948591acf1e16ea27ec9 Mon Sep 17 00:00:00 2001 From: AaaaT Date: Mon, 26 Aug 2019 22:42:40 +0200 Subject: [PATCH 08/12] Update index.js --- homework/index.js | 84 ++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/homework/index.js b/homework/index.js index 335090591..ba5041b59 100644 --- a/homework/index.js +++ b/homework/index.js @@ -1,21 +1,27 @@ 'use strict'; { - function fetchJSON(url, cb) { - const xhr = new XMLHttpRequest(); - xhr.open('GET', url); - xhr.responseType = 'json'; - xhr.onload = () => { - if (xhr.status < 400) { - cb(null, xhr.response); - } else { - cb(new Error(`Network error: ${xhr.status} - ${xhr.statusText}`)); - } - }; - xhr.onerror = () => cb(new Error('Network request failed')); - xhr.send(); + function fetchJSON(url) { + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url); + xhr.responseType = 'json'; + xhr.onload = () => { + if (xhr.status < 400) { + resolve(xhr.response); + } else { + reject(new Error(`Network error: ${xhr.status} - ${xhr.statusText}`)); + } + }; + xhr.onerror = () => { + reject(new Error('Network request failed')); + }; + xhr.send(); + }) + } + function createAndAppend(name, parent, options = {}) { const elem = document.createElement(name); parent.appendChild(elem); @@ -30,17 +36,14 @@ return elem; } + function main(url) { - fetchJSON(url, (err, data) => { - const root = document.getElementById('root'); - if (err) { - createAndAppend('div', root, { text: err.message, class: 'alert-error' }); - } else { - //createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) }); + fetchJSON(url) + .then(repositoryData => { const select = createAndAppend('select', root); createAndAppend('option', select, { text: 'Click here to choose a Repository' }); - - data.forEach(repo => { + + repositoryData.forEach(repo => { const name = repo.name; createAndAppend('option', select, { text: name }); }); @@ -49,7 +52,7 @@ const contribs = createAndAppend('div', forContributorsBlock); select.addEventListener('change', evt => { const selectedRepo = evt.target.value; - const repo = data.filter(r => r.name == selectedRepo)[0]; + const repo = repositoryData.filter(r => r.name == selectedRepo)[0]; console.log(repo); repoInfo.innerHTML = ''; contribs.innerHTML = ''; @@ -62,27 +65,34 @@ addInfo('Name: ', repo.name); addInfo('Desciption: ', repo.description); addInfo('Number of forks: ', repo.forks); - addInfo('Updated: ', repo.updated_at); + addInfo('Updated: ', new Date(repo.updated_at)); const contribsUrl = repo.contributors_url; - fetchJSON(contribsUrl, (err, contribData) => { - contribData.forEach(contributor => { - createAndAppend('p', contribs, { text: '' }); - createAndAppend('img', contribs, { src: contributor.avatar_url, height: 30, class: 'picture' }); - createAndAppend('div', contribs, { text: contributor.login, class: 'contributorName' }); - createAndAppend('div', contribs, { text: contributor.contributions, class: 'numberContributions' }); - }); - }); + fetchJSON(contribsUrl) + .then((contribData) => { + contribData.forEach(contributor => { + // createAndAppend('p', contribs, { text: 'hej'}); + createAndAppend('img', contribs, { src: contributor.avatar_url, height: 40, class: 'picture' }); + createAndAppend('span', contribs, { text: contributor.login, class: 'contributorName' }); + createAndAppend('span', contribs, { text: contributor.contributions, class: 'numberContributions'}); + createAndAppend('div', contribs, { text: '\n'}); + }); + }) + .catch((err) => { + const root = document.getElementById('root'); + createAndAppend('div', root, { text: err.message, class: 'alert-error' }); + }) }); - } - }); - } + }) + .catch((err) => { + const root = document.getElementById('root'); + createAndAppend('div', root, { text: err.message, class: 'alert-error' }); + }) + } + const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100'; window.onload = () => main(HYF_REPOS_URL); } - - - From e5a0358a3b054e6f78c819c31e85c8978be63b7b Mon Sep 17 00:00:00 2001 From: AaaaT Date: Mon, 26 Aug 2019 22:43:43 +0200 Subject: [PATCH 09/12] Update index.html --- homework/index.html | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/homework/index.html b/homework/index.html index c4a7769bd..236258e9f 100644 --- a/homework/index.html +++ b/homework/index.html @@ -25,25 +25,16 @@ - +
-

Repositories

+

Repositories

+
-

Picture

-

Name

-

Number of contributions

- - - -
+

Contributions

+
- - - From c6e4d27cf70ac8522407f773884b778bbea1a9b4 Mon Sep 17 00:00:00 2001 From: AaaaT Date: Mon, 26 Aug 2019 22:44:06 +0200 Subject: [PATCH 10/12] Update style.css --- homework/style.css | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homework/style.css b/homework/style.css index 8ad6007cf..52c11e041 100644 --- a/homework/style.css +++ b/homework/style.css @@ -28,7 +28,6 @@ select { display: flex; flex-direction: row; align-items: flex-start; - flex-flow: row nowrap; margin: 1 rem; } @@ -38,8 +37,6 @@ select { font-size: .9rem; padding: 4px 4px; margin-left: 2px; - - float: center; margin-top: 1rem; width: 60%; @@ -73,4 +70,9 @@ select { opacity: 1; box-shadow: 10px 5px 5px grey; -} \ No newline at end of file +} +span { + display: row; + font-size: .8rem; + margin: 3%; +} From 569d234be1d2f182d6ec27e36707181f843811ec Mon Sep 17 00:00:00 2001 From: AaaaT Date: Fri, 30 Aug 2019 19:52:48 +0200 Subject: [PATCH 11/12] Update index.js --- homework/index.js | 89 +++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/homework/index.js b/homework/index.js index ba5041b59..fdf831137 100644 --- a/homework/index.js +++ b/homework/index.js @@ -36,63 +36,84 @@ return elem; } + function compare(a, b) { + if (a.nameb.name){ + return 1 + } + return 0; + } function main(url) { fetchJSON(url) .then(repositoryData => { const select = createAndAppend('select', root); - createAndAppend('option', select, { text: 'Click here to choose a Repository' }); + // createAndAppend('option', select, { text: 'Click here to choose a Repository' }); - repositoryData.forEach(repo => { + let alphabeticalSorting = repositoryData.sort(compare); + alphabeticalSorting.forEach(repo => { const name = repo.name; createAndAppend('option', select, { text: name }); }); const repoInfo = createAndAppend('div', forRepoBlock); const contribs = createAndAppend('div', forContributorsBlock); + select.addEventListener('change', evt => { const selectedRepo = evt.target.value; - const repo = repositoryData.filter(r => r.name == selectedRepo)[0]; - console.log(repo); - repoInfo.innerHTML = ''; - contribs.innerHTML = ''; - - const addInfo = (label, value) => { - const container = createAndAppend('div', repoInfo); - createAndAppend('span', container, { text: label }); - createAndAppend('span', container, { text: value }); - }; - addInfo('Name: ', repo.name); - addInfo('Desciption: ', repo.description); - addInfo('Number of forks: ', repo.forks); - addInfo('Updated: ', new Date(repo.updated_at)); - - const contribsUrl = repo.contributors_url; - - fetchJSON(contribsUrl) - .then((contribData) => { - contribData.forEach(contributor => { - // createAndAppend('p', contribs, { text: 'hej'}); - createAndAppend('img', contribs, { src: contributor.avatar_url, height: 40, class: 'picture' }); - createAndAppend('span', contribs, { text: contributor.login, class: 'contributorName' }); - createAndAppend('span', contribs, { text: contributor.contributions, class: 'numberContributions'}); - createAndAppend('div', contribs, { text: '\n'}); - }); - }) - .catch((err) => { - const root = document.getElementById('root'); - createAndAppend('div', root, { text: err.message, class: 'alert-error' }); - }) + const repo = alphabeticalSorting.filter(r => r.name == selectedRepo)[0]; + getRepoData(repo, repoInfo, contribs); }); + + let firstRepo = alphabeticalSorting[0] + getRepoData(firstRepo, repoInfo, contribs); }) .catch((err) => { const root = document.getElementById('root'); createAndAppend('div', root, { text: err.message, class: 'alert-error' }); }) } - + + function getRepoData(repo, repoInfo, contribs) { + + // console.log(repo); + repoInfo.innerHTML = ''; + contribs.innerHTML = ''; + + const addInfo = (label, value) => { + const container = createAndAppend('div', repoInfo); + createAndAppend('span', container, { text: label }); + createAndAppend('span', container, { text: value }); + }; + addInfo('Name: ', repo.name); + addInfo('Desciption: ', repo.description); + addInfo('Number of forks: ', repo.forks); + addInfo('Updated: ', new Date(repo.updated_at)); + + const contribsUrl = repo.contributors_url; + + fetchJSON(contribsUrl) + .then((contribData) => { + contribData.forEach(contributor => { + // createAndAppend('p', contribs, { text: 'hej'}); + createAndAppend('img', contribs, { src: contributor.avatar_url, height: 40, class: 'picture' }); + createAndAppend('span', contribs, { text: contributor.login, class: 'contributorName' }); + createAndAppend('span', contribs, { text: contributor.contributions, class: 'numberContributions'}); + createAndAppend('div', contribs, { text: '\n'}); + }); + }) + .catch((err) => { + const root = document.getElementById('root'); + createAndAppend('div', root, { text: err.message, class: 'alert-error' }); + }) + + } const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100'; window.onload = () => main(HYF_REPOS_URL); } + + From b192664576646ce46fc23b10b374423d99f2098f Mon Sep 17 00:00:00 2001 From: AaaaT Date: Mon, 9 Sep 2019 22:54:12 +0200 Subject: [PATCH 12/12] Update index.html --- homework/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homework/index.html b/homework/index.html index 236258e9f..efce87c6f 100644 --- a/homework/index.html +++ b/homework/index.html @@ -19,7 +19,7 @@
- +