-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathps7.js
More file actions
49 lines (32 loc) · 1.42 KB
/
ps7.js
File metadata and controls
49 lines (32 loc) · 1.42 KB
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
// document.getElementsByTagName("nav")[0].firstElementChild.style.background = "black"
// document.getElementsByTagName("nav")[0].lastElementChild.style.background = "black"
const values = ["lightgreen", "lightblue", "blue", "grey", "cyan", "lightyellow", "yellow",
"black", "white", "red", "lightred", "skyblue", "pink", "lightpink", "purple", "lightpurple"]
// Display the current time
function checking() {
// Create a new Date object
let currentDate = new Date();
// Get the current time
let hours = currentDate.getHours();
let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();
// Convert to 12-hour format
let amPm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12 || 12; // Convert 0 to 12
document.getElementById("current").innerHTML = `CURRENT TIME<br>${hours}:${minutes}:${seconds} ${amPm}`
}
function change1() {
document.getElementById("current")
let randomNumber = Math.floor(Math.random() * (values.length - 0) + 0)
let ele = document.getElementById("current")
ele.style.background = values[randomNumber]
}
function change2() {
document.getElementById("current")
let randomNumber = Math.floor(Math.random() * (values.length - 0) + 0)
let ele = document.getElementById("current")
ele.style.color = values[randomNumber]
}
window.setInterval(checking, 1000);
window.setInterval(change1, 1000);
window.setInterval(change2, 1000);