]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Improve nicklist performance.
authorChris Porter <redacted>
Mon, 20 Oct 2008 17:53:14 +0000 (18:53 +0100)
committerChris Porter <redacted>
Mon, 20 Oct 2008 17:53:14 +0000 (18:53 +0100)
Add nicklist manipulation (stage 1).

TODO.txt
js/irc/ircclient.js
js/jslib.js
js/ui/baseuiwindow.js
js/ui/qui.js
static/css/qui.css

index 4db38a5e711e84655e177faa7ff6ad117229b08b..35fa380052b6520c4114bb8f91198b004bc1eea4 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,6 +1,8 @@
 sound\r
 padding\r
 prettify wizard\r
-double click -> query\r
 tab completion\r
 options for notices and stuff\r
+noscript\r
+@+ in nick shown in text\r
+hilight in query bug fix
\ No newline at end of file
index 7004f221cdbcee66f5f0e9857be6f62b47337e69..23dc104b8f674f2e4d34fbb04b38f6aacf95205e 100644 (file)
@@ -124,6 +124,16 @@ qwebirc.irc.IRCClient = new Class({
     
     nickchanentry.prefixes = prefixes.join("");
   },
+  stripPrefix: function(nick) {
+    var l = nick.charAt(0);
+    if(!l)
+      return nick;
+      
+    if(this.prefixes.indexOf(l) != -1)
+      return nick.substring(1);
+      
+    return nick;
+  },
   removePrefix: function(nickchanentry, prefix) {
     nickchanentry.prefixes = nickchanentry.prefixes.replaceAll(prefix, "");
   },
index 07a7e74644448c0e2ae2bd5d1a0732efea954cc3..63281a3786b9742a2d06a1bcf3dad033346fcb72 100644 (file)
@@ -139,4 +139,12 @@ RegExp.escape = function(text) {
   }
   
   return text.replace(arguments.callee.sRE, '\\$1');
+}
+
+qwebirc.ui.insertAt = function(position, parent, element) {
+  if(!parent.childNodes || (position >= parent.childNodes.length)) {
+    parent.appendChild(element);
+  } else {
+    parent.insertBefore(element, parent.childNodes[position]);
+  }
 }
