Clock/update.js

37 lines
866 B
JavaScript
Raw Normal View History

2022-09-13 15:57:56 +00:00
var prevSha = localStorage.getItem("commitsha") ?? "ThisShouldntBeASHA";
setInterval(reqData, 60000);
2022-09-13 15:57:56 +00:00
2022-09-13 18:13:11 +00:00
//balls lmao
2022-09-13 15:57:56 +00:00
function reqData() {
const XHR = new XMLHttpRequest();
XHR.addEventListener("load", (event) => {
var resp = event.target.response;
2022-09-13 15:57:56 +00:00
if (event.target.status.toString().includes("40")) {
console.log(event.target.status + " error :[")
return;
}
if (resp != prevSha) {
2022-09-13 15:57:56 +00:00
if (prevSha == "ThisShouldntBeASHA") {
localStorage.setItem("commitsha", resp);
2022-09-13 15:57:56 +00:00
} else {
document.querySelector("#updatedialog").classList.add("open");
localStorage.setItem("commitsha", resp);
2022-09-13 15:57:56 +00:00
}
}
});
XHR.addEventListener("error", (event) => {
console.log('Oops! Something went wrong.');
});
XHR.open("GET", "https://ClockCheckGithub.meowcatheorange.repl.co");
2022-09-13 15:57:56 +00:00
XHR.send();
}
reqData();