mirror of
https://github.com/YouHaveTrouble/youhavetrouble.github.io.git
synced 2026-05-11 22:06:56 +00:00
js readability and transition between avatar bg colors
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
const status = document.querySelector("#status");
|
||||
const action = document.querySelector("#status-action");
|
||||
const avatar = document.querySelector(".avatar img");
|
||||
const avatar = document.querySelector(".avatar");
|
||||
|
||||
updateStatus();
|
||||
window.setInterval(updateStatus, 10000);
|
||||
|
||||
async function updateStatus() {
|
||||
const result = await fetch("https://api.youhavetrouble.me/online");
|
||||
|
||||
if (result.status !== 200) return;
|
||||
|
||||
const json = await result.json();
|
||||
if (json.steam.status === "ONLINE") {
|
||||
status.innerText = "Currently Online";
|
||||
action.innerText = "";
|
||||
setavatarBg("online")
|
||||
return;
|
||||
}
|
||||
if (json.steam.status === "IN_GAME") {
|
||||
status.innerText = "Currently Online";
|
||||
action.innerText = `Playing ${json.steam.game}`;
|
||||
setavatarBg("online")
|
||||
return;
|
||||
switch (json.steam.status) {
|
||||
case "ONLINE":
|
||||
status.innerText = "Currently Online";
|
||||
action.innerText = "";
|
||||
setavatarBg("online")
|
||||
return;
|
||||
case "IN_GAME":
|
||||
status.innerText = "Currently Online";
|
||||
action.innerText = `Playing ${json.steam.game}`;
|
||||
setavatarBg("online")
|
||||
return;
|
||||
}
|
||||
|
||||
if (json.discord === "DO_NOT_DISTURB" || json.discord === "ONLINE") {
|
||||
status.innerText = "Currently Online";
|
||||
action.innerText = "";
|
||||
|
||||
Reference in New Issue
Block a user