rem: /* Why are we messing with __proto__? * * Well, the short answer is so we can check the parameters passed to the * command properly. * * The long answer is that when a command is being dispatch, e.__proto__ is * set to the result of getObjectDetails() on the source view. This is for * a reason - it means that a parameter <channel-name> is automatically * filled in when run from a channel view, for example. However, here we * don't want just "a parameter" to satisfy some need, we actually want to * check the user's supplied parameters - clearing __proto__ allows this. * Naturally we put it back afterwards. (The upshot, and intended effect, * is that doing "/join" from a channel view will still open the dialog.) 
add: /* This check makes sure we only check if the *user* entered anything, and * ignore any contextual information, like the channel the command was * run on. 
context: function cmdJoin(e){    /* Why are we messing with __proto__?     *     * Well, the short answer is so we can check the parameters passed to the     * command properly.     *     * The long answer is that when a command is being dispatch, e.__proto__ is     * set to the result of getObjectDetails() on the source view. This is for     * a reason - it means that a parameter <channel-name> is automatically     * filled in when run from a channel view, for example. However, here we     * don't want just "a parameter" to satisfy some need, we actually want to     * check the user's supplied parameters - clearing __proto__ allows this.     * Naturally we put it back afterwards. (The upshot, and intended effect,     * is that doing "/join" from a channel view will still open the dialog.)     */    var oldProto = e.__proto__;    e.__proto__ = Object;    if (!e.channelName)    {        window.openDialog("chrome://chatzilla/content/channels.xul", "",                          "modal,resizable=yes", { client: client })        return null;    }    e.__proto__ = oldProto;    if (!("charset" in e))    {        e.charset = null;    }    else if (e.charset && !checkCharset(e.charset))    {        display (getMsg(MSG_ERR_INVALID_CHARSET, e.charset), MT_ERROR);        return null;    }    if (e.channelName && (e.channelName.search(",") != -1))    {        // We can join multiple channels! Woo!        var chan;        var chans = e.channelName.split(",");        var keys = [];        if (e.key)            keys = e.key.split(",");        for (var c in chans)        {            chan = dispatch("join", { charset: e.charset,                                      channelName: chans[c],                                      key: keys.shift() });        }        return chan;    }    if (!e.channelName)    {        var channel = e.channel;        if (!channel)        {            display(getMsg(MSG_ERR_REQUIRED_PARAM, "channel"), MT_ERROR);            return null;        }        e.channelName = channel.unicodeName;        if (channel.mode.key)            e.key = channel.mode.key    }    if (arrayIndexOf(e.server.channelTypes, e.channelName[0]) == -1)        e.channelName = e.server.channelTypes[0] + e.channelName;    var charset = e.charset ? e.charset : e.network.prefs["charset"];    e.channel = e.server.addChannel(e.channelName, charset);    if (e.charset)        e.channel.prefs["charset"] = e.charset;    e.channel.join(e.key);    /* !-channels are "safe" channels, and get a server-generated prefix. For     * this reason, we shouldn't do anything client-side until the server     * replies (since the reply will have the appropriate prefix). */    if (e.channelName[0] != "!")    {        if (!("messages" in e.channel))        {            e.channel.displayHere(getMsg(MSG_CHANNEL_OPENED,                                         e.channel.unicodeName), MT_INFO);        }        dispatch("set-current-view", { view: e.channel });    }    return e.channel;}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/5f0f900ac6d4e7c73f36eb52cfcb64f23a78b81d/commands.js/clean/extensions/irc/xul/content/commands.js