-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
107 lines (93 loc) · 3.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
function clock() {
var hours = document.getElementById("hours");
var minutes = document.getElementById("mins");
var seconds = document.getElementById("secs");
var ap = document.getElementById("ap");
var time = new Date();
var hr = time.getHours();
var min = time.getMinutes();
var sec = time.getSeconds();
var amOrPm;
if (hr >= 0 && hr <= 12) {
amOrPm = "AM";
} else {
amOrPm = "PM";
}
if (hr > 12) {
hr = hr - 12;
} else if (hr == 0) {
hr = 12;
}
if (hr < 10) {
hr = "0" + hr;
}
if (min < 10) {
min = "0" + min;
}
if (sec < 10) {
sec = "0" + sec;
}
hours.innerHTML = hr;
minutes.innerHTML = min;
seconds.innerHTML = sec;
ap.innerHTML = amOrPm;
}
setInterval(clock, 1000);
function setTime() {
var optionValue1 = document.getElementById("wakeup-time");
var optionValue2 = document.getElementById("lunch-time");
var optionValue3 = document.getElementById("nap-time");
var optionValue4 = document.getElementById("night-time");
var hourrs = new Date().getHours();
if (optionValue1.value == hourrs) {
document.getElementById("img-container").style.backgroundImage ="url('./Assests/Mt.jpeg')";
document.getElementById("ltext").innerHTML ="GOOD MORNNG !! WAKE UP !!";
document.getElementById("text-container").innerHTML ="GRAB SOME HEALTHY BREAKFAST !!!";
document.getElementById("wake-up-time-display").innerHTML = `Wake Up Time: ${
optionValue1.options[optionValue1.value].text }`;
}
else {
document.getElementById("wake-up-time-display").innerHTML = `Wake Up Time: ${
optionValue1.options[optionValue1.value].text
}`;
}
if (optionValue2.value == hourrs) {
document.getElementById("img-container").style.backgroundImage ="url('./Assests/Lt.jpeg')";
document.getElementById("ltext").innerHTML ="GOOD AFTERNOON !! TAKE SOME SLEEP";
document.getElementById("text-container").innerHTML ="LET'S HAVE SOME LUNCH !!";
document.getElementById("lunch-time-display").innerHTML = `Lunch Time: ${
optionValue2.options[optionValue2.value].text
}`;
}
else {
document.getElementById("lunch-time-display").innerHTML = `Lunch Time: ${
optionValue2.options[optionValue2.value].text
}`;
}
if (optionValue3.value == hourrs) {
document.getElementById("img-container").style.backgroundImage ="url('./Assests/Et.jpeg')";
document.getElementById("ltext").innerHTML ="GOOD EVENING !!";
document.getElementById("text-container").innerHTML ="STOP YAWNING,GET SOME TEA... ITS JUST EVENING !!";
document.getElementById("nap-time-display").innerHTML = `Nap Time: ${
optionValue3.options[optionValue3.value].text
}`;
}
else {
document.getElementById("nap-time-display").innerHTML = `Nap Time: ${
optionValue3.options[optionValue3.value].text
}`;
}
if (optionValue4.value == hourrs) {
document.getElementById("img-container").style.backgroundImage ="url('./Assests/Nt.jpeg')";
document.getElementById("ltext").innerHTML ="GOOD NIGHT !!";
document.getElementById("text-container").innerHTML ="CLOSE YOUR EYES AND GO TO SLEEP";
document.getElementById("night-time-display").innerHTML = `Night Time: ${
optionValue4.options[optionValue4.value].text
}`;
}
else {
document.getElementById("night-time-display").innerHTML = `Night Time: ${
optionValue4.options[optionValue4.value].text
}`;
}
}