-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservers.html
60 lines (60 loc) · 1.98 KB
/
servers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<div id='data'>
</div>
<hr>
<div>
<input id='kick' />
<button id='kick-button'>Kick Player</button>
<hr>
<input id='crash' />
<button id='crash-button'>Reset Server</button>
<script>
var socket2 = new WebSocket('wss://'+window.location.hostname+'/server');
var kick = document.getElementById('kick');
var crash = document.getElementById('crash');
document.getElementById('kick-button').addEventListener('click', function() {
socket2.send(JSON.stringify({
operation: 'status',
task: 'admin-kick',
username: sessionStorage.username,
token: sessionStorage.token,
victim: kick.value,
}))
});
document.getElementById('crash-button').addEventListener('click', function() {
socket2.send(JSON.stringify({
operation: 'status',
task: 'admin-crash',
username: sessionStorage.username,
token: sessionStorage.token,
channel: crash.value,
}))
})
</script>
</div>
<hr>
<script>
var socket = new WebSocket('wss://'+window.location.hostname+'/server');
var output = document.getElementById('data');
socket.onopen = function() {
socket.send('{"operation":"status", "task":"admin-servers", "username":"'+sessionStorage.username+'", "token":"'+sessionStorage.token+'"}');
socket.onmessage = function(data) {
data = JSON.parse(data.data);
servers = data.servers;
output.innerHTML += 'Total Servers: '+data.serversOnline;
var l = 0;
while (l<servers.length) {
var div = document.createElement('DIV');
div.setAttribute('class', 'server');
div.innerHTML += '<br>Server IP: ' + servers[l].serverRoom + '<br>' + 'Player Count: ' + servers[l].playerNum + '<br>' + 'Players:';
var q = 0;
while (q<servers[l].players.length) {
div.innerHTML += '<br>' + servers[l].players[q];
q++;
}
output.appendChild(div);
l++;
}
socket.onmessage = function() {}
}
}
</script>