Add site to git repo
This commit is contained in:
21
js/getLog.js
Normal file
21
js/getLog.js
Normal file
@@ -0,0 +1,21 @@
|
||||
var output = document.getElementById('server-log');
|
||||
|
||||
function reqListener() {
|
||||
var autoScroll = document.getElementById('auto-scroll');
|
||||
output.textContent = xhr.responseText;
|
||||
if (autoScroll.checked) {
|
||||
output.scrollTop = output.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener('load', reqListener);
|
||||
xhr.open('GET', '/server.log');
|
||||
xhr.send();
|
||||
|
||||
setInterval(function() {
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener('load', reqListener);
|
||||
xhr.open('GET', '/server.log');
|
||||
xhr.send();
|
||||
}, 10000);
|
||||
29
js/getStatus.js
Normal file
29
js/getStatus.js
Normal file
@@ -0,0 +1,29 @@
|
||||
MinecraftAPI.getServerStatus('panic-shack.hallada.net', {
|
||||
port: 25565
|
||||
}, function (err, status) {
|
||||
var serverError = document.getElementById('server-status-error');
|
||||
var serverStatus = document.getElementById('server-status');
|
||||
|
||||
if (err) {
|
||||
serverError.style.color = 'red';
|
||||
return serverError.textContent = 'Error loading server status';
|
||||
} else {
|
||||
serverError.style.display = 'none';
|
||||
}
|
||||
|
||||
serverStatus.style.display = 'block';
|
||||
|
||||
if (status.online == true) {
|
||||
document.getElementById('status-online').style.display = 'inline-block';
|
||||
document.getElementById('status-offline').style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('status-motd').textContent = status.motd;
|
||||
document.getElementById('status-players-now').textContent = status.players.now;
|
||||
document.getElementById('status-players-max').textContent = status.players.max;
|
||||
document.getElementById('status-server-name').textContent = status.server.name;
|
||||
document.getElementById('info-server-name').textContent = status.server.name;
|
||||
document.getElementById('status-server-protocol').textContent = status.server.protocol;
|
||||
document.getElementById('status-last-online').textContent = moment.unix(parseInt(status.last_online, 10)).fromNow();
|
||||
document.getElementById('status-last-updated').textContent = moment.unix(parseInt(status.last_updated, 10)).fromNow();
|
||||
});
|
||||
Reference in New Issue
Block a user