-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebtail.html
42 lines (42 loc) · 1.11 KB
/
webtail.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
<!DOCTYPE html>
<html>
<head>
<title>Webtail</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<style>
pre.line {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="fileData"></div>
<script type="text/javascript">
(function() {
var data = $("#fileData");
function onclose(evt) {
data.text('Connection closed');
conn = new WebSocket("ws://{{.Host}}/ws");
data.empty();
conn.onclose = onclose;
conn.onmessage = onmessage;
};
function onmessage(evt) {
console.log('file updated');
if (evt.data == "\n") {
data.append("<pre class='blank'>"+evt.data+"</pre>");
} else {
data.append("<pre class='line'>"+evt.data+"</pre>");
}
};
var conn = new WebSocket("ws://{{.Host}}/ws");
conn.onclose = onclose
conn.onmessage = onmessage
$("#fileName").change(function() {
conn.close()
});
})();
</script>
</body>
</html>