]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Refactor RFC1459 case handling functions and their callers, as a consequence fixing...
authorChris Porter <redacted>
Sat, 11 Apr 2009 21:23:46 +0000 (22:23 +0100)
committerChris Porter <redacted>
Sat, 11 Apr 2009 21:23:46 +0000 (22:23 +0100)
js/irc/baseircclient.js
js/irc/ircclient.js
js/irc/irclib.js
js/ui/baseui.js
js/ui/tabcompleter.js

index e5fd5d614df27be248a4e3b3471c1a49ae45f0b1..008160b6637091d2167facce3fd5c9a0fea65cc0 100644 (file)
@@ -28,7 +28,8 @@ qwebirc.irc.BaseIRCClient = new Class({
     this.send = this.connection.send.bind(this.connection);
     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) {
index 589651b52d283547ec4bd552a5436a1d7c841cd8..f37cb6dbce41bcbdaaaff739f36f79efc063ad8e 100644 (file)
@@ -73,10 +73,10 @@ qwebirc.irc.IRCClient = new Class({
       
       if(nc.prefixes.length > 0) {
         var c = nc.prefixes.charAt(0);
-        nx = String.fromCharCode(this.prefixes.indexOf(c)) + n.toIRCLower();
+        nx = String.fromCharCode(this.prefixes.indexOf(c)) + this.toIRCLower(n);
         nh[nx] = c + n;
       } else {
-        nx = tff + n.toIRCLower();
+        nx = tff + this.toIRCLower(n);
         nh[nx] = n;
       }
       names.push(nx);
@@ -94,15 +94,15 @@ qwebirc.irc.IRCClient = new Class({
       w.updateNickList(sortednames);
   },
   getWindow: function(name) {
-    return this.windows[name.toIRCLower()];
+    return this.windows[this.toIRCLower(name)];
   },
   newWindow: function(name, type, select) {
     var w = this.getWindow(name);
     if(!w) {
-      w = this.windows[name.toIRCLower()] = this.ui.newWindow(this, type, name);
+      w = this.windows[this.toIRCLower(name)] = this.ui.newWindow(this, type, name);
       
       w.addEvent("close", function(w) {
-        delete this.windows[name.toIRCLower()];
+        delete this.windows[this.toIRCLower(name)];
       }.bind(this));
     }
     
index 7bd93c3f0708a5ff734dd8606e7b8b31d875daf8..99e061412cbd7b57c67c7229001e88f8ba25875c 100644 (file)
@@ -33,9 +33,7 @@ qwebirc.irc.IRCLowerTable = [
 /* xf8-xff */ '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff'
 ];
 
-String.prototype.toIRCLower = function() {
-  var x = this;
-  
+qwebirc.irc.RFC1459toIRCLower = function(x) {
   var p = [];
   for(var i=0;i<x.length;i++) {
     var l = x.charCodeAt(i);
@@ -46,6 +44,10 @@ String.prototype.toIRCLower = function() {
   return p.join("");
 }
 
+qwebirc.irc.ASCIItoIRCLower = function(x) {
+  return x.toLower(); /* does unicode too.... */
+}
+
 String.prototype.hostToNick = function() {
   return this.split("!", 1)[0];
 }
@@ -64,6 +66,6 @@ qwebirc.irc.IRCDate = function(d) {
   return qwebirc.util.DaysOfWeek[d.getDay()] + " " + qwebirc.util.MonthsOfYear[d.getMonth()] + " " + pad(d.getDate()) + " "  + pad(d.getHours()) + ":" + pad(d.getMinutes()) + ":" + pad(d.getSeconds()) + " " + d.getFullYear();
 }
 
-String.prototype.toIRCCompletion = function() {
-  return this.toIRCLower().replace(/[^\w]+/g, "");
+qwebirc.irc.toIRCCompletion = function(client, data) {
+  return client.toIRCLower(data).replace(/[^\w]+/g, "");
 }
index 7577e35fcc1924d6a5a020fc1cb9786bcc3e7ba8..55e6a6e1ef6598c983b06a745fdcb9e9d8056663 100644 (file)
@@ -47,19 +47,23 @@ qwebirc.ui.BaseUI = new Class({
       return client.id;
     }
   },
-  getWindowIdentifier: function(type, name) {
+  getWindowIdentifier: function(client, type, name) {
     if(type == qwebirc.ui.WINDOW_MESSAGES)
       return "-M";
     if(type == qwebirc.ui.WINDOW_STATUS)
       return "";
-    return "_" + name.toIRCLower();
+
+    if(client == qwebirc.ui.CUSTOM_CLIENT) /* HACK */
+      return "_" + name;
+
+    return "_" + client.toIRCLower(name);
   },
   newWindow: function(client, type, name) {
     var w = this.getWindow(client, type, name);
     if($defined(w))
       return w;
       
-    var wId = this.getWindowIdentifier(type, name);
+    var wId = this.getWindowIdentifier(client, type, name);
     var w = this.windows[this.getClientId(client)][wId] = new this.windowClass(this, client, type, name, wId);
     this.windowArray.push(w);
     
@@ -70,14 +74,14 @@ qwebirc.ui.BaseUI = new Class({
     if(!$defined(c))
       return null;
       
-    return c[this.getWindowIdentifier(type, name)];
+    return c[this.getWindowIdentifier(client, type, name)];
   },
   getActiveWindow: function() {
     return this.active;
   },
   getActiveIRCWindow: function(client) {
     if(!this.active || this.active.type == qwebirc.ui.WINDOW_CUSTOM) {
-      return this.windows[this.getClientId(client)][this.getWindowIdentifier(qwebirc.ui.WINDOW_STATUS)];
+      return this.windows[this.getClientId(client)][this.getWindowIdentifier(client, qwebirc.ui.WINDOW_STATUS)];
     } else {
       return this.active;
     }
index 726c48b0b20f447e3b852a89024b9b74d721f2e1..2058f778ab213c3a2635e35abe3adab7254dec5d 100644 (file)
@@ -65,19 +65,19 @@ qwebirc.ui.TabCompleterFactory = new Class({
 });
 
 qwebirc.ui.TabIterator = new Class({
-  initialize: function(prefix, list) {
+  initialize: function(client, prefix, list) {
     this.prefix = prefix;
     if(!$defined(list) || list.length == 0) {
       this.list = null;
     } else {
       var l = [];
       
-      var prefixl = prefix.toIRCCompletion();
+      var prefixl = qwebirc.irc.toIRCCompletion(client, prefix);
       
       /* convert the nick list to IRC lower case, stripping all non letters
        * before comparisions */
       for(var i=0;i<list.length;i++) {
-        var l2 = list[i].toIRCCompletion();
+        var l2 = qwebirc.irc.toIRCCompletion(client, list[i]);
         
         if(l2.startsWith(prefixl))
           l.push(list[i]);
@@ -104,11 +104,11 @@ qwebirc.ui.TabIterator = new Class({
 });
 
 qwebirc.ui.BaseTabCompleter = new Class({
-  initialize: function(prefix, existingNick, suffix, list) {
+  initialize: function(client, prefix, existingNick, suffix, list) {
     this.existingNick = existingNick;
     this.prefix = prefix;
     this.suffix = suffix;
-    this.iterator = new qwebirc.ui.TabIterator(existingNick, list);
+    this.iterator = new qwebirc.ui.TabIterator(client, existingNick, list);
   },
   get: function() {
     var n = this.iterator.next();
@@ -123,7 +123,7 @@ qwebirc.ui.BaseTabCompleter = new Class({
 qwebirc.ui.QueryTabCompleter = new Class({
   Extends: qwebirc.ui.BaseTabCompleter,
   initialize: function(prefix, existingNick, suffix, window) {
-    this.parent(prefix, existingNick, suffix, window.client.lastNicks);
+    this.parent(window.client, prefix, existingNick, suffix, window.client.lastNicks);
   }
 });
 
@@ -133,7 +133,7 @@ qwebirc.ui.ChannelNameTabCompleter = new Class({
 
     /* WTB map */
     var l = [];
-    var wa = window.parentObject.windows[window.client];
+    var wa = window.parentObject.windows[window.parentObject.getClientId(window.client)];
     
     for(var c in window.client.channels) {
       var w = wa[c];
@@ -152,7 +152,7 @@ qwebirc.ui.ChannelNameTabCompleter = new Class({
     var l2 = [];    
     for(var i=0;i<l.length;i++)
       l2.push(l[i][1]);
-    this.parent(prefix, existingText, suffix, l2);
+    this.parent(window.client, prefix, existingText, suffix, l2);
   }
 });
 
@@ -161,6 +161,6 @@ qwebirc.ui.ChannelUsersTabCompleter = new Class({
   initialize: function(prefix, existingText, suffix, window) {
     var nc = window.client.tracker.getSortedByLastSpoke(window.name);
 
-    this.parent(prefix, existingText, suffix, nc);
+    this.parent(window.client, prefix, existingText, suffix, nc);
   }
 });