| <html> |
| |
| <head> |
| <title>IRC Client using WebSockets</title> |
| <script src="include/base64.js"></script> |
| <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> |