-
Notifications
You must be signed in to change notification settings - Fork 6
homework #5
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
homework #5
Changes from all commits
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,20 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>About Me</title> | ||
| <link rel="stylesheet" type="text/css" href="C:\Users\Nikos Sp\Desktop\javascript2 week 1\aboutMe\styles.css"> | ||
| </head> | ||
| <body> | ||
| <h1>About Me</h1> | ||
|
|
||
| <ul> | ||
| <li>Nickname: <span id="nickname"></span></li> | ||
| <li>Favorite food: <span id="fav-food"></span></li> | ||
| <li>Hometown: <span id="hometown"></span></li> | ||
| </ul> | ||
| <script src="C:\Users\Nikos Sp\Desktop\javascript2 week 1\aboutMe\index.js"></script> | ||
| </body> | ||
| </html> | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| let body = document.querySelector("BODY"); | ||
| //document.getElementById("body").style.fontFamily = "Impact,Charcoal,sans-serif"; | ||
|
|
||
| body.style.fontFamily = "Arial, sans-serif"; | ||
|
|
||
|
|
||
| document.getElementById("nickname").textContent = "Kotsidas"; | ||
| document.getElementById("fav-food").textContent = "Pasta"; | ||
| document.getElementById("hometown").textContent = "Heraclion"; | ||
|
|
||
| let list = document.querySelectorAll("li") | ||
|
|
||
| for (let i=0; i<list.length; i++){ | ||
| list[i].classList.add("list-item") | ||
| } | ||
|
|
||
| let profImage = document.createElement("img") | ||
| profImage.src = "http://i.imgur.com/TENxP.jpg" | ||
| profImage.width = "150" | ||
|
|
||
| document.body.appendChild(profImage) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| body { | ||
| font-family: sans-serif; | ||
| } | ||
|
|
||
| .list-item { | ||
| color:red; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| function hijackGoogleLogo() { | ||
| var logo = document.getElementById("hplogo"); | ||
| logo.src = "https://www.hackyourfuture.dk/static/logo-dark.svg" | ||
| logo.srcset = "https://www.hackyourfuture.dk/static/logo-dark.svg"; | ||
| logo.removeAttribute("onload"); | ||
| logo.removeAttribute("data-iml"); | ||
| logo.removeAttribute("data-atf"); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| hijackGoogleLogo(); | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| function showCurrentTime() { | ||
| var today = new Date(); | ||
| var h = today.getHours(); | ||
| var m = today.getMinutes(); | ||
| var s = today.getSeconds(); | ||
| m = checkTime(m); | ||
| s = checkTime(s); | ||
| document.getElementById('txt').innerHTML = | ||
| h + ":" + m + ":" + s; | ||
| setInterval(showCurrentTime, 500); | ||
| } | ||
| function checkTime(i) { | ||
| if (i < 10) { | ||
| i = "0" + i | ||
| } // add zero in front of numbers < 10 | ||
| return i; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| body { | ||
| display: flex; | ||
| background-color:red; | ||
| } | ||
|
|
||
| #txt { | ||
| display:inline-block; | ||
| margin-left: 50vw; | ||
| margin-top: 50vh; | ||
| font-size:x-large; | ||
|
|
||
| border:darkred; | ||
| border-style: double; | ||
| background-color: white; | ||
|
|
||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <link rel="stylesheet" type="text/css" href="C:\Users\Nikos Sp\Desktop\javascript2 week 1\showCurrentTime\styles.css"> | ||
| <script src="C:\Users\Nikos Sp\Desktop\javascript2 week 1\showCurrentTime\showCurrentTime.js"> | ||
|
|
||
| </script> | ||
| </head> | ||
|
|
||
| <body onload="showCurrentTime()"> | ||
|
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. like! |
||
|
|
||
| <div id="txt"></div> | ||
|
|
||
|
|
||
| </body> | ||
| </html> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Cat Walk</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <script src="bundle.js"></script> | ||
|
|
||
| <script src="jscode.js"></script> | ||
| <img style="position:absolute;" src="http://www.anniemation.com/clip_art/images/cat-walk.gif" /> | ||
| </body> | ||
|
|
||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
|
|
||
| let image; | ||
|
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 variable should not be there. If I remember correctly you placed image here so you can view it from chrome devTools console. This should not be the case. If you want to view something in the console, you can just console.log if at the right place |
||
|
|
||
|
|
||
|
|
||
|
|
||
| window.onload = () => { | ||
| image = document.querySelector("img"); | ||
|
|
||
| let distance = 0; | ||
| let screenWidth = window.innerWidth; | ||
| let body = document.querySelector("body") | ||
|
|
||
|
|
||
|
|
||
| function catWalk() { | ||
| image.style.left = `${distance}px`; | ||
| distance += 10; | ||
| console.log(image); | ||
| console.log(distance); | ||
|
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. finalized code should not have any console.log statements. If you want to explain something in your code, try adding some comments |
||
|
|
||
|
|
||
|
|
||
|
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. no need to leave so many lines as space. One should be enough in most cases |
||
|
|
||
|
|
||
| if (distance > screenWidth) { | ||
| distance = 0; | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| //catWalk(); | ||
|
|
||
| //catDance(); | ||
|
|
||
|
|
||
| //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.
It is perfectly fine as it is. Personal preference for loops is .forEach. I try to avoid for loops because you cannot understand straight away what is going on