]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseuiwindow.js
Fix font issue.
[irc/quakenet/qwebirc.git] / js / ui / baseuiwindow.js
index 82c5af7bf6fee015d940f603469409d3c9b71f4b..bde4c4f5b4ab00bcbf7d6c7456d744981d8efc7d 100644 (file)
@@ -16,7 +16,10 @@ qwebirc.ui.Window = new Class({
     this.scrolltimer = null;
     this.commandhistory = this.parentObject.commandhistory;
     this.scrolleddown = true;
-    //new CommandHistory();
+    this.scrollpos = null;
+    this.lastNickHash = {};
+    this.lastSelected = null;
+    this.closed = false;
   },
   updateNickList: function(nicks) {
   },
@@ -24,6 +27,8 @@ qwebirc.ui.Window = new Class({
     qwebirc.ui.Colourise("[" + topic + "]", element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this);
   },
   close: function() {
+    this.closed = true;
+    
     if($defined(this.scrolltimer)) {
       $clear(this.scrolltimer);
       this.scrolltimer = null;
@@ -37,12 +42,12 @@ qwebirc.ui.Window = new Class({
     this.parentObject.__setActiveWindow(this);
     if(this.hilighted)
       this.setHilighted(qwebirc.ui.HILIGHT_NONE);
-    if(this.scrolleddown)
-      this.scrollToBottom();
+      
+    this.resetScrollPos();
+    this.lastSelected = new Date();
   },
   deselect: function() {
-    if(!this.parentObject.singleWindow)
-      this.scrolleddown = this.scrolledDown();
+    this.setScrollPos();
     if($defined(this.scrolltimer)) {
       $clear(this.scrolltimer);
       this.scrolltimer = null;
@@ -50,17 +55,40 @@ qwebirc.ui.Window = new Class({
 
     this.active = false;
   },
+  resetScrollPos: function() {
+    if(this.scrolleddown) {
+      this.scrollToBottom();
+    } else if($defined(this.scrollpos)) {
+      this.getScrollParent().scrollTo(this.scrollpos.x, this.scrollpos.y);
+    }
+  },
+  setScrollPos: function() {
+    if(!this.parentObject.singleWindow) {
+      this.scrolleddown = this.scrolledDown();
+      this.scrollpos = this.lines.getScroll();
+    }
+  },
   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
-        } else if(!type.match(/^OUR/) && this.client.hilightController.match(line["m"])) {
+        if(this.type == qwebirc.ui.WINDOW_QUERY || this.type == qwebirc.ui.WINDOW_MESSAGES) {
+          if(type.match(/^OUR/) || type.match(/NOTICE$/)) {
+            hilight = qwebirc.ui.HILIGHT_ACTIVITY;
+          } else {
+            hilight = qwebirc.ui.HILIGHT_US;
+            this.parentObject.beep();
+          }
+        }
+        if(!type.match(/^OUR/) && this.client.hilightController.match(line["m"])) {
+          lhilight = true;
           hilight = qwebirc.ui.HILIGHT_US;
-        } else {
+          this.parentObject.beep();
+        } else if(hilight != qwebirc.ui.HILIGHT_US) {
           hilight = qwebirc.ui.HILIGHT_SPEECH;
         }
       }
@@ -70,13 +98,16 @@ qwebirc.ui.Window = new Class({
       this.setHilighted(hilight);
 
     if(type)
-      line = this.parentObject.theme.message(type, line, hilight == qwebirc.ui.HILIGHT_US);
+      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");
+    this.addLine("", message, "#FF6347");
+  },
+  infoMessage: function(message) {
+    this.addLine("", message, "#87CEFA");
   },
   setHilighted: function(state) {
     if(state == qwebirc.ui.HILIGHT_NONE || state >= this.hilighted)
@@ -98,12 +129,16 @@ qwebirc.ui.Window = new Class({
       
     return prev.y + prevsize.y == prevbottom;
   },
-  scrollToBottom: function() {
-    var parent = this.lines;
-    var scrollparent = parent;
+  getScrollParent: function() {
+    var scrollparent = this.lines;
 
     if($defined(this.scroller))
       scrollparent = this.scroller;
+    return scrollparent;
+  },
+  scrollToBottom: function() {
+    var parent = this.lines;
+    var scrollparent = this.getScrollParent();
       
     scrollparent.scrollTo(parent.getScroll().x, parent.getScrollSize().y);
   },
@@ -124,6 +159,35 @@ qwebirc.ui.Window = 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);