Standby / script.js
TIMBOVILL's picture
Update script.js
397ee41 verified
raw
history blame
1.06 kB
function showTime() {
const date = new Date();
let h = date.getHours(); // 0 - 23
let m = date.getMinutes(); // 0 - 59
let s = date.getSeconds(); // 0 - 59
let session = "AM";
if (h == 0) {
h = 12;
}
if (h > 12) {
h = h - 12;
session = "PM";
}
h = (h < 10) ? "0" + h : h;
m = (m < 10) ? "0" + m : m;
s = (s < 10) ? "0" + s : s;
const time = h + ":" + m + ":" + s + " " + session;
document.getElementById("MyClockDisplay").innerText = time;
document.getElementById("MyClockDisplay").textContent = time;
setTimeout(showTime, 1000);
}
function toggleMenu() {
const menu = document.getElementById('menu');
if (menu.style.display === 'none' || menu.style.display === '') {
menu.style.display = 'flex';
} else {
menu.style.display = 'none';
}
}
function changeColor(color) {
document.querySelector('.clock').style.color = color;
}
function changeFont(font) {
document.querySelector('.clock').style.fontFamily = font;
}
showTime();