-
Notifications
You must be signed in to change notification settings - Fork 7
Hadidreem17 w1 browsers #31
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: main
Are you sure you want to change the base?
Hadidreem17 w1 browsers #31
Conversation
dardecena
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.
Great effort. You are almost there. Please work on Ex 4 and Ex 5.
| const ul = document.createElement ('ul'); | ||
| books.forEach( book => { | ||
| const li = document.createElement ('li'); | ||
| const p = document.createElement ( 'p'); | ||
| p.textContent = `${book.title} - ${book.author} `; | ||
| const img = document.createElement ('img'); | ||
| img.src = `https://covers.openlibrary.org/b/isbn/${book.isbn}-M.jpg`; | ||
| img.alt = `${book.title} cover`; | ||
| li.appendChild (p); | ||
| li.appendChild (img); | ||
| if (book.alreadyRead) { | ||
| li.style.backgroundColor = 'green'; | ||
| } | ||
| else | ||
| { li.style.backgroundColor = 'red'} ; | ||
| ul.appendChild (li); | ||
| }); | ||
| return ul; |
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.
Nice work!
| body { | ||
| font-family: Arial, sans-serif; | ||
| background-color: #f4f4f4; | ||
| margin: 0; | ||
| padding: 20px; | ||
| } | ||
| h1 { | ||
| text-align: center; | ||
| color: #333; | ||
| } | ||
| ul { | ||
| list-style-type: none; | ||
| padding: 0; | ||
| display : grid ; | ||
| grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); | ||
| gap : 16px; | ||
|
|
||
| } | ||
| li { | ||
| background: #fff; | ||
| margin: 10px 0; | ||
| padding: 15px; | ||
| border-radius: 5px; | ||
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
| } | ||
| img { | ||
| width: 100% ; | ||
| height: auto ; | ||
| border -radius: 5px ; | ||
| display : block ; | ||
|
|
||
| } | ||
| p { | ||
| margin: 0; | ||
| padding: 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.
👍
| function aboutMe() { | ||
| const nickname = document.querySelector ('#nickname'); | ||
| nickname.textContent = 'Rim'; | ||
| const favFood = document.querySelector ('#fav-food'); | ||
| favFood.textContent = 'Sushi'; | ||
| const hometown = document.querySelector ('#hometown'); | ||
| hometown.textContent = 'Tokyo'; | ||
| const listItems = document.querySelectorAll ('li'); | ||
| listItems.forEach(item => { | ||
| item.classList.add('list-item'); | ||
| }); | ||
| } | ||
| aboutMe(); |
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.
Great!
|
|
||
| body { | ||
|
|
||
| font-family: Arial, sans-serif; | ||
| margin: auto; | ||
| padding: 20px; | ||
| } | ||
|
|
||
| .list-item { | ||
| color: red ; | ||
| } |
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.
👍
| const logo = document.querySelector('img[alt="Google"]') ; | ||
| logo.src = 'https://www.hackyourfuture.be/static/logo.png'; | ||
| logo.srcset = 'https://www.hackyourfuture.be/static/logo.png'; | ||
|
|
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.
Good!
| document.querySelector('time').textContent= new Date().toLocaleTimeString() ; | ||
| setInterval(addCurrentTime, 1000) ; |
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.
TODO: Almost there, but not quite.
Hint:
Where on the document do you want to display the time? header? body? etc.
| window.addEventListener('load', function () { | ||
| const cat = document.querySelector('img'); | ||
| const originalSrc = cat.src || 'http://www.anniemation.com/clip_art/images/cat-walk.gif'; | ||
| const danceSrc = 'https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif'; | ||
|
|
||
| cat.style.position = 'absolute'; | ||
| cat.style.left = '0px'; | ||
|
|
||
| let hasDanced = false; | ||
| let walkTimer = null; | ||
|
|
||
| function catWalk() { | ||
| const x = parseInt(cat.style.left, 10) || 0; | ||
| const rightEdge = window.innerWidth - cat.width; | ||
| const mid = rightEdge / 2; | ||
|
|
||
| if (x >= rightEdge) { | ||
| cat.style.left = '0px'; | ||
| hasDanced = false; | ||
| return; | ||
| } | ||
|
|
||
| if (!hasDanced && x >= mid) { | ||
| hasDanced = true; | ||
| clearInterval(walkTimer); | ||
| cat.src = danceSrc; | ||
| setTimeout(function () { | ||
| cat.src = originalSrc; | ||
| walkTimer = setInterval(catWalk, 50); | ||
| }, 5000); | ||
| return; | ||
| } | ||
|
|
||
| cat.style.left = (x + 10) + 'px'; | ||
| } | ||
|
|
||
| walkTimer = setInterval(catWalk, 50); | ||
| }); |
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.
TODO: Good effort but not quite there yet. I see the cat walking in place. It doesn't meet the requirements of walking across the screen from left to right and doing a dance for 50ms in the middle of the screen.
No description provided.