Skip to content

Commit

Permalink
good morning,afternoon, and evening code working.
Browse files Browse the repository at this point in the history
  • Loading branch information
met18001 committed Apr 20, 2020
1 parent 2627ee5 commit d28c0cb
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
38 changes: 38 additions & 0 deletions final_project/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
body {
margin: 0;
padding: 0;
overflow: hidden;

}

img {

}

#img{

}

/* Google font */
@import url('https://fonts.googleapis.com/css?family=Orbitron');

#clock {
font-family: 'Orbitron', sans-serif;
color: #66ff99;
font-size: 56px;
position: absolute;
top: 50%;
left: 34%;


}
p{
position: absolute;
top: 40%;
left: 34%;
font-family: 'Orbitron', sans-serif;
color: #66ff99;
font-size: 20px;
}


20 changes: 20 additions & 0 deletions final_project/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Final Project</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="clock"></div>
<p id="good"> <span> <input type="text" editable name></span></p>

<div id="img"></div>




<script src="js/this.js"></script>
</body>
</html>
55 changes: 55 additions & 0 deletions final_project/js/this.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const numItemsToGenerate = 1;

function renderItem(){
fetch(`https://source.unsplash.com/1600x900/?morning`).then((response)=> {
let item = document.getElementById("img");
item.classList.add('item');
item.innerHTML = `
<img class="morning-image" src="${response.url}" alt="morning image"/>
`
document.documentElement.appendChild(item);
})
}
for(let i=0;i<numItemsToGenerate;i++){
renderItem();
};



function currentTime() {
var date = new Date(); /* creating object of Date class */
var hour = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
var midday = "AM";
midday = (hour >= 12) ? "PM" : "AM"; /* assigning AM/PM */
hour = (hour == 0) ? 12 : ((hour > 12) ? (hour - 12): hour); /* assigning hour in 12-hour format */
hour = updateTime(hour);
min = updateTime(min);
sec = updateTime(sec);
document.getElementById("clock").innerText = hour + " : " + min + " : " + sec + " " + midday; /* adding time to the div */
var t = setTimeout(currentTime, 1000); /* setting timer */
}

function updateTime(k) { /* appending 0 before time elements if less than 10 */
if (k < 10) {
return "0" + k;
}
else {
return k;
}
}

currentTime();


var today = new Date()
var curHr = today.getHours()

if (curHr < 12) {
document.write('good morning').getElementById('good')
} else if (curHr < 18) {
document.write('good afternoon').getElementById('good')
} else {
document.write('good evening').getElementById('good')
}

0 comments on commit d28c0cb

Please sign in to comment.