Update script.js
Browse files
script.js
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
function showTime() {
|
2 |
const date = new Date();
|
3 |
let h = date.getHours(); // 0 - 23
|
@@ -18,7 +21,14 @@ function showTime() {
|
|
18 |
m = (m < 10) ? "0" + m : m;
|
19 |
s = (s < 10) ? "0" + s : s;
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
document.getElementById("MyClockDisplay").innerText = time;
|
23 |
document.getElementById("MyClockDisplay").textContent = time;
|
24 |
|
@@ -42,4 +52,12 @@ function changeFont(font) {
|
|
42 |
document.querySelector('.clock').style.fontFamily = font;
|
43 |
}
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
showTime();
|
|
|
1 |
+
let showSeconds = true;
|
2 |
+
let showAmPm = true;
|
3 |
+
|
4 |
function showTime() {
|
5 |
const date = new Date();
|
6 |
let h = date.getHours(); // 0 - 23
|
|
|
21 |
m = (m < 10) ? "0" + m : m;
|
22 |
s = (s < 10) ? "0" + s : s;
|
23 |
|
24 |
+
let time = h + ":" + m;
|
25 |
+
if (showSeconds) {
|
26 |
+
time += ":" + s;
|
27 |
+
}
|
28 |
+
if (showAmPm) {
|
29 |
+
time += " " + session;
|
30 |
+
}
|
31 |
+
|
32 |
document.getElementById("MyClockDisplay").innerText = time;
|
33 |
document.getElementById("MyClockDisplay").textContent = time;
|
34 |
|
|
|
52 |
document.querySelector('.clock').style.fontFamily = font;
|
53 |
}
|
54 |
|
55 |
+
function toggleSeconds() {
|
56 |
+
showSeconds = !showSeconds;
|
57 |
+
}
|
58 |
+
|
59 |
+
function toggleAmPm() {
|
60 |
+
showAmPm = !showAmPm;
|
61 |
+
}
|
62 |
+
|
63 |
showTime();
|