omlapp/Open Media Library.app/Contents/Resources/static/js/install.js
2014-08-05 11:06:39 +02:00

38 lines
1.1 KiB
JavaScript

function load() {
var base = 'http://[::1]:9842',
img = new Image();
img.onload = function(event) {
document.location.href = base;
};
img.src = base + '/static/oxjs/build/Ox.UI/png/transparent.png?' + new Date;
};
function update() {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var response = JSON.parse(this.responseText);
if (response.installing) {
var status = response.installing;
if (response.progress) {
status = parseInt(response.progress * 100) + '% ' + status;
}
document.getElementById('status').innerHTML = status;
setTimeout(update, 1000);
} else {
document.getElementById('status').innerHTML = "done";
load();
}
};
xhr.onerror = function() {
var status = document.getElementById('status').innerHTML;
if (['done', 'setup'].indexOf(status) == -1) {
document.getElementById('status').innerHTML = "error";
}
load();
}
xhr.open('get', '/status');
xhr.send();
}
update();