From: Chris Porter Date: Sat, 18 Oct 2008 22:38:09 +0000 (+0100) Subject: Add nice whoises. X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/1d6756bcad0a8b762d43c1262e869d7704dfe279 Add nice whoises. Seperate out numerics. Fix double spaces. Fix setAtEnd. Refactor some target or active new line messages. Add away messages. --- diff --git a/compile.bat b/compile.bat index d65c991..93e2fdb 100644 --- a/compile.bat +++ b/compile.bat @@ -3,7 +3,7 @@ mkdir compiled del /q compiled\*.js cd js -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 +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 copy ui\swmui.js + ui\swmlayout.js ..\compiled\swmui-concat.js /b cd ..\compiled diff --git a/compile.sh b/compile.sh index bfa232c..baa6de9 100755 --- a/compile.sh +++ b/compile.sh @@ -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() { diff --git a/js/irc/baseircclient.js b/js/irc/baseircclient.js index f8b0e07..720770f 100644 --- a/js/irc/baseircclient.js +++ b/js/irc/baseircclient.js @@ -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; } }); diff --git a/js/irc/ircclient.js b/js/irc/ircclient.js index 1d14327..61bc92f 100644 --- a/js/irc/ircclient.js +++ b/js/irc/ircclient.js @@ -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 index 0000000..a283e3a --- /dev/null +++ b/js/irc/numerics.js @@ -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" +}; diff --git a/js/jslib.js b/js/jslib.js index b50c396..72ce15c 100644 --- a/js/jslib.js +++ b/js/jslib.js @@ -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 + diff --git a/static/quidebug.html b/static/quidebug.html index 517495a..558f51b 100644 --- a/static/quidebug.html +++ b/static/quidebug.html @@ -11,6 +11,7 @@ + diff --git a/static/swmuidebug.html b/static/swmuidebug.html index 52a501e..8cbccd4 100644 --- a/static/swmuidebug.html +++ b/static/swmuidebug.html @@ -10,6 +10,7 @@ + diff --git a/static/uglyuidebug.html b/static/uglyuidebug.html index 0641ee7..943ead9 100644 --- a/static/uglyuidebug.html +++ b/static/uglyuidebug.html @@ -10,6 +10,7 @@ +