-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace.html
120 lines (111 loc) · 2.91 KB
/
trace.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<html>
<head>
<title>Trace Orkester</title>
</head>
<body>
<div class="top-menu">
<div style="display: flex;">
<div>
<div>
<label for="host">Host</label>
<input id="host" name="host" value="localhost">
</div>
<div>
<label for="port">Port</label>
<input id="port" name="port" value="9998">
</div>
</div>
<div style="display: flex; flex-direction: column;">
<button id="button-connect" type="button">Connect</button>
<button id="button-clear" type="button">Clear</button>
</div>
</div>
<input id="reset" type="checkbox" name="reset" value="reset">
<label For="reset">Clear on [RESET_LOG_MESSAGES]</label>
</div>
<div id="content">
</div>
</body>
<style>
body {
margin-top: 0;
margin-left: 0;
height: fit-content;
}
#host {
width: 10rem;
}
#port {
margin-left: 3px;
width: 3rem;
}
.top-menu {
position: fixed;
top: 0;
z-index: 1;
background-color: gray;
height: 80px;
width: 100vw;
}
#content {
margin-top: 80px;
position: relative;
}
.log-message {
border: 1px ridge;
white-space: break-spaces;
overflow-wrap: break-word
}
.DEBUG {
color: blue;
}
.WARN {
color: yellow;
}
.FATAL {
color: red;
font-weight: bold;
}
</style>
<script src="trace.js"></script>
<script>
const hostInput = document.getElementById("host");
const portInput = document.getElementById("port");
const connectButton = document.getElementById("button-connect");
let socket = undefined;
let isConnected = false;
connectButton.onclick = function () {
if (isConnected) {
socket.close();
isConnected = false;
}
try {
socket = connect(
hostInput.value,
portInput.value,
{
DEBUG: "color: blue"
},
[],
undefined
)
socket.addEventListener("open", event => {
isConnected = true;
connectButton.innerHTML = "Disconnect";
});
socket.addEventListener("error", event => {
console.error(event)
isConnected = false;
connectButton.innerHTML = "Error!"
})
socket.addEventListener("close", event => {
isConnected = false;
connectButton.innerHTML = "Connect"
})
isConnected = true
} catch (e) {
console.error(e)
}
};
</script>
</html>