-
Notifications
You must be signed in to change notification settings - Fork 3
/
terminal.html
80 lines (75 loc) · 2.14 KB
/
terminal.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>JS-Term</title>
<link rel="shortcut icon" href="/favicon.ico">
<style>
html {
overflow-y: scroll;
}
html, body {
padding: 0;
padding-bottom: 30px;
margin: 0;
font-family: monospace;
}
#terminal {
white-space: pre;
overflow: hidden;
/*max-height: 704px;*/ /* if you need to disable scrollbar, ie. terminal codes does this inside Nano, Vim, Emacs, etc. */
}
#terminal > div {
height: 1.25em;
line-height: 1.25em;
}
</style>
<script src='jquery-1.4.4.min.js'></script>
<script src='termemul.js'></script>
<script>
$(function() {
var term = termemul.JQueryTerminal('#terminal');
term.theme(term.themes['Tango']);
term.write('Welcome to the rabbit hole…\r\n\r\n');
/*
// Simple echo terminal
term.write('\r\n> ');
term.oninput = function(data) {
term.write(data.replace('\r', '\r\n> ').replace('\b', '\b \b'));
};
*/
// Online terminal
var ws = new WebSocket('ws://' + location.host + location.pathname);
var keepalive = null;
ws.onopen = function() {
term.oninput = function(data) {
//console.log('send ' + JSON.stringify(data));
ws.send(data);
};
clearInterval(keepalive);
keepalive = setInterval(function() {
ws.send(''); // Connection keep-alive packet every 10 second.
}, 30000);
};
ws.onclose = function() {
clearInterval(keepalive);
keepalive = null;
term.oninput = null;
term.write('\r\n\n\u001B[0;1mCONNECTION CLOSED. \u001B[0m');
};
ws.onmessage = function(e) {
//console.log('recieve ' + JSON.stringify(e.data));
term.write(e.data);
};
});
</script>
</head>
<body class='a0088'>
<div id='terminal'></div>
<object id="beep" type="application/x-shockwave-flash" data="flashbeep-general.swf" width="1" height="1">
<param name="movie" value="flashbeep-general.swf" />
<param name="FlashVars" value="onLoad=isReady" />
</object>
<!-- maybe use textarea for keyboard input: paste text, possible to use Ctrl+Alt+Shift+U in Linux, and other stuff?? ... -->
</body>
</html>