]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add nice whoises.
authorChris Porter <redacted>
Sat, 18 Oct 2008 22:38:09 +0000 (23:38 +0100)
committerChris Porter <redacted>
Sat, 18 Oct 2008 22:38:09 +0000 (23:38 +0100)
Seperate out numerics.
Fix double spaces.
Fix setAtEnd.
Refactor some target or active new line messages.
Add away messages.

13 files changed:
compile.bat
compile.sh
js/irc/baseircclient.js
js/irc/ircclient.js
js/irc/numerics.js [new file with mode: 0644]
js/jslib.js
js/ui/qui.js
js/ui/theme.js
js/ui/url.js
static/mochauidebug.html
static/quidebug.html
static/swmuidebug.html
static/uglyuidebug.html

index d65c991559c62fd752a85eac5ab7d760aa52fad1..93e2fdbd35c64f3404cdecf3306b75850e14a902 100644 (file)
@@ -3,7 +3,7 @@ mkdir compiled
 del /q compiled\*.js\r
 \r
 cd js\r
-copy qwebirc.js + version.js + jslib.js + irc\ircconnection.js + irc\irclib.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + ui\genericlogin.js + ui\embedwizard.js + qwebircinterface.js + irc\commandhistory.js ..\compiled\qwebirc-concat.js /b\r
+copy qwebirc.js + version.js + jslib.js + irc\ircconnection.js + irc\irclib.js + irc\numerics.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + ui\genericlogin.js + ui\embedwizard.js + qwebircinterface.js + irc\commandhistory.js ..\compiled\qwebirc-concat.js /b\r
 copy ui\swmui.js + ui\swmlayout.js ..\compiled\swmui-concat.js /b\r
 cd ..\compiled\r
 \r
