-
-
Notifications
You must be signed in to change notification settings - Fork 12
Reviweing WebDeveloperTest #10
base: master
Are you sure you want to change the base?
Conversation
kabaros
left a comment
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.
This a very good PR @khaledkzy .. the comments are just to improve details but all in all, it does what it is supposed to do in an elegant way.
Read the comments, and let me know if you have questions and update your PR with the changes requested.
| </div> | ||
| </div> | ||
|
|
||
| <script type="text/javascript" src="main.js"></script> |
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.
why did you put the script tag in bottom not in top? (trick question)
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.
Because when you put it at the end it means that the javascript will only run in your page once the page is fully loaded.
| var content = document.querySelector('#mybutton'); | ||
| function showHide(event) { | ||
| event.preventDefault(); | ||
| if (content.className === "hide") { |
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.
very good simple logic
main.js
Outdated
| //Show and Hide The news Sections | ||
| var controlElement = document.querySelector('#show'); | ||
| controlElement.addEventListener('click', showHide); | ||
| var content = document.querySelector('#mybutton'); |
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.
variable names are confusing - why are you 'mybutton' content?
index.html
Outdated
|
|
||
|
|
||
| <p><a href="#" id="show">Show/Hide news items</a></p> | ||
| <div class="content" id="mybutton"> |
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.
why are you giving an id mybutton to something that is not a button?
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.
also in general don't use things like "my" in variable names - this is bad practice
main.js
Outdated
| sbumitButton.addEventListener('click', submitForm); | ||
|
|
||
| function submitForm(event) { | ||
| event.preventDefault(); |
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.
bad indentation - format your document!
main.js
Outdated
| } | ||
|
|
||
| function verifyUserName() { | ||
| if (userName.value.length <= 0 ) { |
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.
this check can also be ... if(!userName.value) (notice the !)
main.js
Outdated
| } | ||
|
|
||
| function verifyUserEmail() { | ||
| if (userEmail.value.length <= 0 || textEmail.value.indexOf('@') < 0 ) { |
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.
this is good but you could also write it like this
var isEmailValid = (userEmail.value.length <= 0 || textEmail.value.indexOf('@') < 0);
userEmail.style.backgroundColor = isEmailValid ? 'red' : 'white'; // if you don't understand this code - google ternary operators in JavaScript
return isEmailValid; // this will be false or true
This code is necessarily better or worse, but just read it and make sure you understand it (it should be equivalent to your code) and let me know if you have questions about it
|
|
||
| // AJAX REQUEST | ||
|
|
||
| var xhrcontent = document.getElementsByClassName(content); |
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.
very good!
Now as an extra challenge .. use fetch to make the AJAX call - see how much simpler you code becomes. https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
(fetch doesn't work in older browsers but we don't care about that - http://caniuse.com/#feat=fetch)
style.css
Outdated
| margin-bottom: 20px; | ||
| } | ||
| a { | ||
| text-decoration: none !important; |
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.
in general, don't use !important - if you work in a team and use !important, people will hate you. Just use a class name to your a tags, and use that class name for styling
style.css
Outdated
| } | ||
|
|
||
| .new .title{ | ||
| color: white; |
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.
indentation! format your document
No description provided.