abtmtr-v4/views/projects/item/clock/update.js

25 lines
694 B
JavaScript

function reqData(start) {
console.log("Pinged API server. Starting: " + start);
var donedata = (e) => {
var resp = e;
var prevSha = "A";
if (!start) prevSha = window.sessionStorage.getItem("commitsha");
if (resp != prevSha) {
window.sessionStorage.setItem("commitsha", resp);
if (start) return;
document.querySelector(
"#updatesha"
).innerHTML = `from job v. ${prevSha} to job v. ${resp}`;
document.querySelector("#updatedialog").classList.add("open");
}
};
fetch_ask("https://ClockCheckGithub.meowcatheorange.repl.co")
.then((x) => x.text())
.then((y) => donedata(y));
}
setInterval(reqData, 60000);
reqData(true);