-
Notifications
You must be signed in to change notification settings - Fork 2
/
script_digiclock.js
76 lines (75 loc) · 2.21 KB
/
script_digiclock.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
const time = document.getElementById('time');
const msg = document.getElementById('msg');
const img = document.getElementById('img');
let userName = prompt('Enter Your Name');
if (userName == null || userName == "") {
userName = "Buddy"
}
function getTime(argument) {
let d = new Date();
let hour = d.getHours();
let min = d.getMinutes();
let sec = d.getSeconds();
let ampm = hour >= 12 ?'PM': 'AM';
if (hour > 12) {
hour -= 12;
}
if (hour == 0) {
hour = 12
}
let fullTime = `${hour} : ${min} : ${sec} ${ampm}`;
if (hour < 12 && hour >= 6 && ampm == 'AM') {
msg.innerHTML = `Good Morning ${userName}!`
}
if (hour < 6 && hour > 1 && ampm == 'AM') {
msg.innerHTML = `Good Night ${userName}!`
}
if (hour == 12 && ampm == 'PM') {
msg.innerHTML = `Good Noon ${userName}!`
}
if (hour == 12 && ampm == 'AM') {
msg.innerHTML = `Good Night ${userName}!`
}
if (hour < 3 && ampm == 'PM') {
msg.innerHTML = `Good Noon ${userName}!`
}
if (hour == 3 && ampm == 'PM') {
msg.innerHTML = `Good Afternoon ${userName}!`
}
if (hour < 5 && hour > 3 && ampm == 'PM') {
msg.innerHTML = `Good Afternoon ${userName}!`
}
if (hour == 5 && ampm == 'PM') {
msg.innerHTML = `Good Evening ${userName}!`
}
if (hour < 8 && hour > 5 && ampm == 'PM') {
msg.innerHTML = `Good Evening ${userName}!`
}
if (hour == 8 && ampm == 'PM') {
msg.innerHTML = `Good Night ${userName}!`
}
if (hour < 12 && hour > 8 && ampm == 'PM') {
msg.innerHTML = `Good Night ${userName}!`
}
time.innerHTML = fullTime;
}
function setWallpaper(argument) {
if (msg.innerHTML == `Good Morning ${userName}!`) {
img.src = 'https://say-het.github.io/morning.jpeg'
}
if (msg.innerHTML == `Good Noon ${userName}!`) {
img.src = 'https://say-het.github.io/afternoon.jpeg'
}
if (msg.innerHTML == `Good Afternoon ${userName}!`) {
img.src = 'https://say-het.github.io/afternoon.jpeg'
}
if (msg.innerHTML == `Good Evening ${userName}!`) {
img.src = 'https://say-het.github.io/evening.jpeg'
}
if (msg.innerHTML == `Good Night ${userName}!`) {
img.src = 'https://say-het.github.io/night.jpeg'
}
}
setTimeout(setWallpaper, 100);
getTime();
setInterval(getTime, 1000);