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.step) { var status = response.step; 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();