]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseuiwindow.js
Fix version in ctcp.
[irc/quakenet/qwebirc.git] / js / ui / baseuiwindow.js
index a0c263215346c32208d7b486caf4dcb1dfeee0bd..4a9d06b6939e4f0fa25c61c9b4f340ecffe178e6 100644 (file)
@@ -1,4 +1,9 @@
-var UIWindow = new Class({
+qwebirc.ui.HILIGHT_NONE = 0;
+qwebirc.ui.HILIGHT_ACTIVITY = 1;
+qwebirc.ui.HILIGHT_SPEECH = 2;
+qwebirc.ui.HILIGHT_US = 3;
+
+qwebirc.ui.Window = new Class({
   Implements: [Events],
   initialize: function(parentObject, client, type, name, identifier) {
     this.parentObject = parentObject;
@@ -7,15 +12,17 @@ var UIWindow = new Class({
     this.active = false;
     this.client = client;
     this.identifier = identifier;
-    this.hilighted = false;
+    this.hilighted = qwebirc.ui.HILIGHT_NONE;
     this.scrolltimer = null;
     this.commandhistory = this.parentObject.commandhistory;
     this.scrolleddown = true;
+    this.lastNickHash = {};
     //new CommandHistory();
   },
   updateNickList: function(nicks) {
   },
-  updateTopic: function(topic)  {
+  updateTopic: function(topic, element)  {
+    qwebirc.ui.Colourise("[" + topic + "]", element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this);
   },
   close: function() {
     if($defined(this.scrolltimer)) {
@@ -30,7 +37,7 @@ var UIWindow = new Class({
     this.active = true;
     this.parentObject.__setActiveWindow(this);
     if(this.hilighted)
-      this.setHilighted(false);
+      this.setHilighted(qwebirc.ui.HILIGHT_NONE);
     if(this.scrolleddown)
       this.scrollToBottom();
   },
@@ -44,22 +51,41 @@ var UIWindow = new Class({
 
     this.active = false;
   },
-  addLine: function(type, line, colour, element, parent, scrollparent) {
-    if(!this.active && !this.hilighted)
-      this.setHilighted(true);
+  addLine: function(type, line, colour, element) {
+    var hilight = qwebirc.ui.HILIGHT_NONE;
+    var lhilight = false;
     
+    if(type) {
+      hilight = qwebirc.ui.HILIGHT_ACTIVITY;
+      
+      if(type.match(/(NOTICE|ACTION|MSG)$/)) {
+        if(this.type == qwebirc.ui.WINDOW_QUERY) {
+          hilight = qwebirc.ui.HILIGHT_US;
+        }
+        if(!type.match(/^OUR/) && this.client.hilightController.match(line["m"])) {
+          lhilight = true;
+          hilight = qwebirc.ui.HILIGHT_US;
+        } else if(hilight != qwebirc.ui.HILIGHT_US) {
+          hilight = qwebirc.ui.HILIGHT_SPEECH;
+        }
+      }
+    }
+
+    if(!this.active && (hilight != qwebirc.ui.HILIGHT_NONE))
+      this.setHilighted(hilight);
+
     if(type)
-      line = this.parentObject.theme.message(type, line);
-    
-    Colourise(IRCTimestamp(new Date()) + " " + line, element);
+      line = this.parentObject.theme.message(type, line, lhilight);
     
+    qwebirc.ui.Colourise(qwebirc.irc.IRCTimestamp(new Date()) + " " + line, element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this);
     this.scrollAdd(element);
   },
   errorMessage: function(message) {
     this.addLine("", message, "red");
   },
   setHilighted: function(state) {
-    this.hilighted = state;
+    if(state == qwebirc.ui.HILIGHT_NONE || state >= this.hilighted)
+      this.hilighted = state;
   },
   scrolledDown: function() {
     if(this.scrolltimer)
@@ -71,6 +97,10 @@ var UIWindow = new Class({
     var prevbottom = parent.getScrollSize().y;
     var prevsize = parent.getSize();
     
+    /* fixes an IE bug */
+    if(prevbottom < prevsize.y)
+      prevbottom = prevsize.y;
+      
     return prev.y + prevsize.y == prevbottom;
   },
   scrollToBottom: function() {
@@ -99,6 +129,35 @@ var UIWindow = new Class({
       this.scrolltimer = null;
     }
   },
+  updateNickList: function(nicks) {
+    var nickHash = {}, present = {};
+    var added = [];
+    var lnh = this.lastNickHash;
+    
+    for(var i=0;i<nicks.length;i++)
+      present[nicks[i]] = 1;
+    
+    for(var k in lnh)
+      if(!present[k])
+        this.nickListRemove(k, lnh[k]);
+        
+    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;
+    }
+    
+    this.lastNickHash = nickHash;
+  },
+  nickListAdd: function(position, nick) {
+  },
+  nickListRemove: function(nick, stored) {
+  },
   historyExec: function(line) {
     this.commandhistory.addLine(line);
     this.client.exec(line);