<!DOCTYPE html>
<html>
<body>
<h1>Status</h1>
<button type="btnStart" onclick="sendStatusChange(true)">Start</button>
<button type="btnStop" onclick="sendStatusChange(false)">Stop</button>
<h1>Logs</h1>
<pre id="minecraft_log">
</pre>
</body>
</html>
<script>
function sendStatusChange(status) {
var http = new XMLHttpRequest();
var url = "/minecraft-status";
var data = JSON.stringify(
{ status: status}
)
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
// send the collected data as JSON
http.send(data);
}
function refreshLog() {
fetch("/minecraft-log")
.then(res => res.json())
.then((out) => {
document.getElementById('minecraft_log').innerText = out.log;
})
.catch(err => { throw err });
setTimeout(refreshLog, 500);
}
setTimeout(refreshLog, 500);
</script>