2022-05-05 03:45:54 +00:00
|
|
|
var networkIssuesInformed = false;
|
|
|
|
|
2022-05-04 20:12:44 +00:00
|
|
|
function checkStatus(){
|
|
|
|
var status = document.getElementById("status");
|
|
|
|
sendCommand("", "ping").then(res => {
|
|
|
|
if (res.code == 200) {
|
|
|
|
status.classList.add("ready");
|
|
|
|
status.classList.remove("error");
|
|
|
|
document.getElementById("statusText").innerText = "Ready";
|
2022-05-05 03:45:54 +00:00
|
|
|
networkIssuesInformed = false;
|
2022-05-04 20:12:44 +00:00
|
|
|
} else {
|
|
|
|
throw new Error("");
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
status.classList.add("error");
|
|
|
|
status.classList.remove("ready");
|
|
|
|
document.getElementById("statusText").innerText = "Error";
|
2022-05-05 03:45:54 +00:00
|
|
|
if (!networkIssuesInformed) {
|
|
|
|
message("Network issue detected, you may request a new MojoConsole link in game.", "fail");
|
|
|
|
networkIssuesInformed = true;
|
|
|
|
}
|
2022-05-04 20:12:44 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-03 10:12:38 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
const sidebarItems = document.querySelector("#sidebar").children;
|
|
|
|
|
|
|
|
for (const item of sidebarItems) {
|
|
|
|
item.onclick = (e) => switchPage(e.target.dataset.value)
|
|
|
|
}
|
2022-05-04 20:12:44 +00:00
|
|
|
checkStatus();
|
2022-05-04 23:38:48 +00:00
|
|
|
setInterval(() => { // check console status
|
2022-05-04 20:12:44 +00:00
|
|
|
checkStatus();
|
|
|
|
}, 30 * 1000 );
|
2022-05-04 23:38:48 +00:00
|
|
|
// adjust frame height
|
2022-05-05 01:16:56 +00:00
|
|
|
setTimeout(() => {
|
2022-05-04 23:38:48 +00:00
|
|
|
var height = window.innerHeight
|
|
|
|
|| document.documentElement.clientHeight
|
|
|
|
|| document.body.clientHeight;
|
|
|
|
var content = document.getElementById("content");
|
|
|
|
height = height - content.getBoundingClientRect().y - 30;
|
|
|
|
content.style.height = height + "px";
|
|
|
|
|
2022-05-04 23:41:41 +00:00
|
|
|
message("Welcome to MojoConsolePlus!");
|
2022-05-05 01:16:56 +00:00
|
|
|
},10); // delay height modification to avoid issues
|
2022-05-04 23:38:48 +00:00
|
|
|
})
|