\ No newline at end of file
index 82c5af7bf6fee015d940f603469409d3c9b71f4b..ded43fda2bda65df0e0cfb0bdb05a178af9285cf 100644 (file)
@@ -16,6 +16,7 @@ qwebirc.ui.Window = new Class({
     this.scrolltimer = null;
     this.commandhistory = this.parentObject.commandhistory;
     this.scrolleddown = true;
+    this.lastNickHash = {};
     //new CommandHistory();
   },
   updateNickList: function(nicks) {
@@ -124,6 +125,32 @@ qwebirc.ui.Window = new Class({
       this.scrolltimer = null;
     }
   },
+  updateNickList: function(nicks) {
+    var nickHash = {};
+    var added = [];
+    var lnh = this.lastNickHash;
+    
+    for(var i=0;i<nicks.length;i++) {
+      var n = nicks[i];
+      var l = lnh[n];
+      if(!l) {
+        l = this.nickListAdd(n, i);
+        if(!l)
+          l = 1;
+      }
+      nickHash[n] = l;
+    }
+    
+    for(var k in lnh)
+      if(!nickHash[k])
+        this.nickListRemove(k, lnh[k]);
+        
+    this.lastNickHash = nickHash;
+  },
+  nickListAdd: function(position, nick) {
+  },
+  nickListRemove: function(nick, stored) {
+  },
   historyExec: function(line) {
     this.commandhistory.addLine(line);
     this.client.exec(line);
index 676029cc4ba7d4db7773c9f4e45dfe3480a2cdfe..967e57faf3ed77d3609ac3e72ce6cbbbf338145e 100644 (file)
@@ -196,6 +196,7 @@ qwebirc.ui.QUI.Window = new Class({
 
     this.tab = new Element("a", {"href": "#"});
     this.tab.addClass("tab");
+    this.tab.addEvent("focus", this.tab.blur);
     parentObject.tabs.appendChild(this.tab);
     
     this.tab.appendText(name);
@@ -216,7 +217,7 @@ qwebirc.ui.QUI.Window = new Class({
 
         this.close();
       }.bind(this));
-
+      
       this.tab.appendChild(tabclose);
     }
 
@@ -235,9 +236,16 @@ qwebirc.ui.QUI.Window = new Class({
       this.topic.set("html", "&nbsp;");
       this.parentObject.qjsui.applyClasses("topic", this.topic);
       
+      this.prevNick = null;
       this.nicklist = new Element("div");
       this.nicklist.addClass("nicklist");
       this.nicklist.addClass("tab-invisible");
+      this.nicklist.addEvent("click", function(x) {
+        if(this.prevNick) {
+          this.prevNick.removeClass("selected");
+          this.prevNick = null;
+        }
+      }.bind(this));
       this.parentObject.qjsui.applyClasses("nicklist", this.nicklist);
     }
     
@@ -254,18 +262,33 @@ qwebirc.ui.QUI.Window = new Class({
     if(this.scrolleddown)
       this.scrollToBottom();
   },
-  updateNickList: function(nicks) {
-    this.parent(nicks);
+  nickListAdd: function(nick, position) {
+    var e = new Element("a");
+    qwebirc.ui.insertAt(position, this.nicklist, e);
     
-    var n = this.nicklist;
-    while(n.firstChild)
-      n.removeChild(n.firstChild);
-
-    nicks.each(function(nick) {
-      var e = new Element("div");
-      n.appendChild(e);
-      e.appendChild(document.createTextNode(nick));
-    });
+    e.href = "#";
+    e.appendChild(document.createTextNode(nick));
+    
+    e.realNick = this.client.stripPrefix(nick);
+    
+    e.addEvent("click", function(x) {
+      if(this.prevNick)
+        this.prevNick.removeClass("selected");
+      this.prevNick = e;
+      e.addClass("selected");
+      new Event(x).stop();
+    }.bind(this));
+    e.addEvent("dblclick", function(x) {
+      new Event(x).stop();
+      this.client.exec("/QUERY " + e.realNick);
+    }.bind(this));
+    
+    e.addEvent("focus", e.blur);
+    
+    return e;
+  },
+  nickListRemove: function(nick, stored) {
+    this.nicklist.removeChild(stored);
   },
   updateTopic: function(topic) {
     var t = this.topic;
index 53d05ec672d80a0ac3eb5149462655e5c4a6464e..f62ed8f96b7aec248de2d5ab0037260a2c3b058f 100644 (file)
@@ -84,19 +84,6 @@ body {
   background: #f2f0ff;
 }
 
-.qwebirc-qui .nicklist {
-  border-left: 1px solid #c8d2dc;
-  position: absolute;
-  top: 0px;
-  right: 0px;
-  width: 125px;
-  overflow: auto;
-  background: #f2f0ff;
-  color: black;
-  font-family: Verdana, sans-serif;
-  font-size: 0.7em;
-}
-
 .qwebirc-qui .tabbar {
   border-bottom: 1px solid #c3cee0;
   background: #e2ecf9;
@@ -131,11 +118,11 @@ body {
 }
 
 .qwebirc-qui .topic .emptytopic {
-  color: grey;
+  color: gray;
 }
 
 .qwebirc-qui .topic {
-  color: grey;
+  color: gray;
   font-family: Verdana, sans-serif;
   padding-left: 5px;
   font-size: 0.7em;
@@ -205,3 +192,36 @@ body {
 .qwebirc-qui a.tab-hilight-us {
   color: red;
 }
+
+.qwebirc-qui .nicklist {
+  border-left: 1px solid #c8d2dc;
+  position: absolute;
+  top: 0px;
+  right: 0px;
+  width: 125px;
+  overflow: auto;
+  background: #f2f0ff;
+  color: black;
+  font-family: Verdana, sans-serif;
+  font-size: 0.7em;
+}
+
+.qwebirc-qui .nicklist a {
+  display: block;
+  color: black;
+  text-decoration: none;
+  cursor: default;
+  border-top: 1px solid #f2f0ff;
+  border-bottom: 1px solid #f2f0ff;
+  padding-left: 1px;
+}
+
+.qwebirc-qui .nicklist a.selected {
+  display: block;
+  color: black;
+  background: white;
+  text-decoration: none;
+  border-top: #c8d2dc 1px solid;
+  border-bottom: #c8d2dc 1px solid;
+  cursor: default;
+}
\ No newline at end of file