Skip to content

Commit

Permalink
Web interface "loading..." banner
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacehuhn committed Jan 31, 2021
1 parent 8b99fcb commit 60be948
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web_interface/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ function convertLineBreaks(str) {
return "";
}

function showMessage(msg, closeAfter) {
function showMessage(msg) {
if (msg.startsWith("ERROR")) {
getE("status").style.backgroundColor = "#d33";
getE("status").innerHTML = "disconnected";

console.error("disconnected (" + msg + ")");
} else if (msg.startsWith("LOADING")) {
getE("status").style.backgroundColor = "#fc0";
getE("status").innerHTML = "loading...";
} else {
getE("status").style.backgroundColor = "#3c5";
getE("status").innerHTML = "connected";
Expand Down Expand Up @@ -72,11 +75,14 @@ function getFile(adr, callback, timeout, method, onTimeout, onError) {
request.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
showMessage();
callback(this.responseText);
}
}
};

showMessage("LOADING");

/* send request */
request.send();

Expand Down

0 comments on commit 60be948

Please sign in to comment.