From 7cbb6d2c746124efb58d02f22194a041fae0d76c Mon Sep 17 00:00:00 2001 From: sena <48647939+msenaavci@users.noreply.github.com> Date: Sun, 2 Jun 2019 05:21:41 +0200 Subject: [PATCH 1/3] Update index.js --- homework/index.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/homework/index.js b/homework/index.js index d3a97645e..8835bfe45 100644 --- a/homework/index.js +++ b/homework/index.js @@ -37,6 +37,73 @@ createAndAppend('div', root, { text: err.message, class: 'alert-error' }); } else { createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) }); + const h1 = createAndAppend('h1', root, { + class: 'h1', + text: 'HYF Repositories', + }); + const select = createAndAppend('select', h1, { + class: 'selector', + }); + select.innerHTML = data.sort(function(a, b) { + a.name.localeCompare(b.name); + }); + for (let i = 0; i < data.length; i++) { + createAndAppend('option', select, { + text: data[i].name, + value: i, + }); + } + const createRepo = repoI => { + const container = createAndAppend('div', root); + const leftDiv = createAndAppend('div', container, { + id: 'left-div', + }); + const rightDiv = createAndAppend('div', container, { + id: 'right-div', + }); + const table1 = createAndAppend('table', leftDiv); + const trL1 = createAndAppend('tr', table1); + const link = createAndAppend('td', trL1, { + text: 'Repository:', + }); + createAndAppend('a', link, { + href: data[repoI].html_url, + target: '_blank', + text: data[repoI].name, + }); + const trL2 = createAndAppend('tr', table1); + const descriprion = createAndAppend('td', trL2, { + text: `Description: ${data[repoI].description}`, + }); + const trL3 = createAndAppend('tr', table1); + const forks = createAndAppend('td', trL3, { + text: `Forks: ${data[repoI].forks}`, + }); + const trL4 = createAndAppend('tr', table); + const update = createAndAppend('td', trL4, { + text: `Updated: ${data[repoI].updated_at}`, + }); + }; + const constributors = () => { + fetch(data[i].contributors_url) + .then(response => response.json()) + .then(data => { + const ul = createAndAppend('ul', rightDiv); + const li = createAndAppend('li', ul, { + id: 'constributor_item', + }); + createAndAppend('img', li, { + src: data[i].avatar_url, + height: '52px', + }); + const divConst = createAndAppend('div', li, { + text: data[i].login, + }); + createAndAppend('div', li, { + text: `${dataCont[i].contributions}`, + }); + }); + }; } }); } From 4fd6be898bd8949015b03bd0eec39e9f9c115eab Mon Sep 17 00:00:00 2001 From: sena <48647939+msenaavci@users.noreply.github.com> Date: Sun, 2 Jun 2019 05:22:30 +0200 Subject: [PATCH 2/3] Update index.html --- homework/index.html | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/homework/index.html b/homework/index.html index 9c8f80c1a..428114250 100644 --- a/homework/index.html +++ b/homework/index.html @@ -16,8 +16,28 @@ -
- +

HYF Repository

+ + +
+
+
+
+ - \ No newline at end of file + From f26ee9f64ccfadb750f448c6a5d734c82cfee60f Mon Sep 17 00:00:00 2001 From: sena <48647939+msenaavci@users.noreply.github.com> Date: Sun, 9 Jun 2019 10:16:50 +0200 Subject: [PATCH 3/3] Update index.html --- homework/index.html | 149 +++++++++++++++++++++++++++++++++----------- 1 file changed, 114 insertions(+), 35 deletions(-) diff --git a/homework/index.html b/homework/index.html index 428114250..ec66a3788 100644 --- a/homework/index.html +++ b/homework/index.html @@ -1,43 +1,122 @@ + + + + + + + + + + + HYF-GITHUB + + + - - - - - - - - - - HYF-GITHUB - - - - - -

HYF Repository

+ + + +
+
+ + + + + + + + + + + + +
+ +
+ +
+
-
-
-
-
- - + document.getElementById('Repository').innerHTML = `Repository: ${data[i].name}` + document.getElementById('Description').innerHTML = `Description: ${data[i].description}`; + document.getElementById('Forks').innerHTML = `Forks: ${data[i].forks}`; + document.getElementById('Updated').innerHTML = `Updated: ${data[i].updated_at}`; + }) + } +} +xhttp.send(); +const rightDiv = document.getElementById('right-div'); + const contHeader = document.createElement('p'); + contHeader.innerHTML = "Contributors"; + const contList = document.createElement('ul'); + rightDiv.appendChild(contHeader); + rightDiv.appendChild(contList); + const url = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100'; +const contributor = (c) => { + fetch(url) + .then(response => response.json()) + .then(data => { + data.forEach(rec => { + fetch(rec.contributors_url) + .then(response => response.json()) + .then(data => { + data.forEach(rec => { + let img = document.createElement('img'); + img.src = rec.avatar_url; + img.height = "48"; + let div =document.createElement('div') + let logIn = rec.login; + div.innerHTML += logIn; + let link = "https://github.com/" + logIn; + let aLink = " " +logIn + ""; + let span = document.createElement('span'); + span.innerHTML += rec.contributions; + const li = document.createElement('li'); + contList.appendChild(li); + li.appendChild(img); + li.appendChild(span); + li.appendChild(div); + div.appendChild(span); + li.innerHTML += img + aLink + span; + }) + }) + }) +}) + .catch(function(error) { + console.log(JSON.stringify(error)); + }) + +} +contributor(url); + + + +