index bfa232ccf4377952873fa54a4c5464c59be3e98b..baa6de93a93e8b4398df80584ce89a2d40401708 100755 (executable)
@@ -3,7 +3,7 @@ mkdir -p compiled
 rm -f compiled/*.js
 
 cd js
-cat qwebirc.js version.js jslib.js irc/ircconnection.js irc/irclib.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js ui/genericlogin.js ui/embedwizard.js irc/commandhistory.js qwebircinterface.js > ../compiled/qwebirc-concat.js
+cat qwebirc.js version.js jslib.js irc/ircconnection.js irc/irclib.js irc/numerics.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js ui/genericlogin.js ui/embedwizard.js irc/commandhistory.js qwebircinterface.js > ../compiled/qwebirc-concat.js
 cat ui/swmui.js ui/swmlayout.js > ../compiled/swmui-concat.js
 
 error() {
index f8b0e072a726dd3944cd9a143ee3bd226b5896a8..720770faaae0b96b3cc9fffa9f4bf7cac876b0da 100644 (file)
@@ -1,5 +1,3 @@
-qwebirc.irc.Numerics = {"001": "RPL_WELCOME", "433": "ERR_NICKNAMEINUSE", "004": "RPL_MYINFO", "005": "RPL_ISUPPORT", "353": "RPL_NAMREPLY", "366": "RPL_ENDOFNAMES", "331": "RPL_NOTOPIC", "332": "RPL_TOPIC", "333": "RPL_TOPICWHOTIME"};
-
 qwebirc.irc.RegisteredCTCPs = {
   "VERSION": function(x) {
     return "qwebirc v" + qwebirc.VERSION + ", copyright (C) Chris Porter 2008 -- user agent: " + Browser.Engine.name + " (" + Browser.Platform.name + ")";
@@ -320,5 +318,67 @@ qwebirc.irc.BaseIRCClient = new Class({
   },  
   irc_RPL_TOPICWHOTIME: function(prefix, params) {
     return true;
+  },
+  irc_RPL_WHOISUSER: function(prefix, params) {
+    var nick = params[1];
+    this.whoisNick = nick;
+
+    return this.whois(nick, "user", {ident: params[2], hostname: params[3], realname: params.indexFromEnd(-1)});
+  },  
+  irc_RPL_WHOISSERVER: function(prefix, params) {
+    var nick = params[1];
+    var server = params[2];
+    var serverdesc = params.indexFromEnd(-1);
+
+    return this.whois(nick, "server", {server: params[2], serverdesc: params.indexFromEnd(-1)});
+  },  
+  irc_RPL_WHOISOPERATOR: function(prefix, params) {
+    var nick = params[1];
+    var text = params.indexFromEnd(-1);
+
+    return this.whois(nick, "oper", {opertext: params.indexFromEnd(-1)});
+  },  
+  irc_RPL_WHOISIDLE: function(prefix, params) {
+    var nick = params[1];
+
+    return this.whois(nick, "idle", {idle: params[2], connected: params[3]});
+  },  
+  irc_RPL_WHOISCHANNELS: function(prefix, params) {
+    var nick = params[1];
+
+    return this.whois(nick, "channels", {channels: params.indexFromEnd(-1)});
+  },  
+  irc_RPL_WHOISACCOUNT: function(prefix, params) {
+    var nick = params[1];
+
+    return this.whois(nick, "account", {account: params[2]});
+  },  
+  irc_RPL_WHOISACTUALLY: function(prefix, params) {
+    var nick = params[1];
+
+    return this.whois(nick, "actually", {hostmask: params[2], ip: params[3]});
+  },  
+  irc_RPL_WHOISOPERNAME: function(prefix, params) {
+    var nick = params[1];
+    var opername = params[2];
+
+    return this.whois(nick, "opername", {opername: params[2]});
+  },  
+  irc_RPL_ENDOFWHOIS: function(prefix, params) {
+    var nick = params[1];
+    var text = params.indexFromEnd(-1);
+    this.whoisNick = null;
+    
+    return this.whois(nick, "end", {});
+  },
+  irc_RPL_AWAY: function(prefix, params) {
+    var nick = params[1];
+    var text = params.indexFromEnd(-1);
+
+    if(this.whoisNick && (this.whoisNick == nick))
+      return this.whois(nick, "away", {"away": text});
+      
+    this.awayMessage(nick, text);
+    return true;
   }
 });
index 1d14327f45e7200dd5b1c733e42d4e43bb4a3cbc..61bc92f60fa5c9b7c6c063ad377b64bb5eccdd57 100644 (file)
@@ -46,6 +46,13 @@ qwebirc.irc.IRCClient = new Class({
   newActiveLine: function(type, data) {
     this.ui.getActiveWindow().addLine(type, data);
   },
+  newTargetOrActiveLine: function(target, type, data) {
+    if(this.getWindow(target)) {
+      this.newLine(target, type, data);
+    } else {
+      this.newActiveLine(type, data);
+    }
+  },
   updateNickList: function(channel) {
     var n1 = this.tracker.getChannel(channel);
     var names = new Array();
@@ -267,11 +274,7 @@ qwebirc.irc.IRCClient = new Class({
       return;
     }
     
-    if(this.getWindow(nick)) {
-      this.newLine(nick, "PRIVCTCP", {"m": args, "x": type, "h": host, "n": nick, "-": this.nickname});
-    } else {
-      this.newActiveLine("PRIVCTCP", {"m": args, "x": type, "h": host, "n": nick, "-": this.nickname});
-    }
+    this.newTargetOrActiveLine(nick, "PRIVCTCP", {"m": args, "x": type, "h": host, "n": nick, "-": this.nickname});
   },
   userCTCPReply: function(user, type, args) {
     var nick = user.hostToNick();
@@ -279,11 +282,7 @@ qwebirc.irc.IRCClient = new Class({
     if(args == undefined)
       args = "";
     
-    if(this.getWindow(nick)) {
-      this.newLine(nick, "CTCPREPLY", {"m": args, "x": type, "h": host, "n": nick, "-": this.nickname});
-    } else {
-      this.newActiveLine("CTCPREPLY", {"m": args, "x": type, "h": host, "n": nick, "-": this.nickname});
-    }
+    this.newTargetOrActiveLine(nick, "CTCPREPLY", {"m": args, "x": type, "h": host, "n": nick, "-": this.nickname});
   },
   channelPrivmsg: function(user, channel, message) {
     this.newChanLine(channel, "CHANMSG", user, {"m": message});
@@ -306,11 +305,7 @@ qwebirc.irc.IRCClient = new Class({
     var nick = user.hostToNick();
     var host = user.hostToHost();
 
-    if(this.getWindow(nick)) {
-      this.newLine(nick, "PRIVNOTICE", {"m": message, "h": host, "n": nick});
-    } else {
-      this.newActiveLine("PRIVNOTICE", {"m": message, "h": host, "n": nick});
-    }
+    this.newTargetOrActiveLine(nick, "PRIVNOTICE", {"m": message, "h": host, "n": nick});
   },
   userInvite: function(user, channel) {
     var nick = user.hostToNick();
@@ -374,5 +369,57 @@ qwebirc.irc.IRCClient = new Class({
   quit: function(message) {
     this.send("QUIT :" + message);
     this.disconnect();
+  },
+  awayMessage: function(nick, message) {
+    this.newLine(nick, "AWAY", {"n": nick, "m": message});
+  },
+  whois: function(nick, type, data) {
+    var ndata = {"n": nick};
+    var mtype;
+    
+    var xsend = function() {
+      this.newTargetOrActiveLine(nick, "WHOIS" + mtype, ndata);
+    }.bind(this);
+    
+    if(type == "user") {
+      mtype = "USER";
+      ndata.h = data.ident + "@" + data.hostname;
+      xsend();
+      mtype = "REALNAME";
+      ndata.m = data.realname;
+    } else if(type == "server") {
+      mtype = "SERVER";
+      ndata.x = data.server;
+      ndata.m = data.serverdesc;
+    } else if(type == "oper") {
+      mtype = "OPER";
+    } else if(type == "idle") {
+      mtype = "IDLE";
+      ndata.x = qwebirc.util.longtoduration(data.idle);
+      ndata.m = qwebirc.irc.IRCDate(new Date(data.connected * 1000));
+    } else if(type == "channels") {
+      mtype = "CHANNELS";
+      ndata.m = data.channels;
+    } else if(type == "account") {
+      mtype = "ACCOUNT";
+      ndata.m = data.account;
+    } else if(type == "away") {
+      mtype = "AWAY";
+      ndata.m = data.away;
+    } else if(type == "opername") {
+      mtype = "OPERNAME";
+      ndata.m = data.opername;
+    } else if(type == "actually") {
+      mtype = "ACTUALLY";
+      ndata.m = data.hostname;
+      ndata.x = data.ip;
+    } else if(type == "end") {
+      mtype = "END";
+    } else {
+      return false;
+    }
+    
+    xsend();
+    return true;
   }
 });
diff --git a/js/irc/numerics.js b/js/irc/numerics.js
new file mode 100644 (file)
index 0000000..a283e3a
--- /dev/null
@@ -0,0 +1,21 @@
+qwebirc.irc.Numerics = {
+  "001": "RPL_WELCOME",
+  "433": "ERR_NICKNAMEINUSE",
+  "004": "RPL_MYINFO",
+  "005": "RPL_ISUPPORT",
+  "353": "RPL_NAMREPLY",
+  "366": "RPL_ENDOFNAMES",
+  "331": "RPL_NOTOPIC",
+  "332": "RPL_TOPIC",
+  "333": "RPL_TOPICWHOTIME",
+  "311": "RPL_WHOISUSER",
+  "312": "RPL_WHOISSERVER",
+  "313": "RPL_WHOISOPERATOR",
+  "317": "RPL_WHOISIDLE",
+  "318": "RPL_ENDOFWHOIS",
+  "319": "RPL_WHOISCHANNELS",
+  "330": "RPL_WHOISACCOUNT",
+  "338": "RPL_WHOISACTUALLY",
+  "343": "RPL_WHOISOPERNAME",
+  "301": "RPL_AWAY"
+};
index b50c39667bf0e841803df71d8b4b13e1af30eeea..72ce15cfb317842b11c5f4de6634f0276d2e6a15 100644 (file)
@@ -90,3 +90,26 @@ qwebirc.util.MonthsOfYear = {
   10: "Nov",
   11: "Dec"
 };
+
+qwebirc.util.NBSPCreate = function(text, element) {
+  var e = text.split("  ");
+  for(var i=0;i<e.length;i++) {
+    var tn = document.createTextNode(e[i]);
+    element.appendChild(tn);
+    
+    if(i != e.length - 1) {
+      var e2 = new Element("span");
+      e2.set("html", "&nbsp;&nbsp;");
+      element.appendChild(e2);
+    }
+  }
+};
+
+qwebirc.util.longtoduration = function(l) {
+  var seconds = l % 60;
+  var minutes = l / 60;
+  var hours = minutes / 60;
+  var days = hours / 24;
+  
+  return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds";
+}
index ef224d541a88d715c974551a0696d1676ade70d8..de0cbc278092e8056c2c5fef315a6cedb19b1096 100644 (file)
@@ -68,7 +68,7 @@ qwebirc.ui.QUI = new Class({
       this.lastcvalue = result;
         
       inputbox.value = result;
-      setAtEnd(inputbox);
+      qwebirc.util.setAtEnd(inputbox);
     }.bind(this));
   },
   setLines: function(lines) {
index edafc4e1fa41a0c1cc3e5a6bf4ed37c37a02ad31..c11786b10b7aa058441366a9c69bc08747a4f948 100644 (file)
@@ -43,7 +43,19 @@ qwebirc.ui.themes.Default = {
   "CTCPREPLY": ["CTCP $x reply from $n: $m"],
   "OURCHANCTCP": ["[ctcp($t)] $x $m"],
   "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
-  "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"]
+  "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
+  "WHOISUSER": ["$B$n$B [$h]", true],
+  "WHOISREALNAME": [" realname : $m", true],
+  "WHOISCHANNELS": [" channels : $m", true],
+  "WHOISSERVER": [" server   : $x [$m]", true],
+  "WHOISACCOUNT": [" account  : $m", true],
+  "WHOISIDLE": [" idle     : $x [connected: $m]", true],
+  "WHOISAWAY": [" away     : $m", true],
+  "WHOISOPER": ["          : $BIRC Operator$B", true],
+  "WHOISOPERNAME": [" operedas : $m", true],
+  "WHOISACTUALLY": [" realhost : $m [ip: $x]", true],
+  "WHOISEND": ["End of WHOIS", true],
+  "AWAY": ["$n is away: $m", true]
 };
 
 qwebirc.ui.Theme = new Class({
index 5ff4c021c1efcbc4dffc01d05fae7c6b8e4ea92d..f4cf2a640cf4865222f7ccf3c791ff4890107112 100644 (file)
@@ -23,7 +23,7 @@ qwebirc.ui.urlificate = function(element, text, execfn, cmdfn) {
   };
   
   var appendText = function(text) {
-    element.appendChild(document.createTextNode(text));  
+    qwebirc.util.NBSPCreate(text, element);
   };
   
   var appendChan = function(text) {
index acc21a0cd397a35469b894dcfdaaf4773a02b0cb..bd3ec686fce4b1f5f107c513ad8a9224291ba977 100644 (file)
@@ -17,6 +17,7 @@
   <script type="text/javascript" src="js/debug/jslib.js"></script>
   <script type="text/javascript" src="js/debug/irc/ircconnection.js"></script>
   <script type="text/javascript" src="js/debug/irc/irclib.js"></script>
+  <script type="text/javascript" src="js/debug/irc/numerics.js"></script>
   <script type="text/javascript" src="js/debug/irc/baseircclient.js"></script>
   <script type="text/javascript" src="js/debug/irc/irctracker.js"></script>
   <script type="text/javascript" src="js/debug/irc/commandparser.js"></script>
index 517495aafeb9b1c76d42d7d42d32d576853ae3aa..558f51bccc902067123ca9034880daed92a45821 100644 (file)
@@ -11,6 +11,7 @@
   <script type="text/javascript" src="js/debug/jslib.js"></script>
   <script type="text/javascript" src="js/debug/irc/ircconnection.js"></script>
   <script type="text/javascript" src="js/debug/irc/irclib.js"></script>
+  <script type="text/javascript" src="js/debug/irc/numerics.js"></script>
   <script type="text/javascript" src="js/debug/irc/baseircclient.js"></script>
   <script type="text/javascript" src="js/debug/irc/irctracker.js"></script>
   <script type="text/javascript" src="js/debug/irc/commandparser.js"></script>
index 52a501e1cdfda76e003db2ff82e450020344b339..8cbccd4de3dbcd4f57097396c997593f1e0cf9e4 100644 (file)
@@ -10,6 +10,7 @@
   <script type="text/javascript" src="js/debug/jslib.js"></script>
   <script type="text/javascript" src="js/debug/irc/ircconnection.js"></script>
   <script type="text/javascript" src="js/debug/irc/irclib.js"></script>
+  <script type="text/javascript" src="js/debug/irc/numerics.js"></script>
   <script type="text/javascript" src="js/debug/irc/baseircclient.js"></script>
   <script type="text/javascript" src="js/debug/irc/irctracker.js"></script>
   <script type="text/javascript" src="js/debug/irc/commandparser.js"></script>
index 0641ee717c28b00cebf5aedfc4a722287d9ab67c..943ead9b3226c6d1d291d9247ff17ac371cc2c16 100644 (file)
@@ -10,6 +10,7 @@
   <script type="text/javascript" src="js/debug/jslib.js"></script>
   <script type="text/javascript" src="js/debug/irc/ircconnection.js"></script>
   <script type="text/javascript" src="js/debug/irc/irclib.js"></script>
+  <script type="text/javascript" src="js/debug/irc/numerics.js"></script>
   <script type="text/javascript" src="js/debug/irc/baseircclient.js"></script>
   <script type="text/javascript" src="js/debug/irc/irctracker.js"></script>
   <script type="text/javascript" src="js/debug/irc/commandparser.js"></script>