-
Notifications
You must be signed in to change notification settings - Fork 72
/
wsirc.html
98 lines (79 loc) · 3.26 KB
/
wsirc.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
<html>
<head>
<title>IRC Client using WebSockets</title>
<script src="include/websock.js"></script>
<script src="include/util.js"></script>
<script src="include/webutil.js"></script>
<script src="include/keysym.js"></script>
<script src="include/VT100.js"></script>
<script src="include/wsirc.js"></script>
<!-- Uncomment to activate firebug lite -->
<!--
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
-->
</head>
<body>
Host: <input id='host' style='width:100'>
Port: <input id='port' style='width:50'>
Encrypt: <input id='encrypt' type='checkbox'>
<input id='connectButton' type='button' value='Connect' style='width:100px'>
<br>
Nick: <input id='nick' style='width:120'>
<br>
Channel: #<input id='channel' style='width:70'>
<br><br>
<div><pre id="irc"></pre></div>
>
<input id="msg" type="text" size=80 onkeypress="sendMsg();">
<script>
var irc;
function sendMsg() {
if (event.keyCode === 13) {
var msg = $D('msg').value;
$D('msg').value = "";
Util.Debug("calling sendMsg('" + msg + "')");
irc.sendMsg(msg);
}
}
function connect() {
var ret;
ret = irc.connect($D('host').value,
$D('port').value,
$D('encrypt').checked,
$D('nick').value,
$D('channel').value);
if (! ret) { return false; }
$D('connectButton').disabled = true;
$D('connectButton').value = "Connecting";
}
function disconnect() {
$D('connectButton').disabled = true;
$D('connectButton').value = "Disconnecting";
irc.disconnect();
}
function connected() {
$D('msg').disabled = false;
$D('connectButton').disabled = false;
$D('connectButton').value = "Disconnect";
$D('connectButton').onclick = disconnect;
}
function disconnected() {
$D('msg').disabled = true;
$D('connectButton').disabled = false;
$D('connectButton').value = "Connect";
$D('connectButton').onclick = connect;
}
window.onload = function() {
console.log("onload");
var url = document.location.href;
$D('host').value = (url.match(/host=([^&#]*)/) || ['',''])[1];
$D('port').value = (url.match(/port=([^&#]*)/) || ['',''])[1];
$D('nick').value = (url.match(/nick=([^&#]*)/) || ['',''])[1];
$D('channel').value = (url.match(/channel=([^&#]*)/) || ['',''])[1];
disconnected();
irc = IRC('irc', connected, disconnected);
}
</script>
</body>
</html>