Auto redirect if available before countdown on state change

This commit is contained in:
JonnyWong16 2016-10-11 19:18:15 -07:00 committed by JonnyWong16
parent 27183483a9
commit d47daba8c1
2 changed files with 46 additions and 15 deletions

View file

@ -35,19 +35,50 @@
</div>
</div>
</%def>
<%def name="javascriptIncludes()">
<script>
// Use p.countdown as container, pass redirect, duration, and optional message
$(".countdown").countdown(reloadPage, ${timer}, "");
$('#state-change-modal').modal({
keyboard: false
})
// Make modal visible
$('#state-change-modal').modal('show')
// Redirect to home page after countdown.
function reloadPage() {
window.location.href = "${new_http_root}index";
}
</script>
<%def name="javascriptIncludes()">
<script>
// Use p.countdown as container, pass redirect, duration, and optional message
$(".countdown").countdown(reloadPage, ${timer}, "");
$('#state-change-modal').modal({
keyboard: false
})
// Make modal visible
$('#state-change-modal').modal('show')
// Redirect to home page after countdown.
function reloadPage() {
window.location.href = "${new_http_root}index";
}
// Redirect to home page if page is available.
var checkOnline = setInterval(checkPageOffline, 1000);
function checkPageOffline() {
$.ajax({
type: 'HEAD',
url: 'index',
timeout: 1000,
error: function () {
% if signal != 'shutdown':
clearInterval(checkOnline);
setInterval(checkPageOnline, 1000);
% else:
reloadPage();
% endif
}
});
}
function checkPageOnline() {
$.ajax({
type: 'HEAD',
url: 'index',
timeout: 1000,
success: function () {
reloadPage();
}
});
}
</script>
</%def>

View file

@ -3324,7 +3324,7 @@ class WebInterface(object):
else:
new_http_root = '/'
return serve_template(templatename="shutdown.html", title=title,
return serve_template(templatename="shutdown.html", signal=signal, title=title,
new_http_root=new_http_root, message=message, timer=timer, quote=quote)
@cherrypy.expose