Changes to install command related files.
connection-xpcom.js:
style changes; fix to verify the socket is open before send/recieve,
* dcc.js, http.js, events.js:
style changes
* irc-debug.js:
changes to display network events
* irc.js:
style changes, userIsMe() convenience function added.
Route events to parent network if there is no local landing spot.
add usersAffected property to onChanMode events.
* utils.js:
add jsenv.HAS_DOCUMENT
* listbox.js
add MPL (duh)
add prepend and insert methods
* test3-handlers.js
Add MPL
Use new command stuff to provide online help and error reporting.
Hook some basic server messages to output window.
Alphabetize nicks (order breaks when someone /nicks)
Added nick property to some display() lines so they can be CSS'd by user.
Listen for onChanMode event.
Modify client.viewsArray to allow for multiple view with the same name.
* test3-static.js
Add MPL
Show navigator.userAgent in VERSION reply
modify setCurrentObject to not care if there isnt a toolbutton associated
modify getTBForObject to work with multiple view w/ same name
test3.xul
Add MPL
Include command related scripts
This commit is contained in:
rginda%ndcico.com 1999-09-15 02:04:24 +00:00
Родитель 3a9ca8d5ed
Коммит 1cf8797af8
15 изменённых файлов: 887 добавлений и 187 удалений

Просмотреть файл

@ -42,6 +42,7 @@ JSLIBFILES = \
$(srcdir)/js/lib/utils.js \
$(srcdir)/js/lib/events.js \
$(srcdir)/js/lib/connection-xpcom.js \
$(srcdir)/js/lib/command-manager.js \
$(srcdir)/js/lib/irc.js \
$(srcdir)/js/lib/irc-debug.js \
$(NULL)
@ -65,6 +66,7 @@ TESTFILES = \
$(srcdir)/xul/tests/test3.css \
$(srcdir)/xul/tests/test3-static.js \
$(srcdir)/xul/tests/test3-handlers.js \
$(srcdir)/xul/tests/test3-commands.js \
$(srcdir)/xul/tests/g_blue.gif \
$(srcdir)/xul/tests/g_blue_on.gif \
$(srcdir)/xul/tests/g_grey.gif \

Просмотреть файл

@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is JSIRC Library
*
* The Initial Developer of the Original Code is New Dimensions Consulting,
* Inc. Portions created by New Dimensions Consulting, Inc. Copyright (C) 1999
* New Dimenstions Consulting, Inc. All Rights Reserved.
*
*
* Contributor(s):
* Robert Ginda, rginda@ndcico.com, original author
*/
function CCommandManager ()
{
this.commands = new Array();
}
CCommandManager.prototype.add =
function cmgr_add (name, func, usage, help)
{
function compare (a, b)
{
if (a.name == b.name)
return 0;
else
if (a.name > b.name)
return 1;
else
return -1;
}
this.commands.push ({name: name, func: func, usage: usage, help: help});
this.commands = this.commands.sort(compare);
}
CCommandManager.prototype.list =
function cmgr_list (partialName)
{
/* returns array of command objects which look like |partialName|, or
* all commands if |partialName| is not specified */
if ((typeof partialName == "undefined") ||
(String(partialName) == ""))
return this.commands;
var ary = new Array();
for (var i in this.commands)
{
if (this.commands[i].name.indexOf(partialName) == 0)
ary.push (this.commands[i]);
if (this.commands[i].name > partialName)
break;
}
return ary;
}

Просмотреть файл

