]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseui.js
Redo window naming system to use window name identifiers.
[irc/quakenet/qwebirc.git] / js / ui / baseui.js
index 627a55b871301aaef6d4817c767f290351fde4d0..6b2887f39051f7ff578faa569ad562b36af2289b 100644 (file)
@@ -3,6 +3,7 @@ qwebirc.ui.WINDOW_QUERY = 2;
 qwebirc.ui.WINDOW_CHANNEL = 3;
 qwebirc.ui.WINDOW_CUSTOM = 4;
 qwebirc.ui.WINDOW_CONNECT = 5;
+qwebirc.ui.WINDOW_MESSAGES = 6;
 qwebirc.ui.CUSTOM_CLIENT = "custom";
 
 qwebirc.ui.BaseUI = new Class({
@@ -50,22 +51,37 @@ qwebirc.ui.BaseUI = new Class({
       return client.id;
     }
   },
-  newWindow: function(client, type, name) {
-    var identifier = name;
+  getWindowIdentifier: function(type, name) {
+    if(type == qwebirc.ui.WINDOW_MESSAGES)
+      return "-M";
     if(type == qwebirc.ui.WINDOW_STATUS)
-      identifier = "";
+      return "";
+    return "_" + name;
+  },
+  newWindow: function(client, type, name) {
+    var w = this.getWindow(client, type, name);
+    if($defined(w))
+      return w;
       
-    var w = this.windows[this.getClientId(client)][identifier] = new this.windowClass(this, client, type, name, identifier);
+    var wId = this.getWindowIdentifier(type, name);
+    var w = this.windows[this.getClientId(client)][wId] = new this.windowClass(this, client, type, name, wId);
     this.windowArray.push(w);
     
     return w;
   },
+  getWindow: function(client, type, name) {
+    var c = this.windows[this.getClientId(client)];
+    if(!$defined(c))
+      return null;
+      
+    return c[this.getWindowIdentifier(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)][""];
+      return this.windows[this.getClientId(client)][this.getWindowIdentifier(qwebirc.ui.WINDOW_STATUS)];
     } else {
       return this.active;
     }
@@ -193,7 +209,7 @@ qwebirc.ui.StandardUI = new Class({
       
     var w = this.newWindow(qwebirc.ui.CUSTOM_CLIENT, type, name);
     w.addEvent("close", function(w) {
-      delete this.windows[qwebirc.ui.CUSTOM_CLIENT][name];
+      delete this.windows[qwebirc.ui.CUSTOM_CLIENT][w.identifier];
     }.bind(this));
     
     if(select)