-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
82 lines (67 loc) · 1.84 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<html>
<head>
<title>WebSocket client</title>
<script src="jquery.min.js"></script>
<script src="jquery.terminal.min.js"></script>
<link href="jquery.terminal.min.css" rel="stylesheet"/>
<style>
.prompt {
color: #fff;
text-shadow: 0 0 3px rgba(0,100,0,50);
}
body {
margin: 0;
height: 99%%;
}
</style>
</head>
<body id="term"></body>
<script>
jQuery(function($, undefined) {
$('#term').terminal(function(command, term) {
if (command !== '') {
if (ws != undefined) {
term.echo("bye")
ws.close()
}
ws = undefined
var ws = new WebSocket(command)
ws.onopen = function(){
ws.onclose = function() {
term.pop()
}
ws.onerror = function() {
term.pop()
}
ws.onmessage = function (event) {
term.echo("<< [[;#0c0;#000]" + String(event.data) + "]")
}
term.resume()
term.push(function(command, term) {
ws.send(command)
}, {
name: 'wsconn',
prompt: "[[;#add8e6;#000]" + command + ":~$] ",
onExit: function(){
term.echo("Disconnected.")
ws.close()
}
})
}
var err = function(event){
term.resume()
}
ws.onclose = err
ws.onerror = err
term.pause()
} else {
term.echo('');
}
}, {
greetings: '[[gu;#add8e6;#000]WebSocket Client - netcat like]\n\n',
name: 'wsclient',
prompt: 'Connect to: '
});
});
</script>
</html>