-
Notifications
You must be signed in to change notification settings - Fork 223
Eval 2 - reddit #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Eval 2 - reddit #225
Changes from all commits
927f222
6c4c0e3
1ef4efb
12ef797
9202a5c
84ca51b
61da120
831114f
1392c02
543d562
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Page</title> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" | ||
| integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
| <link href="style.css" rel="stylesheet"> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <header> | ||
| <h1>Reddit</h1> | ||
| </header> | ||
| </div> | ||
| <main class="container"> | ||
| <hr> | ||
| <div class="comment-btns"> | ||
| <span class="rm-comments-btn">remove</span> | ||
| <span class="show-comments-btn">comments:</span> | ||
| </div> | ||
| <span class="new-comments">I'm a comment - Posted By: Jeff | ||
| <br></span> | ||
| <div class="comment-btns"> | ||
| <hr> | ||
| <span class="rm-comments-btn">remove</span> | ||
| <span class="show-comments-btn">comments:</span> | ||
| </div> | ||
| <span class="new-comments">Here's a comment - Posted By: Jeff <br> | ||
| </span> | ||
| <hr> | ||
| <input class="post" type="text" placeholder="Post Text" /> | ||
| <input class="name" type="text" placeholder="Your Name" /> | ||
| <ul class="nav nav-pills"> | ||
| <li role="presentation" class="active"><a href="#">Submit</a></li> | ||
|
Comment on lines
+36
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never use ul or lists for buttons, use the button tag and you have 'btn btn-primary' bootstrap classes |
||
| </ul> | ||
| </main> | ||
| </body> | ||
| <script src="main.js"></script> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| const submitButton = document.getElementsByClassName('active')[0]; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to have consistency, either use getElementsByClassName or querySelector |
||||||
|
|
||||||
| submitButton.addEventListener('click', function () { | ||||||
|
|
||||||
| const inputPost = document.getElementsByClassName('post')[0].value; | ||||||
| const inputName = document.getElementsByClassName('name')[0].value; | ||||||
|
|
||||||
| const newSpan = document.createElement('span'); | ||||||
| newSpan.innerHTML = `${inputPost}, posted by ${inputName}`; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is less recommented, use textContent or appendChild as they are safer and more performant.
Comment on lines
+4
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. your code alignment is off, check your lint settings. This affects readability. |
||||||
| const lineBreak = document.createElement('br'); | ||||||
|
|
||||||
| const commentContainer = document.querySelector('.new-comments'); | ||||||
| commentContainer.appendChild(newSpan); | ||||||
| commentContainer.appendChild(lineBreak); | ||||||
| }); | ||||||
|
|
||||||
| const rmButton = document.getElementsByClassName('rm-comments-btn')[0]; | ||||||
| rmButton.addEventListener('click', function () { | ||||||
| const commentsContainer = document.querySelector('.new-comments'); | ||||||
| commentsContainer.innerHTML = ''; | ||||||
| }) | ||||||
|
|
||||||
| const toggleButtons = document.querySelectorAll('.show-comments-btn'); | ||||||
|
|
||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| toggleButtons.forEach(button => { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should have been a separate function with ternary operation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator |
||||||
| button.addEventListener('click', function () { | ||||||
|
|
||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. watch for too many empty spaces |
||||||
| const comments = this.parentElement.nextElementSibling; | ||||||
|
|
||||||
|
|
||||||
|
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if (comments.style.display === 'none' || comments.style.display === '') { | ||||||
| comments.style.display = 'block'; | ||||||
| } else { | ||||||
| comments.style.display = 'none'; | ||||||
| } | ||||||
| }); | ||||||
| }); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| .container { | ||
| display: grid; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| hr { | ||
| background-color: black; | ||
| color: black; | ||
| } | ||
|
|
||
| .rm-comments-btn { | ||
| background-color: blue; | ||
| border-radius: 5px; | ||
| padding: 2px; | ||
| font-size: 80%; | ||
| color: white; | ||
| } | ||
|
|
||
| .show-comments-btn { | ||
| margin-left: 5px; | ||
| background-color: blue; | ||
| border-radius: 5px; | ||
| padding: 2px; | ||
| font-size: 80%; | ||
| color: white; | ||
| } | ||
|
|
||
| input { | ||
| width: 400px; | ||
| margin: 5px; | ||
| } | ||
|
|
||
| hr { | ||
| width: 95%; | ||
| } | ||
|
|
||
| .active { | ||
| margin-left: 4px; | ||
| } | ||
|
|
||
| /* button { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not push commented code |
||
| background-color: royalblue; | ||
| color: white; | ||
| border-radius: 5px; | ||
| margin-left: 7px; | ||
| width: 24%; | ||
| font-size:70%; | ||
| } */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, could have been buttons