initialize: function(options) {
this.setOptions(options);
+ this.toIRCLower = qwebirc.irc.RFC1459toIRCLower;
+
this.nickname = this.options.nickname;
-
+ this.lowerNickname = this.toIRCLower(this.nickname);
+
this.__signedOn = false;
this.pmodes = {b: true, k: true, o: true, l: true, v: true};
this.channels = {}
this.connect = this.connection.connect.bind(this.connection);
this.disconnect = this.connection.disconnect.bind(this.connection);
- this.toIRCLower = qwebirc.irc.RFC1459toIRCLower;
this.setupGenericErrors();
},
dispatch: function(data) {
/* TODO: warn */
}
}
+ this.lowerNickname = this.toIRCLower(this.nickname);
},
irc_RPL_WELCOME: function(prefix, params) {
this.nickname = params[0];
-
+ this.lowerNickname = this.toIRCLower(this.nickname);
this.__signedOn = true;
this.signedOn(this.nickname);
},
var oldnick = user.hostToNick();
var newnick = params[0];
- if(this.nickname == oldnick)
+ if(this.nickname == oldnick) {
this.nickname = newnick;
-
+ this.lowerNickname = this.toIRCLower(this.nickname);
+ }
+
this.nickChanged(user, newnick);
return true;
var bg;
var underline = false;
var bold = false;
-
+ var autoNickColour = false;
+
var out = [];
var xline = line.split("");
var element = document.createElement("span");
}
function emitEndToken() {
+ var data = "";
if(out.length > 0) {
- qwebirc.ui.urlificate(element, out.join(""), execfn, cmdfn, window);
+ var data = qwebirc.ui.urlificate(element, out.join(""), execfn, cmdfn, window);
entity.appendChild(element);
out = [];
}
element = document.createElement("span");
+ return data;
}
+
function emitStartToken() {
+ if(autoNickColour)
+ return element;
+
var classes = []
if(fg != undefined)
classes.push("Xc" + fg);
element.className = classes.join(" ");
}
+ var nickColouring = window.parentObject.uiOptions.NICK_COLOURS; /* HACK */
+ var capturingNick = false;
for(var i=0;i<xline.length;i++) {
var lc = xline[i];
+
+ if(nickColouring) {
+ if(!capturingNick) {
+ if(lc == "\x00") {
+ capturingNick = true;
+ emitEndToken();
+ continue;
+ }
+ } else {
+ if(lc != "\x00") {
+ out.push(lc);
+ } else {
+ autoNickColour = true;
+ var e = emitStartToken();
+ var text = emitEndToken();
+
+ var c = text.toHSBColour(window.client);
+ if($defined(c))
+ e.style.color = c.rgbToHex();
+ capturingNick = autoNickColour = false;
+ }
+ continue;
+ }
+ } else if(lc == "\x00") {
+ continue;
+ }
+
if(lc == "\x02") {
emitEndToken();
emitEndToken();
}
+
+String.prototype.toHSBColour = function(client) {
+ var lower = client.toIRCLower(client.stripPrefix(this));
+ if(lower == client.lowerNickname)
+ return null;
+
+ var hash = 0;
+ for(var i=0;i<lower.length;i++)
+ hash = 31 * hash + lower.charCodeAt(i);
+
+ var hue = Math.abs(hash) % 360;
+
+ return new Color([hue, 70, 60], "hsb");
+}
} else {
this.reflow();
}
+
+ this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS;
},
editTopic: function() {
if(!this.client.nickOnChanHasPrefix(this.client.nickname, this.name, "@")) {
this.prevNick = null;
},
nickListAdd: function(nick, position) {
+ var realNick = this.client.stripPrefix(nick);
+
var e = new Element("a");
qwebirc.ui.insertAt(position, this.nicklist, e);
e.href = "#";
- e.appendChild(document.createTextNode(nick));
+ var span = new Element("span");
+ if(this.parentObject.uiOptions.NICK_COLOURS) {
+ var colour = realNick.toHSBColour(this.client);
+ if($defined(colour))
+ span.setStyle("color", colour.rgbToHex());
+ }
+ span.set("text", nick);
+ e.appendChild(span);
- e.realNick = this.client.stripPrefix(nick);
+ e.realNick = realNick;
e.addEvent("click", function(x) {
if(this.prevNick == e) {
if(inputVisible)
this.parentObject.inputbox.focus();
+
+ if(this.type == qwebirc.ui.WINDOW_CHANNEL && this.nicksColoured != this.parentObject.uiOptions.NICK_COLOURS) {
+ this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS;
+
+ var nodes = this.nicklist.childNodes;
+ if(this.parentObject.uiOptions.NICK_COLOURS) {
+ for(var i=0;i<nodes.length;i++) {
+ var e = nodes[i], span = e.firstChild;
+ var colour = e.realNick.toHSBColour(this.client);
+ if($defined(colour))
+ span.setStyle("color", colour.rgbToHex());
+ };
+ } else {
+ for(var i=0;i<nodes.length;i++) {
+ var span = nodes[i].firstChild;
+ span.setStyle("color", null);
+ };
+ }
+ }
},
deselect: function() {
this.parent();
[3, "NICK_OV_STATUS", "Show status (@/+) before nicknames in nicklist", true],
[5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true],
[6, "USE_HIDDENHOST", "Hide your hostmask when authed to Q (+x)", true],
- [8, "LASTPOS_LINE", "Show a last position indicator for each window", true]
+ [8, "LASTPOS_LINE", "Show a last position indicator for each window", true],
+ [9, "NICK_COLOURS", "Automatically colour nicknames", false]
];
qwebirc.config.DefaultOptions = null;
"B": "\x02",
"U": "\x1F",
"O": "\x0F",
+ "{": "\x00",
+ "}": "\x00",
"[": "qwebirc://whois/",
"]": "/",
"$": "$"
"DISCONNECT": ["Disconnected from server: $m", true],
"ERROR": ["ERROR: $m", true],
"SERVERNOTICE": ["$m", true],
- "JOIN": ["$N [$h] has joined $c", true],
- "OURJOIN": ["$N [$h] has joined $c", true],
- "PART": ["$N [$h] has left $c [$m]", true],
- "KICK": ["$v was kicked from $c by $N [$m]", true],
- "MODE": ["mode/$c [$m] by $N", true],
- "QUIT": ["$N [$h] has quit [$m]", true],
- "NICK": ["$n has changed nick to $[$w$]", true],
- "TOPIC": ["$N changed the topic of $c to: $m", true],
+ "JOIN": ["${$N$} [$h] has joined $c", true],
+ "OURJOIN": ["${$N$} [$h] has joined $c", true],
+ "PART": ["${$N$} [$h] has left $c [$m]", true],
+ "KICK": ["${$v$} was kicked from $c by ${$N$} [$m]", true],
+ "MODE": ["mode/$c [$m] by ${$N$}", true],
+ "QUIT": ["${$N$} [$h] has quit [$m]", true],
+ "NICK": ["${$n$} has changed nick to ${$[$w$]$}", true],
+ "TOPIC": ["${$N$} changed the topic of $c to: $m", true],
"UMODE": ["Usermode change: $m", true],
"INVITE": ["$N invites you to join $c", true],
"HILIGHT": ["$C4"],
"HILIGHTEND": ["$O"],
- "CHANMSG": ["<$@$($N$)> $m"],
+ "CHANMSG": ["<${$@$($N$)$}> $m"],
"PRIVMSG": ["<$($N$)> $m"],
- "CHANNOTICE": ["-$($N$):$c- $m"],
+ "CHANNOTICE": ["-${$($N$)$}:$c- $m"],
"PRIVNOTICE": ["-$($N$)- $m"],
- "OURCHANMSG": ["<$B$@$N$B> $m"],
- "OURPRIVMSG": ["<$B$N$B> $m"],
+ "OURCHANMSG": ["<$@$N> $m"],
+ "OURPRIVMSG": ["<$N> $m"],
"OURTARGETEDMSG": ["*$[$t$]* $m"],
"OURTARGETEDNOTICE": ["[notice($[$t$])] $m"],
"OURCHANNOTICE": ["-$N:$t- $m"],
"OURPRIVNOTICE": ["-$N- $m"],
"OURCHANACTION": [" * $N $m"],
"OURPRIVACTION": [" * $N $m"],
- "CHANACTION": [" * $($N$) $m"],
+ "CHANACTION": [" * ${$($N$)$} $m"],
"PRIVACTION": [" * $($N$) $m"],
"CHANCTCP": ["$N [$h] requested CTCP $x from $c: $m"],
"PRIVCTCP": ["$N [$h] requested CTCP $x from $-: $m"],
this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
- this.__ccmap["("] = "";
- this.__ccmap[")"] = "";
-
this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
+ this.__ccmaph["{"] = this.__ccmaph["}"] = "";
},
__dollarSubstitute: function(x, h, mapper) {
var msg = [];
qwebirc.ui.urlificate = function(element, text, execfn, cmdfn, window) {
var punct_re = /[[\)|\]]?(\.*|[\,;])$/;
-
+ var addedText = [];
+
var txtprocess = function(text, regex, appendfn, matchfn) {
for(;;) {
var index = text.search(regex);
};
var appendText = function(text) {
+ addedText.push(text);
qwebirc.util.NBSPCreate(text, element);
};
var appendChan = function(text) {
var newtext = text.replace(punct_re, "");
+ addedText.push(newtext);
var punct = text.substring(newtext.length);
var a = new Element("span");
if(target)
a.target = target;
}
+ addedText.push(disptext);
a.appendChild(document.createTextNode(disptext));
element.appendChild(a);
txtprocess(text, /\b((https?|ftp|qwebirc):\/\/|www\.)[^ ]+/, function(text) {
txtprocess(text, /\B#[^ ,]+/, appendText, appendChan);
}, appendURL);
+
+ return addedText.join("");
}