|
50 | 50 | } |
51 | 51 |
|
52 | 52 | const htmlString = divElement.join(''); |
53 | | - document.getElementById('section2').innerHTML = htmlString; |
| 53 | + document.getElementById('contributorinfomation').innerHTML = htmlString; |
54 | 54 | } |
55 | 55 |
|
56 | 56 | // Load the Repository information into section1 div element. |
57 | 57 |
|
58 | | - function loadDiv(repoInfo, optionValue) { |
| 58 | + function loadRepoDetails(repoInfo, optionValue) { |
59 | 59 | const templateElement = []; |
60 | 60 |
|
61 | 61 | // eslint-disable-next-line no-restricted-syntax |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | const htmlString = templateElement.join(''); |
98 | | - document.getElementById('section1').innerHTML = htmlString; |
| 98 | + document.getElementById('repodetails').innerHTML = htmlString; |
99 | 99 | } |
100 | 100 |
|
101 | 101 | // Create options under 'SELECT' element which should have HYF Repositories. |
102 | 102 |
|
103 | | - function loadSelectionValues(userInfo) { |
| 103 | + function loadSelectionValues(userRepo) { |
104 | 104 | const sortRepoName = []; |
105 | 105 |
|
106 | | - const userRepo = JSON.parse(userInfo); |
107 | | - const mySelect = document.getElementById('myselect'); |
| 106 | + const selectRepo = document.getElementById('selectrepo'); |
108 | 107 |
|
109 | 108 | // push all the HYP repo names to sort array. |
110 | 109 |
|
|
125 | 124 | const option = document.createElement('option'); |
126 | 125 | option.value = repo; |
127 | 126 | option.text = repo; |
128 | | - mySelect.appendChild(option); |
| 127 | + selectRepo.appendChild(option); |
129 | 128 | } |
130 | 129 |
|
131 | | - const selectBox = document.getElementById('myselect'); |
| 130 | + const selectBox = document.getElementById('selectrepo'); |
132 | 131 | const selectedValue = selectBox.options[selectBox.selectedIndex].value; |
133 | 132 |
|
134 | 133 | // Load Repository information for the choose repository name in the select box. |
135 | | - loadDiv(userRepo, selectedValue); |
| 134 | + loadRepoDetails(userRepo, selectedValue); |
136 | 135 | selectBox.onchange = function() { |
137 | | - loadDiv(userRepo, selectBox.value); |
| 136 | + loadRepoDetails(userRepo, selectBox.value); |
138 | 137 | }; |
139 | 138 | } |
140 | 139 |
|
141 | 140 | function main(url) { |
142 | 141 | fetchJSON(url, (err, data) => { |
143 | 142 | const root = document.getElementById('root'); |
144 | | - const myParent = document.body; |
| 143 | + const BodyEl = document.body; |
145 | 144 |
|
146 | 145 | if (err) { |
147 | 146 | createAndAppend('div', root, { text: err.message, class: 'alert-error' }); |
148 | 147 | } else { |
149 | 148 | // Create div element 'select' in document body to hold the label element and list box. |
150 | 149 |
|
151 | | - createAndAppend('div', myParent, { id: 'select' }); |
152 | | - const select = document.getElementById('select'); |
| 150 | + createAndAppend('div', BodyEl, { id: 'seletcontainer' }); |
| 151 | + const select = document.getElementById('seletcontainer'); |
153 | 152 | createAndAppend('LABEL', select, { |
154 | 153 | text: 'HYF Repositories: ', |
155 | 154 | id: 'label', |
156 | 155 | for: 'repo', |
157 | 156 | }); |
158 | | - createAndAppend('select', select, { id: 'myselect' }); |
| 157 | + createAndAppend('select', select, { id: 'selectrepo' }); |
159 | 158 |
|
160 | 159 | // Create two div elements section1 and section2 under 'Root' div to have |
161 | 160 | // section1 - Repository Information. |
162 | 161 | // section2 - Contributions. |
163 | 162 |
|
164 | | - createAndAppend('div', root, { id: 'section1' }); |
165 | | - createAndAppend('div', root, { id: 'section2' }); |
| 163 | + createAndAppend('div', root, { id: 'repodetails' }); |
| 164 | + createAndAppend('div', root, { id: 'contributorinfomation' }); |
166 | 165 |
|
167 | 166 | // Insert section1 before section2 div element under 'root' div. |
168 | | - const newNode = document.getElementById('section2'); |
169 | | - const referenceNode = document.querySelector('section1'); |
| 167 | + const newNode = document.getElementById('contributorinfomation'); |
| 168 | + const referenceNode = document.querySelector('repodetails'); |
170 | 169 | root.insertBefore(newNode, referenceNode); |
171 | 170 |
|
172 | 171 | // Insert Select div first in the body before root div. |
173 | | - myParent.insertBefore(select, document.getElementById('root')); |
| 172 | + BodyEl.insertBefore(select, document.getElementById('root')); |
174 | 173 |
|
175 | | - loadSelectionValues(JSON.stringify(data, null, 2)); |
| 174 | + loadSelectionValues(data); |
176 | 175 | } |
177 | 176 | }); |
178 | 177 | } |
|
0 commit comments