-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdwatch.js
51 lines (46 loc) · 1.23 KB
/
dwatch.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
function time() {
var t = new Date();
var h = t.getHours();
var m = t.getMinutes();
var s = t.getSeconds();
var ap = "";
if (h > 12) {
h = h - 12;
ap = "PM";
} else if (h < 12) {
if (h == 0) {
h = 12;
ap = "AM";
} else {
ap = "AM";
}
}
h = h < 10 ? "0" + h : h;
m = m < 10 ? "0" + m : m;
s = s < 10 ? "0" + s : s;
var timewegot = h + ":" + m + ":" + s + " " + ap;
document.getElementById("Watch").innerText = timewegot;
document.getElementById("Watch").textContent = timewegot;
setTimeout(time, 1000);
}
time();
document.addEventListener("DOMContentLoaded", function () {
const modeSwitch = document.getElementById("modeSwitch");
const body = document.body;
modeSwitch.addEventListener("click", function () {
body.classList.toggle("dark-mode");
});
});
function toggleMode() {
var modeText = document.getElementById("modeText");
var currentMode = modeText.innerText;
if (currentMode === "Light Mode") {
modeText.innerText = "Dark Mode";
modeText.style.color = "white";
title.style.color = "white";
} else {
modeText.innerText = "Light Mode";
modeText.style.color = "black";
title.style.color = "black";
}
}