mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-03-06 08:47:25 +08:00
Update script.js
This commit is contained in:
parent
1a9df7e9e8
commit
6c0ba76e4c
@ -1,4 +1,5 @@
|
||||
var request;
|
||||
var booting = false;
|
||||
var interval = 1000;
|
||||
|
||||
function getInfo() {
|
||||
@ -53,8 +54,13 @@ function processInfo() {
|
||||
|
||||
var msg = request.responseText;
|
||||
if (msg == null || msg.length == 0) {
|
||||
setInfo("Booting DSM instance", true);
|
||||
setTimeout(getInfo, interval);
|
||||
|
||||
if (booting) {
|
||||
schedule();
|
||||
return true;
|
||||
}
|
||||
|
||||
document.location.reload();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,7 +72,7 @@ function processInfo() {
|
||||
} else {
|
||||
processMsg(msg);
|
||||
if (msg.toLowerCase().indexOf("href=") == -1) {
|
||||
setTimeout(getInfo, interval);
|
||||
schedule();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -94,13 +100,23 @@ function setInfo(msg, loading, error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var el = document.getElementById("spinner");
|
||||
if (msg.includes("Booting ")) {
|
||||
booting = true;
|
||||
}
|
||||
|
||||
var el = document.getElementById("info");
|
||||
|
||||
if (el.innerText == msg || el.innerHTML == msg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var spin = document.getElementById("spinner");
|
||||
|
||||
error = !!error;
|
||||
if (!error) {
|
||||
el.style.visibility = 'visible';
|
||||
spin.style.visibility = 'visible';
|
||||
} else {
|
||||
el.style.visibility = 'hidden';
|
||||
spin.style.visibility = 'hidden';
|
||||
}
|
||||
|
||||
loading = !!loading;
|
||||
@ -108,12 +124,7 @@ function setInfo(msg, loading, error) {
|
||||
msg = "<p class=\"loading\">" + msg + "</p>";
|
||||
}
|
||||
|
||||
el = document.getElementById("info");
|
||||
|
||||
if (el.innerHTML != msg) {
|
||||
el.innerHTML = msg;
|
||||
}
|
||||
|
||||
el.innerHTML = msg;
|
||||
return true;
|
||||
|
||||
} catch (e) {
|
||||
@ -133,6 +144,10 @@ function reload() {
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function schedule() {
|
||||
setTimeout(getInfo, interval);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
|
||||
var wsUrl = getURL() + "/status";
|
||||
@ -165,8 +180,11 @@ function connect() {
|
||||
|
||||
ws.onerror = function(e) {
|
||||
ws.close();
|
||||
if (!booting) {
|
||||
document.location.reload();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
getInfo();
|
||||
schedule();
|
||||
connect();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user