<!DOCTYPE html>

<html>
	<head>
		<meta charset="UTF-8" />
		<title>Maloja - Please wait</title>
		<link rel="stylesheet" href="maloja.css" />
	</head>
	
	<body>
		<table class="top_info">
			<tr>
				
				<td class="text">
					<h1>Maloja</h1><br/>
					<span>Redbuilding the database</span>
					
					<p>Please wait...</p>
				</td>
			</tr>
		</table>
		
		
	</body>
	
	<script>
		var pending = false;
		setInterval(probeServer,1500);
	
		function probeServer() {
			if (!pending) {
				console.log("Probing...");
				pending = true;
				var xhttp = new XMLHttpRequest();
				xhttp.open("GET","/db/test", true);
				xhttp.onreadystatechange = goback;
				xhttp.send();
				
			}
			
		}
		
		function goback() {
			if ((this.readyState == 4) && (this.status == 205)) {
				console.log("Not ready yet!")
				pending = false;
			}
			if ((this.readyState == 4) && (this.status == 204)) {
				console.log("K");
				pending = false;
				window.location = "/issues";
			}
		}
	
	</script>
</html>