format html + put js in static
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
var start = function (url) {
|
||||
|
||||
var es = new ReconnectingEventSource(url);
|
||||
|
||||
es.onopen = function () {
|
||||
console.log('connected');
|
||||
};
|
||||
|
||||
es.addEventListener('stream-error', function (e) {
|
||||
es.close();
|
||||
message = JSON.parse(e.data);
|
||||
console.log('stream error: ' + message.condition + ': ' + message.text);
|
||||
}, false);
|
||||
|
||||
es.onerror = function (e) {
|
||||
console.log('connection error');
|
||||
};
|
||||
|
||||
// listening on `message` events and update the corresponding table line.
|
||||
// If the status is `FAILED`, we reload the window to ensure a new csrf_token.
|
||||
es.addEventListener('message', function (e) {
|
||||
message = JSON.parse(e.data);
|
||||
console.log("id: " + message.id);
|
||||
console.log("status: " + message.status);
|
||||
|
||||
const tr = document.getElementById(message.id);
|
||||
if (tr) {
|
||||
var th = tr.querySelector("th[name='status']");
|
||||
th.innerHTML = message.status;
|
||||
|
||||
if (message.status == "FAILED") {
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
}, false);
|
||||
};
|
||||
Reference in New Issue
Block a user