summaryrefslogtreecommitdiffstats
path: root/core/js/maintenance-check.js
blob: 8ca00456fef9af1ecf652a99437fbe39d511e44c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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();
			}
		}
	};
}