From 69f2c0544e80ae1b47a715b3d8e586ac2bfffe98 Mon Sep 17 00:00:00 2001 From: kondou Date: Thu, 4 Jul 2013 14:28:12 +0200 Subject: [PATCH] Refresh if maintenance mode is over Using status.php for this. I modified status.php to also show, whether we're in maintenance. Checks every 20 seconds if maintenance is over, if yes: reload. --- core/js/maintenance-check.js | 20 ++++++++++++++++++++ core/templates/update.user.php | 2 +- lib/base.php | 1 + status.php | 4 +++- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 core/js/maintenance-check.js diff --git a/core/js/maintenance-check.js b/core/js/maintenance-check.js new file mode 100644 index 00000000000..8ca00456fef --- /dev/null +++ b/core/js/maintenance-check.js @@ -0,0 +1,20 @@ +// Check every 20 seconds via status.php if maintenance is over +window.setInterval(checkStatus, 20000); + +function checkStatus() { + var request = new XMLHttpRequest(); + var ocroot = location.pathname.substr( + 0, location.pathname.indexOf('index.php') + ); + request.open("GET", ocroot+'status.php', true); + request.send(); + request.onreadystatechange = function() { + if (request.readyState === 4) { + var response = request.responseText; + var responseobj = JSON.parse(response); + if (responseobj.maintenance === 'false') { + window.location.reload(); + } + } + }; +} diff --git a/core/templates/update.user.php b/core/templates/update.user.php index bb93f0fad00..77a5892e174 100644 --- a/core/templates/update.user.php +++ b/core/templates/update.user.php @@ -1,7 +1,7 @@