mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-15 18:12:08 -05:00
Update js/main.js
This commit is contained in:
parent
171563771f
commit
0a01c76f22
42
js/main.js
42
js/main.js
@ -116,21 +116,37 @@ function delPassword() {
|
|||||||
localStorage.removeItem("selenite.password");
|
localStorage.removeItem("selenite.password");
|
||||||
}
|
}
|
||||||
|
|
||||||
function initTime() {
|
function getCurrentTime() {
|
||||||
setInterval(() => {
|
const n = document.getElementById("time");
|
||||||
let date = new Date();
|
|
||||||
let options = localStorage.getItem("selenite.timeFormat")
|
fetch("https://worldtimeapi.org/api/ip")
|
||||||
? JSON.parse(localStorage.getItem("selenite.timeFormat"))
|
.then(response => response.json())
|
||||||
: {
|
.then(data => {
|
||||||
hour: "2-digit",
|
const t = new Date(data.utc_datetime);
|
||||||
minute: "2-digit",
|
const formattedTime = t.toLocaleTimeString(undefined, {
|
||||||
hour12: true,
|
hour: "numeric",
|
||||||
};
|
minute: "numeric",
|
||||||
let time = date.toLocaleTimeString([], options);
|
second: "numeric",
|
||||||
document.getElementById("time").innerText = time;
|
hour12: true
|
||||||
}, 100);
|
});
|
||||||
|
n.textContent = formattedTime;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
|
||||||
|
const currentTime = new Date();
|
||||||
|
const formattedTime = currentTime.toLocaleTimeString(undefined, {
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
second: "numeric",
|
||||||
|
hour12: true
|
||||||
|
});
|
||||||
|
n.textContent = formattedTime;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCurrentTime();
|
||||||
|
setInterval(getCurrentTime, 900);
|
||||||
|
|
||||||
let cookieConsentScript = document.createElement("script");
|
let cookieConsentScript = document.createElement("script");
|
||||||
cookieConsentScript.src = "/js/cookieConsent.js";
|
cookieConsentScript.src = "/js/cookieConsent.js";
|
||||||
document.head.appendChild(cookieConsentScript);
|
document.head.appendChild(cookieConsentScript);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user