MaketTahta/assets/js/updates.js
2023-10-26 01:26:55 +03:00

47 lines
No EOL
1.8 KiB
JavaScript

/**
* Update components with conf variables each second
*/
function updateComponents() {
setToID("time", updateTime());
if (curHour == 12 && (curMin >= 24 && curMin <= 30)) {
document.getElementById("time").style.color = "red";
document.getElementById("rainbow").style.display = "inherit";
} else {
document.getElementById("time").style.color = "inherit";
document.getElementById("rainbow").style.display = "none";
}
let timer = document.getElementById("stopwatch").getElementsByClassName("timer")[0];
if (confs.get("timerMsec") == 1) {
timer.getElementsByClassName("msec")[0].style.display = "flex";
document.getElementById("stopwatch-msec-dot").style.display = "flex";
} else {
timer.getElementsByClassName("msec")[0].style.display = "none";
document.getElementById("stopwatch-msec-dot").style.display = "none";
}
}
function updateTime() {
var d = new Date();
curHour = getDigits(d.getHours(), 2);
curMin = getDigits(d.getMinutes(), 2);
curSeconds = getDigits(d.getSeconds(), 2);
if (confs.get("clockSecond") == "1") {
return curHour + "." + curMin + "." + curSeconds;
} else {
return curHour + "." + curMin;
}
}
function DEVupdateSettings() {
let devData =
"<b>confs:</b> " + JSON.stringify(confs, (key, value) => (value instanceof Map ? [...value] : value)) + "<br>" +
"<b>schoolPeriods:</b> " + JSON.stringify(schoolPeriods, (key, value) => (value instanceof Map ? [...value] : value)) + "<br>" +
"<b>specialPeriods:</b> " + JSON.stringify(specialPeriods, (key, value) => (value instanceof Map ? [...value] : value)) + "<br>" +
"<b>info:</b> " + navigator.userAgent + "<br>" +
"<b>local-settings:</b>" + (urlParams = new URLSearchParams(window.location.search)) + "<br>";
document.getElementById("DEV").innerHTML = devData;
}