-
Notifications
You must be signed in to change notification settings - Fork 0
/
hterm.html
60 lines (57 loc) · 1.26 KB
/
hterm.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
<!DOCTYPE html>
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script src="hterm_all.js"></script>
<style>
terminal {
display: block;
position: relative;
height: 100%;
width: 100%;
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div id='terminal'></div>
<script>
function setupHterm() {
const term = new hterm.Terminal();
term.onTerminalReady = function() {
const hio = this.io.push();
var socket=io();
hio.onVTKeystroke = (string) => {
switch (string) {
case '\r':
socket.emit("chat message",string);
break;
default:
//io.print(string);
socket.emit("chat message",string);
break;
}
};
hio.sendString = hio.print;
this.setCursorVisible(true);
this.keyboard.characterEncoding = 'raw';
this.keyboard.bindings.addBinding('F11', 'PASS');
this.keyboard.bindings.addBinding('Ctrl-R', 'PASS');
socket.on("chat message",function(msg) {
hio.print(msg);
});
};
term.decorate(document.querySelector('#terminal'));
term.setHeight(25)
term.setWidth(80)
term.installKeyboard();
window.term_ = term;
}
window.onload = function() {
lib.init(setupHterm);
};
</script>
</body>
</html>