maintenance-check.js 572 B

1234567891011121314151617181920
  1. // Check every 20 seconds via status.php if maintenance is over
  2. window.setInterval(checkStatus, 20000);
  3. function checkStatus() {
  4. var request = new XMLHttpRequest();
  5. var ocroot = location.pathname.substr(
  6. 0, location.pathname.indexOf('index.php')
  7. );
  8. request.open("GET", ocroot+'status.php', true);
  9. request.send();
  10. request.onreadystatechange = function() {
  11. if (request.readyState === 4) {
  12. var response = request.responseText;
  13. var responseobj = JSON.parse(response);
  14. if (responseobj.maintenance === 'false') {
  15. window.location.reload();
  16. }
  17. }
  18. };
  19. }