]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Readd scrolling.
authorChris Porter <redacted>
Thu, 19 Jun 2008 01:12:41 +0000 (02:12 +0100)
committerChris Porter <redacted>
Thu, 19 Jun 2008 01:12:41 +0000 (02:12 +0100)
TCPConnection now IRCConnection and is built using Mootools.
Fix for IE.

static/js/irc/baseirc.js
static/js/irc/commandparser.js
static/js/irc/ircclient.js
static/js/tcp.js
static/js/ui/uglyui.js
static/js/ui/uibase.js

index 12139042187b1d5cd6b922cad440f7694f47bf97..337cb1709d7bc1c98faa6b663f634f10659fbb41 100644 (file)
@@ -324,8 +324,9 @@ function BaseIRCClient(nickname, view) {
     return true;\r
   }\r
   \r
-  this.connection = new TCPConnection(nickname, this);\r
-  this.send = this.connection.send;\r
-  this.connect = this.connection.connect;\r
+  this.connection = new IRCConnection({initialNickname: nickname, onRecv: this.dispatch});\r
+  \r
+  this.send = this.connection.send.bind(this.connection);\r
+  this.connect = this.connection.connect.bind(this.connection);\r
   this.disconnect = this.connection.disconnect;\r
 }\r
index 6095d5a62b6ca23ecb39657dc18337c8385df036..011e77e061d3ac4107a56394d4f6bfe7ece0b0e0 100644 (file)
@@ -87,7 +87,7 @@ function CommandParser(parent) {
         message = "";\r
       \r
       send("KICK " + channel + " " + target + " :" + message);\r
-    }],\r
+    }]\r
   };\r
 \r
   this.dispatch = function(line) {\r
index 16e2b727d9bbfeb20fd969380a2429ad5241561a..a88003fb7a47fcbe65dd7f6f0b3bbc146658c626 100644 (file)
@@ -390,7 +390,7 @@ function IRCClient(nickname, ui, autojoin) {
   this.__send = this.parent.send;\r
   \r
   this.commandparser = new CommandParser(this);\r
-  this.dispatch = this.commandparser.dispatch\r
+  this.dispatch = this.commandparser.dispatch;\r
 \r
   this.statusWindow = ui.newClient(self);\r
 \r
index f6054901fbf6f1fefd331226153737a643bfc090..9b7d8f2d2e471b2badcbb27f6a3760e34be6a1a9 100644 (file)
@@ -1,44 +1,57 @@
-function TCPConnection(nickname, parser) {\r
-  var self = this;\r
-  var dispatch = parser.dispatch;\r
-  var counter = 0;\r
-  var disconnected = false;\r
-  \r
-  this.send = function(data) {\r
-    XHR("/e/p/" + self.sessionid + "?c=" + encodeURIComponent(data) + "&t=" + counter++, function(o) {\r
+var IRCConnection = new Class({\r
+  Implements: [Events, Options],\r
+  options: {\r
+    initialNickname: "ircconnX"\r
+  },\r
+  initialize: function(options) {\r
+    this.setOptions(options);\r
+    \r
+    this.initialNickname = this.options.initialNickname;\r
+    \r
+    this.counter = 0;\r
+    this.disconnected = false;\r
+  },\r
+  send: function(data) {\r
+    var r = new Request.JSON({url: "/e/p/" + this.sessionid + "?c=" + encodeURIComponent(data) + "&t=" + this.counter++, onComplete: function(o) {\r
       if(o[0] == false)\r
         alert("An error occured: " + o[1]);\r
-    });\r
-  }\r
-\r
-  this.recv = function() {\r
-    if(self.disconnected)\r
+    }});\r
+    \r
+    r.get();\r
+  },\r
+  x: function() {\r
+    this.fireEvent("recv", [[false, "moo"]]);\r
+  },\r
+  recv: function() {\r
+    if(this.disconnected)\r
       return;\r
       \r
-    XHR("/e/s/" + self.sessionid + "?t=" + counter++, function(o) {\r
+    var r = new Request.JSON({url: "/e/s/" + this.sessionid + "?t=" + this.counter++, onComplete: function(o) {\r
       if(o[0] == false) {\r
         alert("An error occured: " + o[1]);\r
         return;\r
       }\r
-      forEach(o, function(x) {\r
-        dispatch(x);\r
-      });\r
-      self.recv();\r
-    });\r
-  }\r
-\r
-  this.connect = function() {\r
-    XHR("/e/n?nick=" + encodeURIComponent(nickname) + "&r=" + Math.random() * 1024 * 1024, function(o) {\r
+      o.each(function(x) {\r
+        this.fireEvent("recv", [x]);\r
+      }, this);\r
+      \r
+      this.recv();\r
+    }.bind(this)});    \r
+    r.get();\r
+  },\r
+  connect: function() {\r
+    var r = new Request.JSON({url: "/e/n?nick=" + encodeURIComponent(this.initialNickname) + "&r=" + Math.random() * 1024 * 1024, onComplete: function(o) {\r
       if(o[0] == false) {\r
         alert("An error occured: " + o[1]);\r
         return;\r
       }\r
-      self.sessionid = o[1];\r
-      self.recv();    \r
-    });\r
-  }\r
-  \r
-  this.disconnect = function() {\r
-    self.disconnected = true;\r
+      this.sessionid = o[1];\r
+      \r
+      this.recv();    \r
+    }.bind(this)});\r
+    r.get();\r
+  },\r
+  disconnect: function() {\r
+    this.disconnected = true;\r
   }\r
-}
\ No newline at end of file
+});\r
index 76274bd03344895e303abe4e25d383d6f7105809..c385f3058d1f23d392419d61097f9f84d9b27420 100644 (file)
@@ -104,9 +104,19 @@ var UglyUIWindow = new Class({
       line = this.parentObject.theme.message(type, line);\r
     \r
     colourise(timestamp() + " " + line, e);\r
-    this.lines.appendChild(e);\r
     \r
     this.lastcolour = !this.lastcolour;\r
+    \r
+    var prev = this.lines.getScroll();\r
+    var prevbottom = this.lines.getScrollSize().y;\r
+    var prevsize = this.lines.getSize();\r
+    this.lines.appendChild(e);\r
+    \r
+    if(prev.y + prevsize.y == prevbottom)\r
+      this.lines.scrollTo(prev.x, this.lines.getScrollSize().y);\r
+      \r
+    if(!this.active)\r
+      this.tab.setStyle("color", "red");\r
   }\r
 });\r
 \r
@@ -136,5 +146,5 @@ var UglyUI = new Class({
     parentElement.appendChild(form);  \r
     form.appendChild(inputbox);\r
     inputbox.focus();\r
-  },\r
+  }\r
 });
