]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseuiwindow.js
Tidy up style internals somewhat, and add ability for option based CSS.
[irc/quakenet/qwebirc.git] / js / ui / baseuiwindow.js
index 9dcb7a2209474dbf5b61ff760ca87d8ff3432e46..080d93ce0f548acf535192f7d1b3befd3cd3a795 100644 (file)
@@ -3,6 +3,8 @@ qwebirc.ui.HILIGHT_ACTIVITY = 1;
 qwebirc.ui.HILIGHT_SPEECH = 2;
 qwebirc.ui.HILIGHT_US = 3;
 
+qwebirc.ui.MAXIMUM_LINES_PER_WINDOW = 1000;
+
 qwebirc.ui.WINDOW_LASTLINE = qwebirc.ui.WINDOW_QUERY | qwebirc.ui.WINDOW_MESSAGES | qwebirc.ui.WINDOW_CHANNEL | qwebirc.ui.WINDOW_STATUS;
 
 qwebirc.ui.Window = new Class({
@@ -148,13 +150,16 @@ qwebirc.ui.Window = new Class({
     
     var prev = parent.getScroll();
     var prevbottom = parent.getScrollSize().y;
-    var prevsize = parent.getSize();
-    
-    /* fixes an IE bug */
-    if(prevbottom < prevsize.y)
-      prevbottom = prevsize.y;
+    var prevheight = parent.clientHeight;
+
+    /*
+     * fixes an IE bug: the scrollheight is less than the actual height
+     * when the div isn't full
+     */
+    if(prevbottom < prevheight)
+      prevbottom = prevheight;
       
-    return prev.y + prevsize.y == prevbottom;
+    return prev.y + prevheight == prevbottom;
   },
   getScrollParent: function() {
     var scrollparent = this.lines;
@@ -179,6 +184,8 @@ qwebirc.ui.Window = new Class({
     if($defined(element)) {
       var sd = this.scrolledDown();
       parent.appendChild(element);
+      if(parent.childNodes.length > qwebirc.ui.MAXIMUM_LINES_PER_WINDOW)
+        parent.removeChild(parent.firstChild);
       if(sd) {
         if(this.scrolltimer)
           $clear(this.scrolltimer);
@@ -233,7 +240,11 @@ qwebirc.ui.Window = new Class({
       if(!this.lastPositionLineInserted) {
         this.scrollAdd(this.lastPositionLine);
       } else if(this.lines.lastChild != this.lastPositionLine) {
-        this.lines.removeChild(this.lastPositionLine);
+        try {
+          this.lines.removeChild(this.lastPositionLine);
+        } catch(e) {
+          /* IGNORE, /clear removes lastPositionLine from the dom without resetting it. */
+        }
         this.scrollAdd(this.lastPositionLine);
       }
     } else {