Week1-Assignment#1
Conversation
| function main(url) { | ||
| fetchJSON(url, (err, data) => { | ||
| const root = document.getElementById('root'); | ||
| const myParent = document.body; |
There was a problem hiding this comment.
Who is my? I'd call it something like BodyEl
There was a problem hiding this comment.
changed myParent to BodyEl.
| createAndAppend('pre', root, { text: JSON.stringify(data, null, 2) }); | ||
| // Create div element 'select' in document body to hold the label element and list box. | ||
|
|
||
| createAndAppend('div', myParent, { id: 'select' }); |
There was a problem hiding this comment.
The id name is a bit confusing here. Would call is something like select-container or something.
There was a problem hiding this comment.
Corrected the container name for select as - selectcontainer.
| // section1 - Repository Information. | ||
| // section2 - Contributions. | ||
|
|
||
| createAndAppend('div', root, { id: 'section1' }); |
There was a problem hiding this comment.
Would name these divs closer to what content they will hold. More like contributors and repo-details
There was a problem hiding this comment.
corrected the name div name as repodetails,contributorinfomation
| // Insert Select div first in the body before root div. | ||
| myParent.insertBefore(select, document.getElementById('root')); | ||
|
|
||
| loadSelectionValues(JSON.stringify(data, null, 2)); |
There was a problem hiding this comment.
Does it need to be stringified? Kinda confused what the other two parameters do.
There was a problem hiding this comment.
It was there in existing code, but i corrected ans used the data as such.
| const sortRepoName = []; | ||
|
|
||
| const userRepo = JSON.parse(userInfo); | ||
| const mySelect = document.getElementById('myselect'); |
There was a problem hiding this comment.
Not sure what the word my helps signify. Think a better name could be used?
There was a problem hiding this comment.
corrected with name selectrepo.
| } | ||
|
|
||
| // sort the repo name using sort function and localeComapare for uppercase and lowercase sorting. | ||
| sortRepoName.sort((a, b) => a.localeCompare(b)); |
There was a problem hiding this comment.
Nice, I've never heard of localCompare before
| const selectedValue = selectBox.options[selectBox.selectedIndex].value; | ||
|
|
||
| // Load Repository information for the choose repository name in the select box. | ||
| loadDiv(userRepo, selectedValue); |
There was a problem hiding this comment.
Great job creating separate functions. But can we rename this to something more clear on what it does?
There was a problem hiding this comment.
Renamed the function name as loadRepoDetails.
|
|
||
| `${'<p id="updated">'} Updated : ${formatedUpdate}</p>`, | ||
| '</div>', | ||
| ); |
There was a problem hiding this comment.
Interesting technique here. Yes, this will work.
| if (err) { | ||
| createAndAppend('div', root, { text: err.message, class: 'alert-error' }); | ||
| } else { | ||
| addContributors(data); |
| "license": "CC-BY-4.0", | ||
| "devDependencies": { | ||
| "eslint": "^5.9.0", | ||
| "eslint": "^5.16.0", |
grod220
left a comment
There was a problem hiding this comment.
Going to approve the week 1 stuff and request changes for week 2
No description provided.