\ No newline at end of file
index 760f6886647133e11cb654fdc2da685511476eab..7c08eaf49ab639ef4c9d1f6d7193ab579df1ef9d 100644 (file)
@@ -3,6 +3,7 @@ WINDOW_QUERY = 2;
 WINDOW_CHANNEL = 3;\r
 \r
 var UIWindow = new Class({\r
+  Implements: [Events],\r
   initialize: function(parentObject, client, type, name, identifier) {\r
     this.parentObject = parentObject;\r
     this.type = type;\r
@@ -32,7 +33,6 @@ var UIWindow = new Class({
     this.addLine("", message, "red");\r
   }\r
 });\r
-UIWindow.implement(new Events);\r
 \r
 var UI = new Class({\r
   initialize: function(windowClass) {\r
@@ -52,7 +52,7 @@ var UI = new Class({
     if(type == WINDOW_STATUS)\r
       identifier = "";\r
       \r
-    w = this.windows[client][identifier] = new this.windowClass(this, client, type, name, identifier);\r
+    var w = this.windows[client][identifier] = new this.windowClass(this, client, type, name, identifier);\r
     this.windowArray.push(w);\r
     \r
     return w;\r
@@ -71,19 +71,17 @@ var UI = new Class({
   __closed: function(window) {\r
     if(window.active) {\r
       this.active = undefined;\r
-      if(this.windowArray.length > 1) {\r
-        for(var i=0;i<this.windowArray.length;i++) {\r
-          if(this.windowArray[i] != window)\r
-            continue;\r
-\r
-          if(i == 0) {\r
-            this.selectWindow(this.windowArray[1]);\r
-          } else {\r
-            this.selectWindow(this.windowArray[i - 1]);\r
-          }\r
-          this.windowArray = this.windowArray.splice(i, 1);\r
-          break;\r
+      if(this.windowArray.length == 1) {\r
+        this.windowArray = [];\r
+      } else {\r
+        var index = this.windowArray.indexOf(window);\r
+        if(i == 0) {\r
+          this.selectWindow(this.windowArray[1]);\r
+        } else {\r
+          this.selectWindow(this.windowArray[index - 1]);\r
         }\r
+        \r
+        this.windowArray = this.windowArray.erase(window);\r
       }\r
     }\r
     \r