-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
172 lines (121 loc) · 3.64 KB
/
index.html
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Greetings</title>
<style>
body{
font-variant-caps: all-petite-caps;
}
.widget {
padding: 5px 5px ;
color: #d4d4d4;
display: flex;
justify-content:center;
align-items:center;
flex-direction: column;
max-width: 95%;
margin: auto;
border: 3px solid #d4d4d4;
border-radius: 5px;
box-shadow: 2px 2px 1px 0px #d4d4d4;
}
.greet{
font-size: 3em;
}
.date {
font-family: monospace;
font-size: 2em;
}
.clock {
font-family: monospace;
font-size: 2em;
}
.time {
display: inline-block;
min-width: 20px;
}
.colon {
font-size: 1em;
display: inline-block;
}
</style>
</head>
<body>
<div class="container>">
<div class="widget">
<div class="greet" id="greet"></div>
<div class="date" id="date"></div>
<div class="clock">
<div class="time" id="hour"></div>
<div class="colon">:</div>
<div class="time" id="min"></div>
<div class="colon">:</div>
<div class="time" id="sec"></div>
</div>
</div>
</div>
<script>
function dispalyGreetings(today){
hrs = today.getHours();
name="Pawan"
if (hrs < 12)
greet = 'Good Morning '+name;
else if (hrs >= 12 && hrs <= 17)
greet = 'Good Afternoon '+name;
else if (hrs >= 17 && hrs <= 24)
greet = 'Good Evening '+name;
document.getElementById('greet').innerHTML = greet;
}
function dispalyDate(today) {
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var dayName = days[today.getDay()];
var monthName = monthNames[today.getMonth()];
var date = today.getDate();
var year = today.getFullYear();
document.getElementById('date').innerHTML =dayName+", "+monthName+" "+date+" "+year;
}
function dispalyClock(today) {
var hour = padZeros(twelveHour(today.getHours()));
var minutes = padZeros(today.getMinutes());
var seconds = padZeros(today.getSeconds());
if(today.getHours() >=12){
seconds+=" pm"
}
else{
seconds+=" am"
}
document.getElementById('hour').innerHTML = hour;
document.getElementById('min').innerHTML = minutes;
document.getElementById('sec').innerHTML = seconds;
}
function twelveHour(hour) {
if (hour > 12) {
return hour -= 12
} else if (hour === 0) {
return hour = 12;
} else {
return hour
}
}
function padZeros(num) {
if (num < 10) {
num = '0' + num
};
return num;
}
function dispalyWidget() {
var today = new Date();
dispalyGreetings(today);
dispalyDate(today);
dispalyClock(today);
setTimeout(dispalyWidget, 500);
}
dispalyWidget()
</script>
</body>
</html>