@ -39,8 +39,8 @@ function CBSConnection ()
}
CBSConnection.prototype.connect = function bs_connect (host, port,
bind, tcp_flag)
CBSConnection.prototype.connect =
function bs_connect (host, port, bind, tcp_flag)
{
if (typeof tcp_flag == "undefined")
tcp_flag = false;
@ -57,7 +57,8 @@ CBSConnection.prototype.connect = function bs_connect (host, port,
}
CBSConnection.prototype.disconnect = function bs_disconnect ()
CBSConnection.prototype.disconnect =
function bs_disconnect ()
{
this.isConnected = false;
@ -65,8 +66,11 @@ CBSConnection.prototype.disconnect = function bs_disconnect ()
}
CBSConnection.prototype.sendData = function bs_send (str)
CBSConnection.prototype.sendData =
function bs_send (str)
{
if (!this.isConnected)
throw "Not Connected.";
try
{
@ -87,9 +91,13 @@ CBSConnection.prototype.sendData = function bs_send (str)
}
CBSConnection.prototype.readData = function bs_read (timeout)
CBSConnection.prototype.readData =
function bs_read (timeout)
{
if (!this.isConnected)
throw "Not Connected.";
try
{
var rv = this._bsc.readData(timeout);

Просмотреть файл

@ -39,7 +39,8 @@ function CDCCChat (ep, host, port)
}
CDCCChat.prototype.connect = function dchat_connect (host, port)
CDCCChat.prototype.connect =
function dchat_connect (host, port)
{
if (typeof host != "undefined") this.host = host;
@ -54,7 +55,8 @@ CDCCChat.prototype.connect = function dchat_connect (host, port)
}
CDCCChat.prototype.onPoll = function dchat_poll (e)
CDCCChat.prototype.onPoll =
function dchat_poll (e)
{
var line = "";
@ -106,10 +108,10 @@ CDCCChat.prototype.onPoll = function dchat_poll (e)
}
CDCCChat.prototype.say = function dchat_say (msg)
CDCCChat.prototype.say =
function dchat_say (msg)
{
this.connection.sendData (msg + "\n");
}

Просмотреть файл

@ -60,7 +60,8 @@ function CEventPump (eventsPerStep)
}
CEventPump.prototype.onHook = function ep_hook(e)
CEventPump.prototype.onHook =
function ep_hook(e)
{
var hooks = this.hooks;
@ -84,7 +85,8 @@ CEventPump.prototype.onHook = function ep_hook(e)
}
CEventPump.prototype.addHook = function ep_addhook(pattern, f, name, neg)
CEventPump.prototype.addHook =
function ep_addhook(pattern, f, name, neg)
{
if (typeof f != "function")
@ -96,7 +98,8 @@ CEventPump.prototype.addHook = function ep_addhook(pattern, f, name, neg)
}
CEventPump.prototype.removeHookByName = function ep_remhookname(name)
CEventPump.prototype.removeHookByName =
function ep_remhookname(name)
{
for (var h in this.hooks)
@ -110,14 +113,16 @@ CEventPump.prototype.removeHookByName = function ep_remhookname(name)
}
CEventPump.prototype.removeHookByIndex = function ep_remhooki(idx)
CEventPump.prototype.removeHookByIndex =
function ep_remhooki(idx)
{
return arrayRemoveAt (this.hooks, idx);
}
CEventPump.prototype.addEvent = function ep_addevent (e)
CEventPump.prototype.addEvent =
function ep_addevent (e)
{
e.queuedAt = new Date();
@ -126,7 +131,8 @@ CEventPump.prototype.addEvent = function ep_addevent (e)
}
CEventPump.prototype.routeEvent = function ep_routeevent (e)
CEventPump.prototype.routeEvent =
function ep_routeevent (e)
{
var count = 0;
var ddprefix = "";
@ -150,7 +156,7 @@ CEventPump.prototype.routeEvent = function ep_routeevent (e)
}
catch (ex)
{
dd ("Error routing event: " + ex);
dd ("Error routing event: " + ex.toSource());
}
if (count++ > this.MAX_EVENT_DEPTH)
throw "Too many events in chain";
@ -182,7 +188,8 @@ CEventPump.prototype.routeEvent = function ep_routeevent (e)
}
CEventPump.prototype.stepEvents = function ep_stepevents()
CEventPump.prototype.stepEvents =
function ep_stepevents()
{
var i = 0;
@ -198,8 +205,3 @@ CEventPump.prototype.stepEvents = function ep_stepevents()
return true;
}

Просмотреть файл

@ -39,7 +39,8 @@ function CHTTPDoc (server, path)
}
CHTTPDoc.prototype.get = function http_get (ep)
CHTTPDoc.prototype.get =
function http_get (ep)
{
this.connection = new CBSConnection();
@ -66,7 +67,8 @@ CHTTPDoc.prototype.get = function http_get (ep)
}
CHTTPDoc.prototype.onPoll = function http_poll (e)
CHTTPDoc.prototype.onPoll =
function http_poll (e)
{
var line = "";
var ex, c;
@ -158,7 +160,7 @@ CHTTPDoc.prototype.onPoll = function http_poll (e)
break;
default:
dd ("** INVALID STATE IN HTTPDoc OBJECT (" + this.state + ") **");
dd ("** INVALID STATE in HTTPDoc object (" + this.state + ") **");
need_more = false;
this.state = "error";
break;
@ -188,7 +190,8 @@ CHTTPDoc.prototype.onPoll = function http_poll (e)
}
CHTTPDoc.prototype.onComplete = function http_complete(e)
CHTTPDoc.prototype.onComplete =
function http_complete(e)
{
return true;

Просмотреть файл

@ -13,6 +13,7 @@ function event_tracer (e)
data = "'" + e.data + "'";
break;
case "network":
case "channel":
name = e.destObject.name;
break;

Просмотреть файл

@ -56,6 +56,25 @@
*
*/
function userIsMe (user)
{
switch (user.TYPE)
{
case "IRCUser":
return (user == user.parent.me);
break;
case "IRCChanUser":
return (user.__proto__ == user.parent.parent.me);
break;
default:
return false;
}
}
/*
* irc network
*/
@ -80,7 +99,8 @@ CIRCNetwork.prototype.stayingPower = false;
CIRCNetwork.prototype.TYPE = "IRCNetwork";
CIRCNetwork.prototype.connect = function net_conenct()
CIRCNetwork.prototype.connect =
function net_conenct()
{
var ev = new CEvent ("network", "do-connect", this, "onDoConnect");
@ -88,7 +108,7 @@ CIRCNetwork.prototype.connect = function net_conenct()
}
CIRCNetwork.prototype.quit = CIRCNetwork.prototype.exit =
CIRCNetwork.prototype.quit =
function net_quit (reason)
{
@ -100,7 +120,8 @@ function net_quit (reason)
/*
* Handles a request to connect to a primary server.
*/
CIRCNetwork.prototype.onDoConnect = function net_doconnect(e)
CIRCNetwork.prototype.onDoConnect =
function net_doconnect(e)
{
if ((this.primServ) && (this.primServ.connection.isConnected))
@ -139,7 +160,8 @@ CIRCNetwork.prototype.onDoConnect = function net_doconnect(e)
/*
* What to do when the client connects to it's primary server
*/
CIRCNetwork.prototype.onConnect = function net_connect (e)
CIRCNetwork.prototype.onConnect =
function net_connect (e)
{
this.primServ = e.server;
@ -159,7 +181,8 @@ CIRCNetwork.prototype.onConnect = function net_connect (e)
}
CIRCNetwork.prototype.isConnected = function net_connected (e)
CIRCNetwork.prototype.isConnected =
function net_connected (e)
{
return (this.primServ && this.primServ.connection.isConnected);
@ -198,7 +221,8 @@ CIRCServer.prototype.DEFAULT_REASON = "no reason";
CIRCServer.prototype.TYPE = "IRCServer";
CIRCServer.prototype.flushSendQueue = function serv_flush()
CIRCServer.prototype.flushSendQueue =
function serv_flush()
{
this.sendQueue.length = 0;
@ -208,7 +232,8 @@ CIRCServer.prototype.flushSendQueue = function serv_flush()
}
CIRCServer.prototype.login = function serv_login(nick, name, desc)
CIRCServer.prototype.login =
function serv_login(nick, name, desc)
{
this.me = new CIRCUser (this, nick, name);
@ -217,7 +242,8 @@ CIRCServer.prototype.login = function serv_login(nick, name, desc)
}
CIRCServer.prototype.logout = function serv_logout(reason)
CIRCServer.prototype.logout =
function serv_logout(reason)
{
if (typeof reason == "undefined") reason = this.DEFAULT_REASON;
@ -227,21 +253,24 @@ CIRCServer.prototype.logout = function serv_logout(reason)
}
CIRCServer.prototype.addChannel = function serv_addchan (name)
CIRCServer.prototype.addChannel =
function serv_addchan (name)
{
return new CIRCChannel (this, name);
}
CIRCServer.prototype.addUser = function serv_addusr (nick, name, host)
CIRCServer.prototype.addUser =
function serv_addusr (nick, name, host)
{
return new CIRCUser (this, nick, name, host);
}
CIRCServer.prototype.getChannelsLength = function serv_chanlen()
CIRCServer.prototype.getChannelsLength =
function serv_chanlen()
{
var i = 0;
@ -252,7 +281,8 @@ CIRCServer.prototype.getChannelsLength = function serv_chanlen()
}
CIRCServer.prototype.getUsersLength = function serv_chanlen()
CIRCServer.prototype.getUsersLength =
function serv_chanlen()
{
var i = 0;
@ -263,14 +293,16 @@ CIRCServer.prototype.getUsersLength = function serv_chanlen()
}
CIRCServer.prototype.sendData = function serv_senddata (msg)
CIRCServer.prototype.sendData =
function serv_senddata (msg)
{
arrayInsertAt (this.sendQueue, 0, msg);
}
CIRCServer.prototype.queuedSendData = function serv_senddata (msg)
CIRCServer.prototype.queuedSendData =
function serv_senddata (msg)
{
arrayInsertAt (this.sendQueue, 0, msg);
@ -281,8 +313,8 @@ CIRCServer.prototype.queuedSendData = function serv_senddata (msg)
* Takes care not to let more than MAX_LINES_PER_SEND lines out per
* cycle. Cycle's are defined as the time between onPoll calls.
*/
CIRCServer.prototype.messageTo = function serv_messto (code, target, msg,
ctcpCode)
CIRCServer.prototype.messageTo =
function serv_messto (code, target, msg, ctcpCode)
{
var lines = String(msg).split ("\n");
var sendable = 0, i;
@ -325,28 +357,32 @@ CIRCServer.prototype.messageTo = function serv_messto (code, target, msg,
}
CIRCServer.prototype.sayTo = function serv_sayto (target, msg)
CIRCServer.prototype.sayTo =
function serv_sayto (target, msg)
{
this.messageTo ("PRIVMSG", target, msg);
}
CIRCServer.prototype.noticeTo = function serv_noticeto (target, msg)
CIRCServer.prototype.noticeTo =
function serv_noticeto (target, msg)
{
this.messageTo ("NOTICE", target, msg);
}
CIRCServer.prototype.actTo = function serv_actto (target, msg)
CIRCServer.prototype.actTo =
function serv_actto (target, msg)
{
this.messageTo ("PRIVMSG", target, msg, "ACTION");
}
CIRCServer.prototype.onDisconnect = function serv_disconnect(e)
CIRCServer.prototype.onDisconnect =
function serv_disconnect(e)
{
if ((this.parent.primServ == this) && (this.parent.stayingPower))
@ -360,7 +396,8 @@ CIRCServer.prototype.onDisconnect = function serv_disconnect(e)
}
CIRCServer.prototype.onPoll = function serv_poll(e)
CIRCServer.prototype.onPoll =
function serv_poll(e)
{
var lines;
var ex;
@ -456,7 +493,8 @@ CIRCServer.prototype.onPoll = function serv_poll(e)
* See Section 2.3.1 of RFC 1459 for details on <prefix>, <middle> and
* <trailing> tokens.
*/
CIRCServer.prototype.onRawData = function serv_onRawData(e)
CIRCServer.prototype.onRawData =
function serv_onRawData(e)
{
var ary;
var l = e.data;
@ -504,20 +542,29 @@ CIRCServer.prototype.onRawData = function serv_onRawData(e)
/*
* onParsedData forwards to next event, based on |e.code|
*/
CIRCServer.prototype.onParsedData = function serv_onParsedData(e)
CIRCServer.prototype.onParsedData =
function serv_onParsedData(e)
{
e.type = e.code.toLowerCase();
e.destObject = this;
e.destMethod = "on" + e.code[0].toUpperCase() +
e.code.substr (1, e.code.length).toLowerCase();
if (typeof this[e.destMethod] == "function")
e.destObject = this;
else
{
e.set = "network";
e.destObject = this.parent;
}
return true;
}
/* User changed topic */
CIRCServer.prototype.onTopic = function serv_topic (e)
CIRCServer.prototype.onTopic =
function serv_topic (e)
{
e.channel = new CIRCChannel (this, e.params[1]);
@ -532,7 +579,8 @@ CIRCServer.prototype.onTopic = function serv_topic (e)
}
/* TOPIC reply */
CIRCServer.prototype.on332 = function serv_332 (e)
CIRCServer.prototype.on332 =
function serv_332 (e)
{
e.channel = new CIRCChannel (this, e.params[2]);
@ -545,7 +593,8 @@ CIRCServer.prototype.on332 = function serv_332 (e)
}
/* topic information */
CIRCServer.prototype.on333 = function serv_333 (e)
CIRCServer.prototype.on333 =
function serv_333 (e)
{
e.channel = new CIRCChannel (this, e.params[2]);
@ -559,7 +608,8 @@ CIRCServer.prototype.on333 = function serv_333 (e)
}
/* name reply */
CIRCServer.prototype.on353 = function serv_353 (e)
CIRCServer.prototype.on353 =
function serv_353 (e)
{
e.channel = new CIRCChannel (this, e.params[3]);
@ -603,7 +653,8 @@ CIRCServer.prototype.on353 = function serv_353 (e)
}
/* end of names */
CIRCServer.prototype.on366 = function serv_366 (e)
CIRCServer.prototype.on366 =
function serv_366 (e)
{
e.channel = new CIRCChannel (this, e.params[2]);
@ -616,7 +667,8 @@ CIRCServer.prototype.on366 = function serv_366 (e)
}
/* channel time stamp? */
CIRCServer.prototype.on329 = function serv_329 (e)
CIRCServer.prototype.on329 =
function serv_329 (e)
{
e.channel = new CIRCChannel (this, e.params[2]);
@ -629,7 +681,8 @@ CIRCServer.prototype.on329 = function serv_329 (e)
}
/* channel mode reply */
CIRCServer.prototype.on324 = function serv_324 (e)
CIRCServer.prototype.on324 =
function serv_324 (e)
{
e.channel = new CIRCChannel (this, e.params[2]);
@ -642,7 +695,8 @@ CIRCServer.prototype.on324 = function serv_324 (e)
}
/* user changed the mode */
CIRCServer.prototype.onMode = function serv_mode (e)
CIRCServer.prototype.onMode =
function serv_mode (e)
{
e.destObject = this;
@ -665,14 +719,16 @@ CIRCServer.prototype.onMode = function serv_mode (e)
}
CIRCServer.prototype.onUserMode = function serv_usermode (e)
CIRCServer.prototype.onUserMode =
function serv_usermode (e)
{
return true;
}
CIRCServer.prototype.onChanMode = function serv_chanmode (e)
CIRCServer.prototype.onChanMode =
function serv_chanmode (e)
{
var modifier = "";
var params_eaten = 0;
@ -692,6 +748,9 @@ CIRCServer.prototype.onChanMode = function serv_chanmode (e)
var mode_str = e.params[BASE_PARAM];
params_eaten++;
e.modeStr = mode_str;
e.usersAffected = new Array();
for (var i = 0; i < mode_str.length ; i++)
{
switch (mode_str[i])
@ -708,6 +767,7 @@ CIRCServer.prototype.onChanMode = function serv_chanmode (e)
var nick = e.params[BASE_PARAM + params_eaten];
var user = new CIRCChanUser (e.channel, nick, true);
params_eaten++;
e.usersAffected.push (user);
}
else
if (modifier == "-")
@ -715,6 +775,7 @@ CIRCServer.prototype.onChanMode = function serv_chanmode (e)
var nick = e.params[BASE_PARAM + params_eaten];
var user = new CIRCChanUser (e.channel, nick, false);
params_eaten++;
e.usersAffected.push (user);
}
break;
@ -725,6 +786,7 @@ CIRCServer.prototype.onChanMode = function serv_chanmode (e)
var user = new CIRCChanUser (e.channel, nick, (void 0),
true);
params_eaten++;
e.usersAffected.push (user);
}
else
if (modifier == "-")
@ -733,6 +795,7 @@ CIRCServer.prototype.onChanMode = function serv_chanmode (e)
var user = new CIRCChanUser (e.channel, nick, (void 0),
false);
params_eaten++;
e.usersAffected.push (user);
}
break;
@ -834,12 +897,12 @@ CIRCServer.prototype.onChanMode = function serv_chanmode (e)
e.destObject = e.channel;
e.set = "channel";
return true;
}
CIRCServer.prototype.onNick = function serv_nick (e)
CIRCServer.prototype.onNick =
function serv_nick (e)
{
var newKey = e.meat.toLowerCase();
var oldKey = e.user.nick;
@ -873,7 +936,8 @@ CIRCServer.prototype.onNick = function serv_nick (e)
}
CIRCServer.prototype.onQuit = function serv_quit (e)
CIRCServer.prototype.onQuit =
function serv_quit (e)
{
for (var c in e.server.channels)
@ -902,7 +966,8 @@ CIRCServer.prototype.onQuit = function serv_quit (e)
}
CIRCServer.prototype.onPart = function serv_part (e)
CIRCServer.prototype.onPart =
function serv_part (e)
{
e.channel = new CIRCChannel (this, e.params[1]);
@ -915,7 +980,8 @@ CIRCServer.prototype.onPart = function serv_part (e)
}
CIRCServer.prototype.onKick = function serv_kick (e)
CIRCServer.prototype.onKick =
function serv_kick (e)
{
e.channel = new CIRCChannel (this, e.params[1]);
@ -929,7 +995,8 @@ CIRCServer.prototype.onKick = function serv_kick (e)
}
CIRCServer.prototype.onJoin = function serv_join (e)
CIRCServer.prototype.onJoin =
function serv_join (e)
{
e.channel = new CIRCChannel (this, e.meat);
@ -945,7 +1012,8 @@ CIRCServer.prototype.onJoin = function serv_join (e)
}
CIRCServer.prototype.onPing = function serv_ping (e)
CIRCServer.prototype.onPing =
function serv_ping (e)
{
/* non-queued send, so we can calcualte lag */
@ -957,7 +1025,8 @@ CIRCServer.prototype.onPing = function serv_ping (e)
}
CIRCServer.prototype.onPong = function serv_pong (e)
CIRCServer.prototype.onPong =
function serv_pong (e)
{
if (this.lastPingSent)
@ -969,7 +1038,8 @@ CIRCServer.prototype.onPong = function serv_pong (e)
}
CIRCServer.prototype.onNotice = function serv_notice (e)
CIRCServer.prototype.onNotice =
function serv_notice (e)
{
if (!e.user)
@ -998,7 +1068,8 @@ CIRCServer.prototype.onNotice = function serv_notice (e)
}
CIRCServer.prototype.onPrivmsg = function serv_privmsg (e)
CIRCServer.prototype.onPrivmsg =
function serv_privmsg (e)
{
/* setting replyTo provides a standard place to find the target for */
@ -1030,7 +1101,8 @@ CIRCServer.prototype.onPrivmsg = function serv_privmsg (e)
}
CIRCServer.prototype.onCTCP = function serv_ctcp (e)
CIRCServer.prototype.onCTCP =
function serv_ctcp (e)
{
var ary = e.meat.match (/^\01(\S+)? ?(.*)\01$/i);
@ -1055,7 +1127,8 @@ CIRCServer.prototype.onCTCP = function serv_ctcp (e)
}
CIRCServer.prototype.onCTCPVersion = function serv_cver (e)
CIRCServer.prototype.onCTCPVersion =
function serv_cver (e)
{
var lines = e.server.VERSION_RPLY.split ("\n");
@ -1069,7 +1142,8 @@ CIRCServer.prototype.onCTCPVersion = function serv_cver (e)
}
CIRCServer.prototype.onCTCPPing = function serv_cping (e)
CIRCServer.prototype.onCTCPPing =
function serv_cping (e)
{
/* non-queued send */
@ -1082,7 +1156,8 @@ CIRCServer.prototype.onCTCPPing = function serv_cping (e)
}
CIRCServer.prototype.onCTCPDcc = function serv_dcc (e)
CIRCServer.prototype.onCTCPDcc =
function serv_dcc (e)
{
var ary = e.CTCPData.match (/(\S+)? ?(.*)/);
@ -1104,7 +1179,8 @@ CIRCServer.prototype.onCTCPDcc = function serv_dcc (e)
}
CIRCServer.prototype.onDCCChat = function serv_dccchat (e)
CIRCServer.prototype.onDCCChat =
function serv_dccchat (e)
{
var ary = e.DCCData.match (/(chat) (\d+) (\d+)/i);
@ -1120,7 +1196,8 @@ CIRCServer.prototype.onDCCChat = function serv_dccchat (e)
}
CIRCServer.prototype.onDCCSend = function serv_dccsend (e)
CIRCServer.prototype.onDCCSend =
function serv_dccsend (e)
{
var ary = e.DCCData.match (/(\S+) (\d+) (\d+) (\d+)/);
@ -1165,14 +1242,16 @@ function CIRCChannel (parent, name)
CIRCChannel.prototype.TYPE = "IRCChannel";
CIRCChannel.prototype.addUser = function chan_adduser (nick, isOp, isVoice)
CIRCChannel.prototype.addUser =
function chan_adduser (nick, isOp, isVoice)
{
return new CIRCChanUser (this, nick, isOp, isVoice);
}
CIRCChannel.prototype.getUsersLength = function chan_userslen ()
CIRCChannel.prototype.getUsersLength =
function chan_userslen ()
{
var i = 0;
@ -1183,7 +1262,8 @@ CIRCChannel.prototype.getUsersLength = function chan_userslen ()
}
CIRCChannel.prototype.setTopic = function chan_topic (str)
CIRCChannel.prototype.setTopic =
function chan_topic (str)
{
if ((!this.mode.publicTopic) &&
(!this.parent.me.isOp))
@ -1197,28 +1277,32 @@ CIRCChannel.prototype.setTopic = function chan_topic (str)
}
CIRCChannel.prototype.say = function chan_say (msg)
CIRCChannel.prototype.say =
function chan_say (msg)
{
this.parent.sayTo (this.name, msg);
}
CIRCChannel.prototype.act = function chan_say (msg)
CIRCChannel.prototype.act =
function chan_say (msg)
{
this.parent.actTo (this.name, msg);
}
CIRCChannel.prototype.notice = function chan_notice (msg)
CIRCChannel.prototype.notice =
function chan_notice (msg)
{
this.parent.noticeTo (this.name, msg);
}
CIRCChannel.prototype.join = function chan_join ()
CIRCChannel.prototype.join =
function chan_join ()
{
this.parent.sendData ("JOIN " + this.name + "\n");
@ -1226,7 +1310,8 @@ CIRCChannel.prototype.join = function chan_join ()
}
CIRCChannel.prototype.part = function chan_part ()
CIRCChannel.prototype.part =
function chan_part ()
{
this.parent.sendData ("PART " + this.name + "\n");
@ -1253,7 +1338,8 @@ function CIRCChanMode (parent)
CIRCChanMode.prototype.TYPE = "IRCChanMode";
CIRCChanMode.prototype.setMode = function chanm_mode (modestr)
CIRCChanMode.prototype.setMode =
function chanm_mode (modestr)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1265,7 +1351,8 @@ CIRCChanMode.prototype.setMode = function chanm_mode (modestr)
}
CIRCChanMode.prototype.setLimit = function chanm_limit (n)
CIRCChanMode.prototype.setLimit =
function chanm_limit (n)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1280,7 +1367,8 @@ CIRCChanMode.prototype.setLimit = function chanm_limit (n)
}
CIRCChanMode.prototype.lock = function chanm_lock (k)
CIRCChanMode.prototype.lock =
function chanm_lock (k)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1291,7 +1379,8 @@ CIRCChanMode.prototype.lock = function chanm_lock (k)
}
CIRCChanMode.prototype.unlock = function chan_unlock (k)
CIRCChanMode.prototype.unlock =
function chan_unlock (k)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1302,7 +1391,8 @@ CIRCChanMode.prototype.unlock = function chan_unlock (k)
}
CIRCChanMode.prototype.setModerated = function chan_moderate (f)
CIRCChanMode.prototype.setModerated =
function chan_moderate (f)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1315,7 +1405,8 @@ CIRCChanMode.prototype.setModerated = function chan_moderate (f)
}
CIRCChanMode.prototype.setPublicMessages = function chan_pmessages (f)
CIRCChanMode.prototype.setPublicMessages =
function chan_pmessages (f)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1328,7 +1419,8 @@ CIRCChanMode.prototype.setPublicMessages = function chan_pmessages (f)
}
CIRCChanMode.prototype.setPublicTopic = function chan_ptopic (f)
CIRCChanMode.prototype.setPublicTopic =
function chan_ptopic (f)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1341,7 +1433,8 @@ CIRCChanMode.prototype.setPublicTopic = function chan_ptopic (f)
}
CIRCChanMode.prototype.setInvite = function chan_invite (f)
CIRCChanMode.prototype.setInvite =
function chan_invite (f)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1354,7 +1447,8 @@ CIRCChanMode.prototype.setInvite = function chan_invite (f)
}
CIRCChanMode.prototype.setPvt = function chan_pvt (f)
CIRCChanMode.prototype.setPvt =
function chan_pvt (f)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1367,7 +1461,8 @@ CIRCChanMode.prototype.setPvt = function chan_pvt (f)
}
CIRCChanMode.prototype.setSecret = function chan_secret (f)
CIRCChanMode.prototype.setSecret =
function chan_secret (f)
{
if (!this.parent.users[this.parent.parent.me.nick].isOp)
return false;
@ -1419,7 +1514,8 @@ function usr_changenick (nick)
}
CIRCUser.prototype.getHostMask = function usr_hostmask (pfx)
CIRCUser.prototype.getHostMask =
function usr_hostmask (pfx)
{
pfx = (typeof pfx != "undefined") ? pfx : "*!" + this.name + "@*.";
var idx = this.host.indexOf(".");
@ -1430,21 +1526,24 @@ CIRCUser.prototype.getHostMask = function usr_hostmask (pfx)
}
CIRCUser.prototype.say = function usr_say (msg)
CIRCUser.prototype.say =
function usr_say (msg)
{
this.parent.sayTo (this.nick, msg);
}
CIRCUser.prototype.notice = function usr_notice (msg)
CIRCUser.prototype.notice =
function usr_notice (msg)
{
this.parent.noticeTo (this.nick, msg);
}
CIRCUser.prototype.act = function usr_act (msg)
CIRCUser.prototype.act =
function usr_act (msg)
{
this.parent.actTo (this.nick, msg);

Просмотреть файл

@ -44,6 +44,7 @@ jsenv.HAS_XPCOM = ((typeof Components == "function") &&
(typeof Components.classes == "function"));
jsenv.HAS_JAVA = (typeof java == "object");
jsenv.HAS_RHINO = (typeof defineClass == "function");
jsenv.HAS_DOCUMENT = (typeof document == "object");
function dumpObject (o, pfx, sep)
{

Просмотреть файл

@ -39,6 +39,7 @@ JSLIBFILES = \
.\js\lib\utils.js \
.\js\lib\events.js \
.\js\lib\connection-xpcom.js \
.\js\lib\command-manager.js \
.\js\lib\irc.js \
.\js\lib\irc-debug.js \
$(NULL)
@ -62,6 +63,7 @@ TESTFILES = \
.\xul\tests\test3.css \
.\xul\tests\test3-static.js \
.\xul\tests\test3-handlers.js \
.\xul\tests\test3-commands.js \
.\xul\tests\g_blue.gif \
.\xul\tests\g_blue_on.gif \
.\xul\tests\g_grey.gif \

Просмотреть файл

@ -1,3 +1,26 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is JSIRC Library
*
* The Initial Developer of the Original Code is New Dimensions Consulting,
* Inc. Portions created by New Dimensions Consulting, Inc. Copyright (C) 1999
* New Dimenstions Consulting, Inc. All Rights Reserved.
*
*
* Contributor(s):
* Robert Ginda, rginda@ndcico.com, original author
*/
function CListBox ()
{
@ -51,24 +74,62 @@ function lbox_add (stuff, tag)
option.tag = tag;
this.listContainer.appendChild (option);
return true;
}
CListBox.prototype.prepend =
function lbox_prepend (stuff, oldstuff, tag)
{
if (!this.listContainer.firstChild)
return this.add (stuff, tag);
var nextOption = this._findOption (oldstuff);
if (!nextOption)
return false;
var option = document.createElement ("html:a");
option.setAttribute ("class", "list-option");
option.appendChild (stuff);
option.appendChild (document.createElement("html:br"));
option.onclick = this.clickHandler;
option.listManager = this;
option.tag = tag;
this.listContainer.insertBefore (option, nextOption);
}
CListBox.prototype.insert =
function lbox_Insert (stuff, tag)
{
this.prepend (stuff, this.listContainer.firstChild, tag);
}
CListBox.prototype.remove =
function lbox_remove (stuff)
{
var option = this._findOption (stuff);
if (option)
this.listContainer.removeChild (option);
return;
}
CListBox.prototype._findOption =
function lbox_remove (stuff)
{
var option = this.listContainer.firstChild;
while (option)
{
if (option.firstChild == stuff)
{
this.listContainer.removeChild (option);
return true;
}
return option;
option = option.nextSibling;
}
return false;
return;
}
CListBox.prototype.enumerateElements =

Просмотреть файл

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is JSIRC Test Client #3
*
* The Initial Developer of the Original Code is New Dimensions Consulting,
* Inc. Portions created by New Dimensions Consulting, Inc. Copyright (C) 1999
* New Dimenstions Consulting, Inc. All Rights Reserved.
*
*
* Contributor(s):
* Robert Ginda, rginda@ndcico.com, original author
*/
function addCommands(commandObject)
{
function add (name, func, usage, help)
{
commandObject.add (name, func, usage, help);
}
add ("help", "onInputHelp",
"[<command-name>]",
"Displays help on all commands matching <command-name>, if " +
"<command-name> is not given, displays help on all commands");
add ("network", "onInputNetwork",
"<network-name>",
"Sets the current network to <network-name>");
add ("attach", "onInputAttach",
"[<network-name>]",
"Attaches to the network specified by <network-name>, " +
"or the current network, if no network is specified.");
add ("me", "onInputMe",
"<action>",
"Performs an 'action' on the current channel.");
add ("nick", "onInputNick",
"<nickname>",
"Changes your current nickname.");
add ("name", "onInputName",
"<username>",
"Changes the username displayed before your hostmask if the server " +
"you're connecting to allows it. Some servers will only trust the " +
"username reply from the ident service. You must specify this " +
"*before* connecting to the network.");
add ("desc", "onInputDesc",
"<description>",
"Changes the 'ircname' line returned when someone performs a /whois " +
"on you. You must specify this *before* connecting to the network.");
add ("quote", "onInputQuote",
"<irc-command>",
"Sends a raw command to the IRC server, not a good idea if you " +
"don't know what you're doing. see IRC 1459 " +
"( http://www.irchelp.org/irchelp/rfc1459.html ) for complete " +
"details.");
add ("eval", "onInputEval",
"<script>",
"Evaluates <script> as JavaScript code. Not for the faint of heart.");
add ("join", "onInputJoin",
"[#|&]<channel-name>",
"Joins a the global (name starts with #) or local (name starts " +
"with &) channel named <channel-name>. If no prefix is given, # is " +
"assumed.");
add ("leave", "onInputLeave",
"",
"Parts the current channel");
add ("zoom", "onInputZoom",
"<nick>",
"Shows only messages <nick> has sent to the channel, filtering out " +
"all others, (including yours.)");
add ("topic", "onInputTopic",
"[<new-topic>]",
"If <new-topic> is specified and you are a chanop, or the channel " +
"is not in 'private topic' mode (+t), the topic will be changed to " +
"<new-topic>. If <new-topic> is *not* specified, the current topic " +
"will be displayed");
}

Просмотреть файл

@ -1,3 +1,25 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is JSIRC Test Client #3
*
* The Initial Developer of the Original Code is New Dimensions Consulting,
* Inc. Portions created by New Dimensions Consulting, Inc. Copyright (C) 1999
* New Dimenstions Consulting, Inc. All Rights Reserved.
*
*
* Contributor(s):
* Robert Ginda, rginda@ndcico.com, original author
*/
function onLoad()
{
@ -21,7 +43,7 @@ function onTBIClick (id)
var tbi = document.getElementById (id);
var view = client.viewsArray[tbi.getAttribute("viewKey")];
setCurrentObject (view);
setCurrentObject (view.source);
}
@ -78,21 +100,10 @@ function onInputCompleteLine(e)
}
else /* normal command */
{
var destMethod = "onInput" + command[0].toUpperCase() +
command.substr (1, command.length).toLowerCase();
if (typeof client[destMethod] != "function")
{
client.display ("Unknown command '" + command + "'.",
"ERROR");
return false;
}
var type = "input-" + command.toLowerCase();
var ev = new CEvent ("client", type, client, destMethod);
var ev = new CEvent ("client", "input-command", client,
"onInputCommand");
ev.command = command;
ev.inputData = ary[2] ? ary[2] : "";
ev.inputData = ary[2] ? stringTrim(ary[2]) : "";
ev.target = client.currentObject;
@ -154,8 +165,6 @@ function onInputCompleteLine(e)
arrayRemoveAt (lines, i);
var lastLine = lines[lines.length - 1];
dd ("lines: " + lines);
if (lastLine.replace(/s*$/,"") ==
e.target.getAttribute ("collapseChar"))
{
@ -171,21 +180,92 @@ function onInputCompleteLine(e)
}
client.onInputCommand =
function cli_icommand (e)
{
var ary = client.commands.list (e.command);
switch (ary.length)
{
case 0:
client.currentObject.display ("Unknown command '" + e.command +
"'.", "ERROR");
break;
case 1:
if (typeof client[ary[0].func] == "undefined")
client.currentObject.display ("Sorry, '" + e.command +
"' has not been implemented.",
"ERROR");
else
{
e.commandEntry = ary[0];
if (!client[ary[0].func](e))
client.currentObject.display (ary[0].name + " " +
ary[0].usage, "USAGE");
}
break;
default:
client.currentObject.display ("Ambiguous command: '" + e.command +
"'", "ERROR");
var str = "";
for (var i in ary)
str += str ? ", " + ary[i].name : ary[i].name;
client.currentObject.display (ary.length + " commands match: " +
str, "ERROR");
}
}
client.onInputHelp =
function cli_ihelp (e)
{
var ary = client.commands.list (e.inputData);
if (ary.length == 0)
{
client.currentObject.display ("No such command, '" + e.inputData +
"'.", "ERROR");
return false;
}
var saveDir = client.PRINT_DIRECTION;
client.PRINT_DIRECTION = 1;
for (var i in ary)
{
client.currentObject.display (ary[i].name + " " + ary[i].usage,
"USAGE");
client.currentObject.display (ary[i].help, "HELP");
client.currentObject.display ("", "HELP");
}
client.PRINT_DIRECTION = saveDir;
return true;
}
client.onInputNetwork =
function clie_inetwork (e)
{
if (!e.inputData)
{
client.display ("network <network-name>", "USAGE");
return false;
}
var net = client.networks[e.inputData];
if (net)
{
client.lastNetwork = net;
setCurrentObject (net);
}
else
client.display ("Unknown network '" + e.inputData + "'", "ERROR");
{
client.currentObject.display ("Unknown network '" + e.inputData + "'",
"ERROR");
return false;
}
return true;
@ -200,16 +280,16 @@ function cli_iattach (e)
{
if (client.lastNetwork)
{
client.display ("No network specified network, " +
"Using '" + client.lastNetwork.name + "'",
"NOTICE");
client.currentObject.display ("No network specified network, " +
"Using '" + client.lastNetwork.name +
"'", "NOTICE");
net = client.lastNetwork;
}
else
{
client.display ("No network specified, and no default network " +
"is in place.", "ERROR");
client.display ("attach <network-name>.", "USAGE");
client.currentObject.display ("No network specified, and no " +
"default network is in place.",
"ERROR");
return false;
}
}
@ -217,13 +297,17 @@ function cli_iattach (e)
{
net = client.networks[e.inputData];
if (!net)
{
client.display ("Unknown network '" + e.inputData + "'", "ERROR");
return false;
}
client.lastNetwork = net;
}
net.connect();
net.display ("Connecting...", "INFO");
setCurrentObject(net);
return true;
}
@ -235,6 +319,7 @@ function cli_ime (e)
e.inputData = filterOutput (e.inputData, "ACTION", "!ME");
e.channel.act (e.inputData);
}
return true;
}
client.onInputNick =
@ -249,6 +334,9 @@ function cli_inick (e)
else
CIRCNetwork.prototype.INITIAL_NICK = e.inputData;
return true;
}
client.onInputName =
@ -260,6 +348,8 @@ function cli_iname (e)
CIRCNetwork.prototype.INITIAL_NAME = e.inputData;
return true;
}
client.onInputDesc =
@ -271,19 +361,25 @@ function cli_idesc (e)
CIRCNetwork.prototype.INITIAL_DESC = e.inputData;
return true;
}
client.onInputRaw =
function cli_iraw (e)
client.onInputQuote =
function cli_iquote (e)
{
client.primNet.primServ.sendData (e.inputData + "\n");
return true;
}
client.onInputEval =
function cli_ieval (e)
{
if (!e.inputData)
return false;
if (e.inputData.indexOf ("\n") != -1)
e.inputData = "\n" + e.inputData + "\n";
@ -301,27 +397,26 @@ function cli_ieval (e)
client.display (String(ex), "ERROR");
}
return true;
}
client.onInputJ = client.onInputJoin =
client.onInputJoin =
function cli_ijoin (e)
{
if (!e.network || !e.network.isConnected())
{
if (!e.network)
client.display ("No network selected.", "ERROR");
client.currentObject.display ("No network selected.", "ERROR");
else
client.display ("Network '" + e.network.name + " is not connected.",
"ERROR");
client.currentObject.display ("Network '" + e.network.name +
" is not connected.", "ERROR");
return false;
}
var name = e.inputData.match(/\S+/);
if (!name)
{
client.display ("join [#|&]<channel-name>", "USAGE");
return false;
}
if ((name[0] != "#") && (name[0] != "&"))
name = "#" + name;
@ -331,23 +426,115 @@ function cli_ijoin (e)
e.channel.display ("Joining...", "INFO");
setCurrentObject(e.channel);
return true;
}
client.onInputP = client.onInputPart = client.onInputLeave =
client.onInputLeave =
function cli_ipart (e)
{
if (!e.channel)
{
client.currentObject.display ("Part can only be used from channels.",
"ERROR");
return false;
}
e.channel.part();
return true;
}
client.onInputZoom =
function cli_izoom (e)
{
if (!e.inputData)
return false;
if (!e.channel)
{
client.currentObject.display ("Zoom can only be used from channels.",
"ERROR");
return false;
}
var nick = e.inputData.toLowerCase();
var cuser = e.channel.users[nick];
if (!cuser)
{
client.currentObject.display ("User '" + e.inputData + "' not found.");
return false;
}
setCurrentObject(cuser);
return true;
}
client.onInputTopic =
function cli_itopic (e)
{
if (!e.channel)
{
client.currentObject.display ("Topic can only be used from channels.",
"ERROR");
return false;
}
if (!e.inputData)
{
if (e.channel.topic)
{
client.currentObject.display (e.channel.topic, "TOPIC");
client.currentObject.display ("Set by " + e.channel.topicBy +
" on " + e.channel.topicDate + ".",
"TOPIC");
}
else
client.currentObject.display ("No topic.", "TOPIC");
}
else
{
if (!e.channel.setTopic(e.inputData))
client.currentObject.display ("Could not set topic.", "ERROR");
}
}
CIRCNetwork.prototype.onNotice =
function my_notice (e)
CIRCNetwork.prototype.on001 = /* Welcome! */
CIRCNetwork.prototype.on002 = /* your host is */
CIRCNetwork.prototype.on003 = /* server born-on date */
CIRCNetwork.prototype.on004 = /* server id */
CIRCNetwork.prototype.on251 = /* users */
CIRCNetwork.prototype.on252 = /* opers online (in params[2]) */
CIRCNetwork.prototype.on254 = /* channels found (in params[2]) */
CIRCNetwork.prototype.on255 = /* link info */
CIRCNetwork.prototype.on265 = /* local user details */
CIRCNetwork.prototype.on266 = /* global user details */
CIRCNetwork.prototype.on375 = /* start of MOTD */
CIRCNetwork.prototype.on372 = /* MOTD line */
CIRCNetwork.prototype.on376 = /* end of MOTD */
function my_showtonet (e)
{
var p = (e.params[2]) ? e.params[2] + " " : "";
this.display (e.meat, "NOTICE");
switch (e.code)
{
case 372:
case 375:
case 376:
if (this.IGNORE_MOTD)
return;
/* no break */
default:
this.display (p + e.meat, e.code.toUpperCase());
break;
}
}
@ -402,8 +589,15 @@ function my_366 (e)
else
this.list.clear();
var ary = new Array();
for (var u in this.users)
this.list.add (this.users[u].getDecoratedNick());
ary.push (this.users[u].nick);
ary.sort();
for (var u in ary)
this.list.add (this.users[ary[u]].getDecoratedNick());
}
@ -427,9 +621,31 @@ CIRCChannel.prototype.onJoin =
function my_cjoin (e)
{
this.display(e.user.properNick + " has joined " + e.channel.name,
"JOIN");
this.list.add (e.user.getDecoratedNick());
if (userIsMe (e.user))
this.display ("YOU have joined " + e.channel.name, "JOIN", "!ME");
else
this.display(e.user.properNick + " (" + e.user.name + "@" +
e.user.host + ") has joined " + e.channel.name,
"JOIN", e.user.nick);
var ary = new Array();
for (var u in this.users)
ary.push (this.users[u].nick);
ary.sort();
for (u in ary)
if (ary[u] == e.user.nick)
break;
if (u < ary.length - 1)
{
this.list.prepend (e.user.getDecoratedNick(),
e.channel.users[ary[u + 1]].getDecoratedNick());
}
else
this.list.add (e.user.getDecoratedNick());
}
@ -437,7 +653,11 @@ CIRCChannel.prototype.onPart =
function my_cpart (e)
{
this.display (e.user.properNick + " has left " + e.channel.name, "PART");
if (userIsMe (e.user))
this.display ("YOU have left " + e.channel.name, "PART", "!ME");
else
this.display (e.user.properNick + " has left " + e.channel.name,
"PART");
this.list.remove (e.user.getDecoratedNick());
}
@ -446,17 +666,58 @@ CIRCChannel.prototype.onKick =
function my_ckick (e)
{
this.display (e.lamer.properNick + " was booted from " + e.channel.name +
" by " + e.user.properNick + " (" + e.reason + ")", "KICK");
if (userIsMe (e.lamer))
this.display ("YOU have been booted from " + e.channel.name +
" by " + e.user.properNick + " (" + e.reason + ")",
"KICK", e.user.nick);
else
{
var enforcerProper, enforcerNick;
if (userIsMe (e.user))
{
enforcerProper = "YOU";
enforcerNick = "!ME";
}
else
{
enforcerProper = e.user.properNick;
enforcerNick = e.user.nick;
}
this.display (e.lamer.properNick + " was booted from " +
e.channel.name + " by " + enforcerProper + " (" +
e.reason + ")", "KICK", enforcerNick);
}
this.list.listContainer.removeChild (e.user.getDecoratedNick());
}
CIRCChannel.prototype.onChanMode =
function my_cmode (e)
{
this.display (e.meat + " by " +
e.user.nick, "MODE");
for (var u in e.usersAffected)
e.usersAffected[u].updateDecoratedNick();
}
CIRCChannel.prototype.onNick =
function my_cnick (e)
{
this.display (e.oldNick + " is now known as " + e.user.properNick, "NICK");
if (userIsMe (e.user))
this.display ("YOU are now known as " + e.user.properNick, "NICK",
"!ME");
else
this.display (e.oldNick + " is now known as " + e.user.properNick,
"NICK");
e.user.updateDecoratedNick();
}
@ -466,9 +727,14 @@ CIRCChannel.prototype.onQuit =
function my_cquit (e)
{
this.display (e.user.properNick + " has left " + e.server.parent.name +
" (" + e.reason + ")", "QUIT");
this.list.listContainer.removeChild (e.user.getDecoratedNick());
if (userIsMe(e.user)) /* I dont think this can happen */
this.display ("YOU have left " + e.server.parent.name +
" (" + e.reason + ")", "QUIT", "!ME");
else
this.display (e.user.properNick + " has left " + e.server.parent.name +
" (" + e.reason + ")", "QUIT", e.user.nick);
this.list.remove (e.user.getDecoratedNick());
}

