Better restart/shutdown refresh page polling

This commit is contained in:
JonnyWong16 2017-12-09 22:32:39 -08:00
commit b76143116c

View file

@ -54,34 +54,31 @@
window.location.href = "${new_http_root}index"; window.location.href = "${new_http_root}index";
} }
// Redirect to home page if page is available. var online = true;
var checkOnline = setInterval(checkPageOffline, 1000);
function checkPageOffline() { (function poll() {
$.ajax({ setTimeout(function () {
type: 'HEAD', $.ajax({
url: 'index', url: 'index',
timeout: 1000, type: 'HEAD',
error: function () { success: function () {
% if signal != 'shutdown': if (!(online)){
clearInterval(checkOnline); reloadPage();
setInterval(checkPageOnline, 1000); }
% else: },
reloadPage(); error: function () {
% endif online = false;
} % if signal == 'shutdown':
}); reloadPage();
} % endif
function checkPageOnline() { },
$.ajax({ complete: function () {
type: 'HEAD', poll();
url: 'index', },
timeout: 1000, timeout: 1000
success: function () { });
reloadPage(); }, 1000);
} })();
});
}
</script> </script>
</%def> </%def>