1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5
<meta http-equiv="content-type" content="text/html; charset=utf-8">
6
<script src="browsercheck.js"></script>
7
<script src="shared.js"></script>
8
<script src="switchStyle.js"></script>
9
<script src="jsjac.js"></script>
13
function submitClicked() {
14
var body = document.forms[0].elements["msgbox"].value;
16
if (body == '') // don't send empty message
19
var aMessage = new JSJaCMessage();
20
aMessage.setTo(parent.group);
23
if (body.match(/^\/say (.+)/)) {
28
aMessage.setBody(body);
29
aMessage.setType('groupchat');
30
parent.srcW.con.send(aMessage);
31
} else if (body.match(/^\/clear/)) {
35
parent.cFrame.body.innerHTML = '';
36
} else if (body.match(/^\/nick (.+)/)) {
40
var nick = body.replace(/^\/nick (.+)/,"$1");
41
var aPresence = new JSJaCPresence();
42
aPresence.setTo(parent.group+"/"+nick);
43
parent.srcW.con.send(aPresence);
44
} else if (body.match(/^\/topic (.+)/)) {
48
var topic = body.replace(/^\/topic (.+)/,"$1");
49
aMessage.setType('groupchat');
50
aMessage.setSubject(topic);
51
parent.srcW.con.send(aMessage);
52
} else if (body.match(/^\/ban (\S+)\s*(.*)/)) {
57
var reason = RegExp.$2;
59
var jid = parent.roster.getFullJIDByNick(nick);
61
parent.putMsgHTML("No such nick"+": " + nick, new Date().toLocaleTimeString(), parent.jid);
63
parent.changeAffiliation(jid,'outcast',false,reason);
65
} else if (body.match(/^\/kick (\S+)\s*(.*)/)) {
70
var reason = RegExp.$2;
72
var jid = parent.roster.getFullJIDByNick(nick);
74
parent.putMsgHTML("No such nick"+": " + nick, new Date().toLocaleTimeString(), parent.jid);
76
parent.changeRole(jid,'none',false,reason);
78
} else if (body.match(/^\/invite (\S+)\s*(.*)/)) { // [TODO]
83
var reason = RegExp.$2;
86
aMessage.appendNode('x',
87
{'xmlns': 'http://jabber.org/protocol/muc#user'});
88
var aNode = x.appendChild(aMessage.getDoc().createElement('invite'));
89
aNode.setAttribute('to',jid);
90
if (reason && reason != '')
91
aNode.appendChild(aMessage.getDoc().createElement('reason')).appendChild(aMessage.getDoc().createTextNode(reason));
92
parent.srcW.con.send(aMessage);
93
} else if (body.match(/^\/join (\S+)\s*(.*)/)) {
99
parent.srcW.openGroupchat(room,parent.nick,pass);
100
} else if (body.match(/^\/msg (\S+)\s*(.*)/)) {
104
var nick = RegExp.$1;
105
var body = RegExp.$2;
107
var jid = parent.roster.getFullJIDByNick(nick);
109
parent.putMsgHTML("No such nick"+": " + nick, new Date().toLocaleTimeString(), parent.jid);
111
aMessage.setType('chat');
113
aMessage.setBody(body);
114
parent.srcW.con.send(aMessage);
116
} else if (body.match(/^\/part\s*(.*)/)) {
121
var aPresence = new JSJaCPresence();
122
aPresence.setTo(parent.group);
123
aPresence.setType('unavailable');
124
if (msg && msg != '')
125
aPresence.setStatus(msg);
126
parent.srcW.con.send(aPresence);
127
} else if (body.match(/^\/whois (\S+)/)) {
131
var nick = RegExp.$1;
132
var jid = parent.roster.getFullJIDByNick(nick);
134
parent.putMsgHTML("No such nick"+": " + nick, new Date().toLocaleTimeString(), parent.jid);
136
parent.srcW.openUserInfo(jid);
137
} else if (body.match(/^\/help/)) {
141
open("http://www.jabber.org/jeps/jep-0045.html#impl-client-irc");
143
aMessage.setType('groupchat');
144
aMessage.setBody(body);
145
parent.srcW.con.send(aMessage);
148
// add message to our message history
149
parent.srcW.addtoHistory(body);
150
document.forms["chatform"].msgbox.value=''; // empty box
151
document.forms["chatform"].msgbox.focus(); // set focus back on input field
157
function openRegisterRoom() {
158
if (!rw || rw.closed)
159
rw = open("groupchat_register.html","rw"+makeWindowName(parent.jid),"width=300,height=400,resizable=yes");
166
function openInvite() {
167
if (!iw || iw.closed)
168
iw = open("groupchat_invite_dialog.html","iw"+makeWindowName(parent.group),"width=300,height=200");
174
if (iw && !iw.closed)
176
if (rw && !rw.closed)
180
function msgboxKeyPressed(el,e) {
182
if (window.event) { e = window.event; keycode = window.event.keyCode; }
183
else if (e) keycode = e.keyCode;
188
var txt = document.forms["chatform"].msgbox;
191
var possibilities = new Array();
195
pos1 = txt.selectionStart; // current cursor position
196
// no selection, not at the beginning of the line and at the end of a word or at the end of the line
197
if(pos1 == txt.selectionEnd && pos1 > 0 && (txt.value.substring(pos1, pos1+1) == ' ' || pos1 == txt.value.length)) {
198
part = txt.value.substring(0, pos1);
199
pos2 = part.lastIndexOf(" ") + 1;
201
part = part.substring(pos2, pos1);
205
for (i in top.roster.users) {
206
if(top.roster.users[i].name.indexOf(part) == 0)
207
possibilities.push(top.roster.users[i].name);
209
if(possibilities.length == 1) { // complete, if only one possibility has been found or enumerate possibilities
210
if(pos2 == 0) //special case: beginning of line, add additional ":"
211
txt.value = txt.value.substring(0, pos2) + possibilities.pop() + ": " + txt.value.substring(pos1, txt.value.length)
213
txt.value = txt.value.substring(0, pos2) + possibilities.pop() + " " + txt.value.substring(pos1, txt.value.length)
216
else if(possibilities.length > 1) {
217
var string = possibilities.join(" ");
218
parent.putMsgHTML(string, new Date().toLocaleTimeString(), parent.jid);
226
if (!e.shiftKey && !e.ctrlKey)
227
return submitClicked();
233
function msgboxKeyDown(el,e) {
235
if (window.event) { e = window.event; keycode = window.event.keyCode; }
236
else if (e) keycode = e.which;
243
el.value = parent.srcW.getHistory('up', el.value);
244
el.focus(); el.select();
247
case 40: // shift+down
249
el.value = parent.srcW.getHistory('down', el.value);
250
el.focus(); el.select();
254
if (e.ctrlKey) { // ctrl+l
255
parent.cFrame.body.innerHTML = '';
270
<body style="margin:8px;">
271
<form name="chatform">
272
<table width="100%" height="100%" border=0 cellpadding=0 cellspacing=0>
274
<td width="100%"><textarea id="msgbox" wrap="virtual" style="width:100%;height:100%;" tabindex=1 onKeyPress="return msgboxKeyPressed(this,event);" onKeyDown="return msgboxKeyDown(this,event);"></textarea></td></tr>
275
<tr><td height=5></td></tr>
277
<td align="right"><button id="config_chan_button" onClick="return parent.openConfig();" style="display:none;" tabindex=5>Config</button> <span id="register_room_span" style="display:none;"><button id="register_room_button" onClick="return openRegisterRoom();" tabindex=4>Register</button> </span><button id="invite_button" onClick="return openInvite();" tabindex=3>Invite</button> <button id='submit' name='submit' type='submit' onClick="return submitClicked();" tabindex=2>Send</button></td></tr>