-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·60 lines (54 loc) · 1.66 KB
/
index.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
<html>
<style type="text/css">
body {
background-color: #4591d0;
padding: 20px;
font-family: -apple-system;
color: white;
}
h1 {
font-size: 65px;
font-weight: 700;
margin: 0;
padding: 0;
}
span {
line-height: 20px;
padding-bottom: 20px;
font-family: -apple-system;
}
</style>
<body>
<h1>Lake Server</h1>
<pre><span id='output-text'></span></pre>
<script>
var HOST = location.origin.replace(/^http/, 'ws')
var ws = new WebSocket(HOST);
var element = document.getElementById('output-text');
ws.onopen = function(event) {
ws.send("LAKE_SERVER|server|pairCode|SERVER_VIEWER|" + String(navigator.userAgent));
};
ws.onmessage = function(event) {
var date = new Date();
var dateString = date.toLocaleTimeString();
if (event.data instanceof Blob) {
var reader = new FileReader();
reader.onload = function() {
var jsonPretty = JSON.stringify(JSON.parse(this.result), null, '\t');
var newText = dateString + "<br>" + jsonPretty;
element.innerHTML = element.innerHTML + "<br><br>" + newText;
};
reader.readAsText(event.data);
} else if (event.data.includes(' Connected')) {
var newText = dateString + ": " + event.data;
element.innerHTML = element.innerHTML + "<br><br>" + newText;
} else if (event.data.includes('LAKE_SERVER|server|status|')) {
var newText = dateString + ": " + event.data;
element.innerHTML = element.innerHTML + "<br><br>" + newText.replace('LAKE_SERVER|server|status|', '');
} else {
console.log(event.data);
}
};
</script>
</body>
</html>