|
36 | 36 |
|
37 | 37 | divElement.push('<div id="header">', `${'<h3>'} Contributions: ${'</h3>'} ${'</div>'}`);
|
38 | 38 |
|
39 |
| - // eslint-disable-next-line no-restricted-syntax |
40 |
| - for (const details of contribution) { |
| 39 | + contribution.forEach(details => { |
41 | 40 | divElement.push(
|
42 | 41 | '<ul>',
|
43 | 42 | `${'<li>'} ${'<img src="'}${details.avatar_url}" width="40" height="40">`,
|
|
46 | 45 | `<li>${details.contributions}</li>`,
|
47 | 46 | '</ul>',
|
48 | 47 | );
|
49 |
| - } |
| 48 | + }); |
50 | 49 |
|
51 | 50 | const htmlString = divElement.join('');
|
52 | 51 | document.getElementById('contributor-information').innerHTML = htmlString;
|
|
57 | 56 | function loadRepoDetails(repoInfo, optionValue) {
|
58 | 57 | const templateElement = [];
|
59 | 58 |
|
60 |
| - // eslint-disable-next-line no-restricted-syntax |
61 |
| - for (const repo in repoInfo) { |
62 |
| - if (Object.prototype.hasOwnProperty.call(repoInfo, repo)) { |
63 |
| - if (optionValue === repoInfo[repo].name) { |
64 |
| - // format the date |
65 |
| - const upDate = new Date(repoInfo[repo].updated_at); |
66 |
| - const amOrPm = upDate.getHours() < 12 ? 'AM' : 'PM'; |
67 |
| - const dateHours = upDate.getHours() % 12 || 12; |
68 |
| - const formatedUpdate = `${upDate.getMonth()}/${upDate.getDate()}/${upDate.getFullYear()} ${dateHours} |
| 59 | + Object.keys(repoInfo).forEach(key => { |
| 60 | + if (optionValue === repoInfo[key].name) { |
| 61 | + // format the date |
| 62 | + const upDate = new Date(repoInfo[key].updated_at); |
| 63 | + const amOrPm = upDate.getHours() < 12 ? 'AM' : 'PM'; |
| 64 | + const dateHours = upDate.getHours() % 12 || 12; |
| 65 | + const formatedUpdate = `${upDate.getMonth()}/${upDate.getDate()}/${upDate.getFullYear()} ${dateHours} |
69 | 66 | : ${upDate.getMinutes()}:${upDate.getSeconds()} ${amOrPm}`;
|
70 |
| - |
71 |
| - templateElement.push( |
72 |
| - '<div id="row">', |
73 |
| - `${'<p id="name-info">'} Repository name : ${'<a href="'}${ |
74 |
| - repoInfo[repo].html_url |
75 |
| - }"${'/>'} ${repoInfo[repo].name}</a></p>`, |
76 |
| - `${'<p id="desc">'} Description : ${repoInfo[repo].description}</p>`, |
77 |
| - `${'<p id="forks">'} Forks : ${repoInfo[repo].forks_count}</p>`, |
78 |
| - |
79 |
| - `${'<p id="updated">'} Updated : ${formatedUpdate}</p>`, |
80 |
| - '</div>', |
81 |
| - ); |
82 |
| - |
83 |
| - // Call another function(addContributors) to fill i contributor information. |
84 |
| - fetchUrl(repoInfo[repo].contributors_url).then(responseData => { |
85 |
| - addContributors(responseData); |
86 |
| - }); |
87 |
| - } |
| 67 | + templateElement.push( |
| 68 | + '<div id="row">', |
| 69 | + `${'<p id="name-info">'} Repository name : ${'<a href="'}${ |
| 70 | + repoInfo[key].html_url |
| 71 | + }"${'/>'} ${repoInfo[key].name}</a></p>`, |
| 72 | + `${'<p id="desc">'} Description : ${repoInfo[key].description}</p>`, |
| 73 | + `${'<p id="forks">'} Forks : ${repoInfo[key].forks_count}</p>`, |
| 74 | + |
| 75 | + `${'<p id="updated">'} Updated : ${formatedUpdate}</p>`, |
| 76 | + '</div>', |
| 77 | + ); |
| 78 | + fetchUrl(repoInfo[key].contributors_url).then(responseData => { |
| 79 | + addContributors(responseData); |
| 80 | + }); |
88 | 81 | }
|
89 |
| - } |
| 82 | + }); |
90 | 83 | const htmlString = templateElement.join('');
|
91 | 84 | document.getElementById('repo-details').innerHTML = htmlString;
|
92 | 85 | }
|
|
100 | 93 |
|
101 | 94 | // push all the HYP repo names to sort array.
|
102 | 95 |
|
103 |
| - // eslint-disable-next-line no-restricted-syntax |
104 |
| - for (const repo in userRepo) { |
105 |
| - if (Object.prototype.hasOwnProperty.call(userRepo, repo)) { |
106 |
| - sortRepoName.push(userRepo[repo].name); |
107 |
| - } |
108 |
| - } |
| 96 | + Object.keys(userRepo).forEach(key => { |
| 97 | + sortRepoName.push(userRepo[key].name); |
| 98 | + }); |
109 | 99 |
|
110 | 100 | // sort the repo name using sort function and localeComapare for uppercase and lowercase sorting.
|
111 | 101 | sortRepoName.sort((a, b) => a.localeCompare(b));
|
112 | 102 |
|
113 | 103 | // Create Option under Select element and attach the same with SELECT element.
|
114 | 104 |
|
115 |
| - // eslint-disable-next-line no-restricted-syntax |
116 |
| - for (const repo of sortRepoName) { |
| 105 | + sortRepoName.forEach(repo => { |
117 | 106 | const option = document.createElement('option');
|
118 | 107 | option.value = repo;
|
119 | 108 | option.text = repo;
|
120 | 109 | selectRepo.appendChild(option);
|
121 |
| - } |
| 110 | + }); |
122 | 111 |
|
123 | 112 | const selectBox = document.getElementById('select-repo');
|
124 | 113 |
|
|
0 commit comments