Просмотреть файл

@ -1,3 +1,26 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is JSIRC Test Client #3
*
* The Initial Developer of the Original Code is New Dimensions Consulting,
* Inc. Portions created by New Dimensions Consulting, Inc. Copyright (C) 1999
* New Dimenstions Consulting, Inc. All Rights Reserved.
*
*
* Contributor(s):
* Robert Ginda, rginda@ndcico.com, original author
*/
var client = new Object();
client.COMMAND_CHAR = "/";
@ -13,6 +36,8 @@ client.V0_IMG = "g_grey.gif"; /* user isnt voide image */
client.ACT_IMG = "green-on.gif"; /* view has activity image */
client.NACT_IMG = "green-off.gif"; /* view has no activity image */
client.CUR_IMG = "yellow-on.gif"; /* view is currently displayed */
client.PRINT_DIRECTION = -1; /*1 => new messages at bottom, -1 => at top */
client.name = "*client*";
client.viewsArray = new Array();
client.currentObject = client;
@ -23,9 +48,15 @@ CIRCNetwork.prototype.INITIAL_NAME = "chatzilla";
CIRCNetwork.prototype.INITIAL_DESC = "New Now Know How";
CIRCNetwork.prototype.INITIAL_CHANNEL = "";
CIRCNetwork.prototype.MAX_MESSAGES = 50;
CIRCNetwork.prototype.IGNORE_MOTD = false;
CIRCServer.prototype.READ_TIMEOUT = 0;
CIRCServer.prototype.VERSION_RPLY += "ChatZilla test client #3";
CIRCServer.prototype.VERSION_RPLY += "\nChatZilla test client #3";
if (jsenv.HAS_DOCUMENT)
{
CIRCServer.prototype.VERSION_RPLY += ", running under " +
navigator.userAgent;
}
CIRCUser.prototype.MAX_MESSAGES = 100;
@ -45,12 +76,16 @@ function initStatic()
client.quickList = new CListBox(document.getElementById("quickList"));
client.display ("More help is on the way!", "HELP");
client.display ("/nick, /join, /part, and /me may also be useful.", "HELP");
client.display ("Where <network-name> is one of [" +
keys (client.networks) + "]", "HELP");
client.display ("Use /attach <network-name> connect to a network.", "HELP");
client.display ("Welcome to ChatZilla...", "HELP");
var saveDir = client.PRINT_DIRECTION;
client.PRINT_DIRECTION = 1;
client.display ("Welcome to ChatZilla...\n" +
"Use /attach <network-name> connect to a network.\n" +
"Where <network-name> is one of [" +
keys (client.networks) + "]\n" +
"More help is available with /help [<command-name>]",
"HELLO");
client.PRINT_DIRECTION = saveDir;
setCurrentObject (client);
}
@ -58,6 +93,9 @@ function initStatic()
function initHost(obj)
{
client.commands = new CCommandManager();
addCommands (obj.commands);
obj.networks = new Object();
obj.eventPump = new CEventPump (10);
@ -114,7 +152,8 @@ function setCurrentObject (obj)
}
var tb = getTBForObject(client.currentObject);
tb.setAttribute ("src", client.NACT_IMG);
if (tb)
tb.setAttribute ("src", client.NACT_IMG);
var output = document.getElementById ("output");
@ -130,7 +169,8 @@ function setCurrentObject (obj)
client.currentObject = obj;
tb = getTBForObject(obj);
tb.setAttribute ("src", client.CUR_IMG);
if (tb)
tb.setAttribute ("src", client.CUR_IMG);
}
@ -181,18 +221,20 @@ function addHistory (source, obj)
function notifyActivity (source)
{
var tb = getTBForObject (source);
var tb = getTBForObject (source, true);
if (client.currentObject != source)
tb.setAttribute ("src", "green-on.gif");
tb.setAttribute ("src", client.ACT_IMG);
}
/* gets the toolbutton associated with an object
* creating it if it doesn't exist */
function getTBForObject (source)
* if |create| is present, and true, create if not found */
function getTBForObject (source, create)
{
var name, tb;
var name;
create = (typeof create != "undefined") ? Boolean(create) : false;
switch (source.TYPE)
{
@ -206,22 +248,37 @@ function getTBForObject (source)
case "IRCClient":
name = source.name;
break;
default:
dd ("** INVALID OBJECT passed to getTBForObject **");
return;
}
var id = "tb[" + name + "]";
var tb, id = "tb[" + name + "]";
var matches = 1;
if (!(tb = document.getElementById (id)))
for (var i in client.viewsArray)
if (client.viewsArray[i].source == source)
tb = client.viewsArray[i].tb;
else
if (client.viewsArray[i].tb.id == id)
id = "tb[" + name + "<" + (++matches) + ">]";
if (!tb && create) /* not found, create one */
{
var views = document.getElementById ("views-tbar");
var tbi = document.createElement ("toolbaritem");
tbi.setAttribute ("class", "activity-button");
tbi.setAttribute ("onclick", "onTBIClick('" + id + "')");
var tb = document.createElement ("titledbutton");
tb = document.createElement ("titledbutton");
tb.setAttribute ("id", id);
client.viewsArray.push (source);
client.viewsArray.push ({source: source, tb: tb});
tb.setAttribute ("viewKey", client.viewsArray.length - 1);
tb.setAttribute ("value", name);
if (matches > 1)
tb.setAttribute ("value", name + "<" + matches + ">");
else
tb.setAttribute ("value", name);
tbi.appendChild (tb);
views.appendChild (tbi);
}

Просмотреть файл

@ -1,13 +1,36 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is JSIRC Test Client #2
The Initial Developer of the Original Code is New Dimensions Consulting,
Inc. Portions created by New Dimensions Consulting, Inc. Copyright (C) 1999
New Dimenstions Consulting, Inc. All Rights Reserved.
Contributor(s):
Robert Ginda, rginda@ndcico.com, original author
-->
<!DOCTYPE window>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="test3.css" type="text/css"?>
<!--
file:/home/rginda/src/mozilla_DEV/mozilla/extensions/irc/xul/tests/test3.xul
resource:///irc/tests/test3.xul
-->
<window xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical" onload="onLoad();" onunload="onUnload();">
@ -15,12 +38,14 @@ file:/home/rginda/src/mozilla_DEV/mozilla/extensions/irc/xul/tests/test3.xul
<html:script src="resource:///irc/js/lib/utils.js"/>
<html:script src="resource:///irc/js/lib/connection-xpcom.js"/>
<html:script src="resource:///irc/js/lib/events.js"/>
<html:script src="resource:///irc/js/lib/command-manager.js"/>
<html:script src="resource:///irc/js/lib/irc.js"/>
<html:script src="resource:///irc/js/lib/irc-debug.js"/>
<html:script src="resource:///irc/xul/lib/listbox.js"/>
<html:script src="resource:///irc/tests/test3-static.js"/>
<html:script src="resource:///irc/tests/test3-handlers.js"/>
<html:script src="resource:///irc/tests/test3-commands.js"/>
<toolbox>
<menubar>