|
37 | 37 | createAndAppend('div', root, { text: err.message, class: 'alert-error' });
|
38 | 38 | } else {
|
39 | 39 | createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) });
|
| 40 | + const h1 = createAndAppend('h1', root, { |
| 41 | + class: 'h1', |
| 42 | + text: 'HYF Repositories', |
| 43 | + }); |
| 44 | + const select = createAndAppend('select', h1, { |
| 45 | + class: 'selector', |
| 46 | + }); |
| 47 | + select.innerHTML = data.sort(function(a, b) { |
| 48 | + a.name.localeCompare(b.name); |
| 49 | + }); |
| 50 | + for (let i = 0; i < data.length; i++) { |
| 51 | + createAndAppend('option', select, { |
| 52 | + text: data[i].name, |
| 53 | + value: i, |
| 54 | + }); |
| 55 | + } |
| 56 | + const createRepo = repoI => { |
| 57 | + const container = createAndAppend('div', root); |
| 58 | + const leftDiv = createAndAppend('div', container, { |
| 59 | + id: 'left-div', |
| 60 | + }); |
| 61 | + const rightDiv = createAndAppend('div', container, { |
| 62 | + id: 'right-div', |
| 63 | + }); |
| 64 | + const table1 = createAndAppend('table', leftDiv); |
| 65 | + const trL1 = createAndAppend('tr', table1); |
| 66 | + const link = createAndAppend('td', trL1, { |
| 67 | + text: 'Repository:', |
| 68 | + }); |
| 69 | + createAndAppend('a', link, { |
| 70 | + href: data[repoI].html_url, |
| 71 | + target: '_blank', |
| 72 | + text: data[repoI].name, |
| 73 | + }); |
| 74 | + const trL2 = createAndAppend('tr', table1); |
| 75 | + const descriprion = createAndAppend('td', trL2, { |
| 76 | + text: `Description: ${data[repoI].description}`, |
| 77 | + }); |
| 78 | + const trL3 = createAndAppend('tr', table1); |
| 79 | + const forks = createAndAppend('td', trL3, { |
| 80 | + text: `Forks: ${data[repoI].forks}`, |
| 81 | + }); |
| 82 | + const trL4 = createAndAppend('tr', table); |
| 83 | + const update = createAndAppend('td', trL4, { |
| 84 | + text: `Updated: ${data[repoI].updated_at}`, |
| 85 | + }); |
| 86 | + }; |
| 87 | + const constributors = () => { |
| 88 | + fetch(data[i].contributors_url) |
| 89 | + .then(response => response.json()) |
| 90 | + .then(data => { |
| 91 | + const ul = createAndAppend('ul', rightDiv); |
| 92 | + const li = createAndAppend('li', ul, { |
| 93 | + id: 'constributor_item', |
| 94 | + }); |
| 95 | + createAndAppend('img', li, { |
| 96 | + src: data[i].avatar_url, |
| 97 | + height: '52px', |
| 98 | + }); |
| 99 | + const divConst = createAndAppend('div', li, { |
| 100 | + text: data[i].login, |
| 101 | + }); |
| 102 | + createAndAppend('div', li, { |
| 103 | + text: `${dataCont[i].contributions}`, |
| 104 | + }); |
| 105 | + }); |
| 106 | + }; |
40 | 107 | }
|
41 | 108 | });
|
42 | 109 | }
|
|
0 commit comments