Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Week1/homework/aboutMe/about_me.html
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>


25 changes: 25 additions & 0 deletions Week1/homework/aboutMe/index.js
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")
}
Copy link
Copy Markdown

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


let profImage = document.createElement("img")
profImage.src = "http://i.imgur.com/TENxP.jpg"
profImage.width = "150"

document.body.appendChild(profImage)




7 changes: 7 additions & 0 deletions Week1/homework/aboutMe/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
font-family: sans-serif;
}

.list-item {
color:red;
}
13 changes: 13 additions & 0 deletions Week1/homework/hijackLogo/hijackGoogleLogo.js
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();

17 changes: 17 additions & 0 deletions Week1/homework/showCurrentTime/showCurrentTime.js
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;
}
18 changes: 18 additions & 0 deletions Week1/homework/showCurrentTime/styles.css
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;

}


17 changes: 17 additions & 0 deletions Week1/homework/showCurrentTime/time.html
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()">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like!


<div id="txt"></div>


</body>
</html>

16 changes: 16 additions & 0 deletions Week1/homework/theCatWalk/index.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>
44 changes: 44 additions & 0 deletions Week1/homework/theCatWalk/jscode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

let image;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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




Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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);


}