From: Chris Porter Date: Sat, 25 Oct 2008 21:44:27 +0000 (+0100) Subject: Fix version in ctcp. X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/3c3ddb143ab908af85456d1cfcc675256d302bbd Fix version in ctcp. Fix a few typos. Add getCaretPos and setAt. Use run instead of attempt in CommandParser. --- diff --git a/TODO.txt b/TODO.txt index ca33b37..b272675 100644 --- a/TODO.txt +++ b/TODO.txt @@ -9,3 +9,4 @@ nick only/chan only scroll pos isn't saved when you go between tabs if not at bottom. fix embedding wizard in IE undo closed tab +memory leaks diff --git a/js/irc/baseircclient.js b/js/irc/baseircclient.js index c329ec8..8a2e7c5 100644 --- a/js/irc/baseircclient.js +++ b/js/irc/baseircclient.js @@ -1,6 +1,6 @@ qwebirc.irc.RegisteredCTCPs = { "VERSION": function(x) { - return "qwebirc v" + qwebirc.VERSION + ", copyright (C) Chris Porter 2008 -- user agent: " + Browser.Engine.name + " (" + Browser.Platform.name + ")"; + return "qwebirc v" + qwebirc.VERSION + ", copyright (C) Chris Porter 2008 -- " + qwebirc.util.browserVersion(); }, "USERINFO": function(x) { return "qwebirc"; }, "TIME": function(x) { return qwebirc.irc.IRCTime(new Date()); }, @@ -65,7 +65,7 @@ qwebirc.irc.BaseIRCClient = new Class({ } }, isChannel: function(target) { - var c = target.chatAt(0); + var c = target.charAt(0); return c == '#'; }, irc_RPL_WELCOME: function(prefix, params) { diff --git a/js/irc/commandparser.js b/js/irc/commandparser.js index 65ec882..3afd35f 100644 --- a/js/irc/commandparser.js +++ b/js/irc/commandparser.js @@ -84,7 +84,7 @@ qwebirc.irc.CommandParser = new Class({ return; } - var ret = fn.attempt([args], this); + var ret = fn.run([args], this); if(ret == undefined) return; @@ -125,7 +125,7 @@ qwebirc.irc.CommandParser = new Class({ var target = args[0]; var message = args[1]; - if(this.parentObject.isChannel(target)) + if(!this.parentObject.isChannel(target)) this.parentObject.pushLastNick(target); if(this.send("PRIVMSG " + target + " :" + message)) this.newTargetLine(target, "MSG", message, {}); diff --git a/js/jslib.js b/js/jslib.js index 63281a3..7e75d03 100644 --- a/js/jslib.js +++ b/js/jslib.js @@ -38,19 +38,6 @@ String.prototype.splitMax = function(by, max) { return newitems; } -qwebirc.util.setAtEnd = function(obj) { - pos = obj.value.length; - - if(obj.createTextRange) { - var range = obj.createTextRange(); - range.move("character", pos); - range.select(); - } else if(obj.selectionStart) { - obj.focus(); - obj.setSelectionRange(pos, pos); - } -} - /* returns the arguments */ qwebirc.util.parseURI = function(uri) { var result = {} @@ -147,4 +134,36 @@ qwebirc.ui.insertAt = function(position, parent, element) { } else { parent.insertBefore(element, parent.childNodes[position]); } -} \ No newline at end of file +} + +qwebirc.util.setAt = function(obj, pos) { + if($defined(obj.selectionStart)) { + obj.focus(); + obj.setSelectionRange(pos, pos); + } else if(obj.createTextRange) { + var range = obj.createTextRange(); + range.move("character", pos); + range.select(); + } +} + +qwebirc.util.setAtEnd = function(obj) { + qwebirc.util.setAt(obj.value.length); +} + +qwebirc.util.getCaretPos = function(element) { + if($defined(element.selectionStart)) + return element.selectionStart; + + if(document.selection) { + element.focus(); + var sel = document.selection.createRange(); + sel.moveStart("character", -element.value.length); + return sel.text.length; + } +} + +qwebirc.util.browserVersion = function() { + //return "engine: " + Browser.Engine.name + " platform: " + Browser.Platform.name + " user agent: " + navigator.userAgent; + return navigator.userAgent; +}