From: Chris Porter Date: Sat, 18 Oct 2008 20:39:49 +0000 (+0100) Subject: Try not to corrupt the namespaces. X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/e20e5a6b73d37ddd1a4c6ded2dcc336e3299fecf Try not to corrupt the namespaces. --- diff --git a/TODO.txt b/TODO.txt index 20a214c..06231d4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,2 @@ -IE7 -IE6 -ping timeout bug? -opera weirdness +make pretty again. +swmui window bug diff --git a/compile.bat b/compile.bat index dae4e55..710a63d 100644 --- a/compile.bat +++ b/compile.bat @@ -3,8 +3,8 @@ mkdir compiled del /q compiled\*.js cd js -copy 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 ui\swmlayout.js + ui\swmui.js ..\compiled\swmui-concat.js /b +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 ui\swmui.js + ui\swmlayout.js ..\compiled\swmui-concat.js /b cd ..\compiled java -jar ..\bin\yuicompressor-2.3.5.jar ..\static\js\mochaui\mocha.js > mocha-compressed.js diff --git a/compile.sh b/compile.sh index da65e74..bfa232c 100755 --- a/compile.sh +++ b/compile.sh @@ -3,8 +3,8 @@ mkdir -p compiled rm -f compiled/*.js cd js -cat 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 ui/swmlayout.js ui/swmui.js > ../compiled/swmui-concat.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 ui/swmui.js ui/swmlayout.js > ../compiled/swmui-concat.js error() { cd .. diff --git a/js/irc/baseircclient.js b/js/irc/baseircclient.js index 69393d4..165edd9 100644 --- a/js/irc/baseircclient.js +++ b/js/irc/baseircclient.js @@ -1,19 +1,19 @@ -var 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.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"}; -var RegisteredCTCPs = { +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 -- user agent: " + Browser.Engine.name + " (" + Browser.Platform.name + ")"; }, "USERINFO": function(x) { return "qwebirc"; }, - "TIME": function(x) { return IRCTime(new Date()); }, + "TIME": function(x) { return qwebirc.irc.IRCTime(new Date()); }, "PING": function(x) { return x; }, "CLIENTINFO": function(x) { return "PING VERSION TIME USERINFO CLIENTINFO"; } }; -var BaseIRCClient = new Class({ +qwebirc.irc.BaseIRCClient = new Class({ Implements: [Options], options: { - nickname: "WCunset" + nickname: "qwebirc" }, initialize: function(options) { this.setOptions(options); @@ -25,7 +25,7 @@ var BaseIRCClient = new Class({ this.channels = {} this.nextctcp = 0; - this.connection = new IRCConnection({initialNickname: this.nickname, onRecv: this.dispatch.bind(this)}); + this.connection = new qwebirc.irc.IRCConnection({initialNickname: this.nickname, onRecv: this.dispatch.bind(this)}); this.send = this.connection.send.bind(this.connection); this.connect = this.connection.connect.bind(this.connection); @@ -47,7 +47,7 @@ var BaseIRCClient = new Class({ var prefix = data[2]; var sl = data[3]; - var n = Numerics[command]; + var n = qwebirc.irc.Numerics[command]; var x = n; if(!n) @@ -176,7 +176,7 @@ var BaseIRCClient = new Class({ if(ctcp) { var type = ctcp[0].toUpperCase(); - var replyfn = RegisteredCTCPs[type]; + var replyfn = qwebirc.irc.RegisteredCTCPs[type]; if(replyfn) { var t = new Date().getTime() / 1000; if(t > this.nextctcp) diff --git a/js/irc/commandhistory.js b/js/irc/commandhistory.js index 175ac19..dae85d5 100644 --- a/js/irc/commandhistory.js +++ b/js/irc/commandhistory.js @@ -1,4 +1,4 @@ -var CommandHistory = new Class({ +qwebirc.irc.CommandHistory = new Class({ Implements: [Options], options: { lines: 20 diff --git a/js/irc/commandparser.js b/js/irc/commandparser.js index 46b68ee..45cca49 100644 --- a/js/irc/commandparser.js +++ b/js/irc/commandparser.js @@ -1,4 +1,4 @@ -var CommandParser = new Class({ +qwebirc.irc.CommandParser = new Class({ initialize: function(parentObject) { this.aliases = { "J": "JOIN", diff --git a/js/irc/ircclient.js b/js/irc/ircclient.js index e0e78b2..2d3f0b8 100644 --- a/js/irc/ircclient.js +++ b/js/irc/ircclient.js @@ -1,7 +1,7 @@ -var IRCClient = new Class({ - Extends: BaseIRCClient, +qwebirc.irc.IRCClient = new Class({ + Extends: qwebirc.irc.BaseIRCClient, options: { - nickname: "WCunset", + nickname: "qwebirc", autojoin: "" }, initialize: function(options, ui) { @@ -13,7 +13,7 @@ var IRCClient = new Class({ this.modeprefixes = "ov"; this.windows = {}; - this.commandparser = new CommandParser(this); + this.commandparser = new qwebirc.irc.CommandParser(this); this.exec = this.commandparser.dispatch.bind(this.commandparser); this.statusWindow = this.ui.newClient(this); @@ -126,7 +126,7 @@ var IRCClient = new Class({ this.newServerLine("RAW", {"n": "numeric", "m": params.slice(1).join(" ")}); }, signedOn: function(nickname) { - this.tracker = new IRCTracker(); + this.tracker = new qwebirc.irc.IRCTracker(); this.nickname = nickname; this.newServerLine("SIGNON"); diff --git a/js/irc/ircconnection.js b/js/irc/ircconnection.js index 619251b..d763203 100644 --- a/js/irc/ircconnection.js +++ b/js/irc/ircconnection.js @@ -1,6 +1,6 @@ /* This could do with a rewrite from scratch. */ -var IRCConnection = new Class({ +qwebirc.irc.IRCConnection = new Class({ Implements: [Events, Options], options: { initialNickname: "ircconnX", diff --git a/js/irc/irclib.js b/js/irc/irclib.js index 8e53c38..a83850a 100644 --- a/js/irc/irclib.js +++ b/js/irc/irclib.js @@ -1,4 +1,4 @@ -var IRCLowerTable = [ +qwebirc.irc.IRCLowerTable = [ /* x00-x07 */ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', /* x08-x0f */ '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', /* x10-x17 */ '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', @@ -40,7 +40,7 @@ String.prototype.toIRCLower = function() { for(var i=0;i 0) { - urlificate(element, out.join(""), execfn, cmdfn); + qwebirc.ui.urlificate(element, out.join(""), execfn, cmdfn); entity.appendChild(element); out = []; } @@ -100,4 +100,4 @@ function Colourise(line, entity, execfn, cmdfn) { } emitEndToken(); -} \ No newline at end of file +} diff --git a/js/ui/embedwizard.js b/js/ui/embedwizard.js index 12bbba2..987ec7c 100644 --- a/js/ui/embedwizard.js +++ b/js/ui/embedwizard.js @@ -1,4 +1,4 @@ -var WebmasterGuideStep = new Class({ +qwebirc.ui.EmbedWizardStep = new Class({ Implements: [Options, Events], options: { "title": "", @@ -28,7 +28,7 @@ var WebmasterGuideStep = new Class({ } }); -var WebmasterGuide = new Class({ +qwebirc.ui.EmbedWizard = new Class({ Implements: [Options, Events], options: { parent: null, @@ -85,7 +85,7 @@ var WebmasterGuide = new Class({ return cell; }, newStep: function(options) { - return new WebmasterGuideStep(this, options); + return new qwebirc.ui.EmbedWizardStep(this, options); }, newRadio: function(parent, text, name, selected) { var p = new Element("div"); diff --git a/js/ui/genericlogin.js b/js/ui/genericlogin.js index 18cc06c..1d7fba6 100644 --- a/js/ui/genericlogin.js +++ b/js/ui/genericlogin.js @@ -1,13 +1,12 @@ -function GenericLoginBox(parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick) { +qwebirc.ui.GenericLoginBox = function(parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick) { if(autoConnect) { - ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick); + qwebirc.ui.ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick); } else { - LoginBox(parentElement, callback, initialNickname, initialChannels); + qwebirc.ui.LoginBox(parentElement, callback, initialNickname, initialChannels); } - } -function ConfirmBox(parentElement, callback, initialNickname, initialChannels, autoNick) { +qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initialChannels, autoNick) { var box = new Element("table"); box.addClass("confirmbox"); parentElement.appendChild(box); @@ -67,7 +66,7 @@ function ConfirmBox(parentElement, callback, initialNickname, initialChannels, a }); } -function LoginBox(parentElement, callback, initialNickname, initialChannels) { +qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initialChannels) { var box = new Element("table"); parentElement.appendChild(box); box.addClass("loginbox"); diff --git a/js/ui/mochaui.js b/js/ui/mochaui.js index 710e073..9c1e86a 100644 --- a/js/ui/mochaui.js +++ b/js/ui/mochaui.js @@ -1,12 +1,68 @@ -var QMochaUIWindow = new Class({ - Extends: UIWindow, +qwebirc.ui.MochaUI = new Class({ + Extends: qwebirc.ui.NewLoginUI, + initialize: function(parentElement, theme) { + this.parent(parentElement, qwebirc.ui.MochaUI.Window, "mochaui"); + this.theme = theme; + this.parentElement = parentElement; + + window.addEvent("domready", function() { + /* determine input size */ + var l = new Element("input", {styles: {border: 0}}); + this.parentElement.appendChild(l); + this.inputHeight = l.getSize().y; + this.parentElement.removeChild(l); + + MochaUI.Desktop = new MochaUI.Desktop(); + MochaUI.Dock = new MochaUI.Dock({ + dockPosition: "top" + }); + + MochaUI.Modal = new MochaUI.Modal(); + MochaUI.options.useEffects = false; + }.bind(this)); + + window.addEvent("unload", function() { + if(MochaUI) + MochaUI.garbageCleanUp(); + }); + }, + postInitialize: function() { + return; + this.tabs = new Element("div"); + this.tabs.addClass("tabbar"); + + this.parentElement.appendChild(this.tabs); + + this.container = new Element("div"); + this.container.addClass("container"); + + this.parentElement.appendChild(this.container); + + var form = new Element("form"); + var inputbox = new Element("input"); + inputbox.addClass("input"); + + form.addEvent("submit", function(e) { + new Event(e).stop(); + + this.getActiveWindow().client.exec(inputbox.value); + inputbox.value = ""; + }.bind(this)); + this.parentElement.appendChild(form); + form.appendChild(inputbox); + inputbox.focus(); + } +}); + +qwebirc.ui.MochaUI.Window = new Class({ + Extends: qwebirc.ui.Window, initialize: function(parentObject, client, type, name) { this.parent(parentObject, client, type, name); this.lines = new Element("div", {styles: {overflow: "auto", "width": "90"}}); - var toolbar = type != WINDOW_CUSTOM && type != WINDOW_CONNECT; + var toolbar = (type != qwebirc.ui.WINDOW_CUSTOM) && (type != qwebirc.ui.WINDOW_CONNECT); if(toolbar) { this.form = new Element("form"); @@ -50,14 +106,14 @@ var QMochaUIWindow = new Class({ parentObject.selectWindow(this); }.bind(this), onClose: function() { - if(type == WINDOW_CHANNEL) + if(type == qwebirc.ui.WINDOW_CHANNEL) this.client.exec("/PART " + name); this.close(); }.bind(this) }; prefs.toolbar = toolbar; - prefs.closable = type != WINDOW_STATUS && type != WINDOW_CONNECT; + prefs.closable = type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT; /* HACK */ /* var oldIndexLevel = MochaUI.Windows.indexLevel; @@ -174,59 +230,3 @@ var QMochaUIWindow = new Class({ MochaUI.closeWindow(this.window.windowEl); }, }); - -var QMochaUI = new Class({ - Extends: NewLoginUI, - initialize: function(parentElement, theme) { - this.parent(parentElement, QMochaUIWindow, "mochaui"); - this.theme = theme; - this.parentElement = parentElement; - - window.addEvent("domready", function() { - /* determine input size */ - var l = new Element("input", {styles: {border: 0}}); - this.parentElement.appendChild(l); - this.inputHeight = l.getSize().y; - this.parentElement.removeChild(l); - - MochaUI.Desktop = new MochaUI.Desktop(); - MochaUI.Dock = new MochaUI.Dock({ - dockPosition: "top" - }); - - MochaUI.Modal = new MochaUI.Modal(); - MochaUI.options.useEffects = false; - }.bind(this)); - - window.addEvent("unload", function() { - if(MochaUI) - MochaUI.garbageCleanUp(); - }); - }, - postInitialize: function() { - return; - this.tabs = new Element("div"); - this.tabs.addClass("tabbar"); - - this.parentElement.appendChild(this.tabs); - - this.container = new Element("div"); - this.container.addClass("container"); - - this.parentElement.appendChild(this.container); - - var form = new Element("form"); - var inputbox = new Element("input"); - inputbox.addClass("input"); - - form.addEvent("submit", function(e) { - new Event(e).stop(); - - this.getActiveWindow().client.exec(inputbox.value); - inputbox.value = ""; - }.bind(this)); - this.parentElement.appendChild(form); - form.appendChild(inputbox); - inputbox.focus(); - } -}); diff --git a/js/ui/qui.js b/js/ui/qui.js index 62fca0b..959b836 100644 --- a/js/ui/qui.js +++ b/js/ui/qui.js @@ -1,4 +1,94 @@ -var QJSUI = new Class({ +qwebirc.ui.QUI = new Class({ + Extends: qwebirc.ui.NewLoginUI, + initialize: function(parentElement, theme) { + this.parent(parentElement, qwebirc.ui.QUI.Window, "qui"); + this.theme = theme; + this.parentElement = parentElement; + }, + postInitialize: function() { + this.qjsui = new qwebirc.ui.QUI.JSUI("qwebirc-qui", this.parentElement); + + this.qjsui.top.addClass("tabbar"); + + this.qjsui.bottom.addClass("input"); + this.qjsui.right.addClass("nicklist"); + this.qjsui.topic.addClass("topic"); + this.qjsui.middle.addClass("lines"); + + this.tabs = this.qjsui.top; + this.origtopic = this.topic = this.qjsui.topic; + this.origlines = this.lines = this.qjsui.middle; + this.orignicklist = this.nicklist = this.qjsui.right; + + this.input = this.qjsui.bottom; + this.reflow = this.qjsui.reflow.bind(this.qjsui); + + this.createInput(); + this.reflow(); + }, + createInput: function() { + var form = new Element("form"); + this.input.appendChild(form); + form.addClass("input"); + + var inputbox = new Element("input"); + form.appendChild(inputbox); + this.inputbox = inputbox; + + form.addEvent("submit", function(e) { + new Event(e).stop(); + + if(inputbox.value == "") + return; + + this.getActiveWindow().historyExec(inputbox.value); + inputbox.value = ""; + }.bind(this)); + + inputbox.addEvent("keydown", function(e) { + var resultfn; + var cvalue = inputbox.value; + + if(e.key == "up") { + resultfn = this.commandhistory.upLine; + } else if(e.key == "down") { + resultfn = this.commandhistory.downLine; + } else { + return; + } + + if((cvalue != "") && (this.lastcvalue != cvalue)) + this.commandhistory.addLine(cvalue, true); + + var result = resultfn.bind(this.commandhistory)(); + + new Event(e).stop(); + if(!result) + result = ""; + this.lastcvalue = result; + + inputbox.value = result; + setAtEnd(inputbox); + }.bind(this)); + }, + setLines: function(lines) { + this.lines.parentNode.replaceChild(lines, this.lines); + this.qjsui.middle = this.lines = lines; + }, + setChannelItems: function(nicklist, topic) { + if(!$defined(nicklist)) { + nicklist = this.orignicklist; + topic = this.origtopic; + } + this.nicklist.parentNode.replaceChild(nicklist, this.nicklist); + this.qjsui.right = this.nicklist = nicklist; + + this.topic.parentNode.replaceChild(topic, this.topic); + this.qjsui.topic = this.topic = topic; + } +}); + +qwebirc.ui.QUI.JSUI = new Class({ initialize: function(class_, parent, sizer) { this.parent = parent; this.sizer = $defined(sizer)?sizer:parent; @@ -98,8 +188,8 @@ var QJSUI = new Class({ } }); -var QUIWindow = new Class({ - Extends: UIWindow, +qwebirc.ui.QUI.Window = new Class({ + Extends: qwebirc.ui.Window, initialize: function(parentObject, client, type, name) { this.parent(parentObject, client, type, name); @@ -114,13 +204,14 @@ var QUIWindow = new Class({ parentObject.selectWindow(this); }.bind(this)); - if(type != WINDOW_STATUS && type != WINDOW_CONNECT) { - tabclose = new Element("span"); + if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) { + var tabclose = new Element("span"); + tabclose.set("text", "X"); tabclose.addClass("tabclose"); tabclose.addEvent("click", function(e) { new Event(e).stop(); - if(type == WINDOW_CHANNEL) + if(type == qwebirc.ui.WINDOW_CHANNEL) this.client.exec("/PART " + name); this.close(); @@ -137,7 +228,7 @@ var QUIWindow = new Class({ this.scrolleddown = this.scrolledDown(); }.bind(this)); - if(type == WINDOW_CHANNEL) { + if(type == qwebirc.ui.WINDOW_CHANNEL) { this.topic = new Element("div"); this.topic.addClass("topic"); this.topic.addClass("tab-invisible"); @@ -150,7 +241,7 @@ var QUIWindow = new Class({ this.parentObject.qjsui.applyClasses("nicklist", this.nicklist); } - if(type == WINDOW_CHANNEL) { + if(type == qwebirc.ui.WINDOW_CHANNEL) { this.updateTopic(""); } else { this.reflow(); @@ -195,7 +286,7 @@ var QUIWindow = new Class({ this.reflow(); }, select: function() { - var inputVisible = this.type != WINDOW_CONNECT && this.type != WINDOW_CUSTOM; + var inputVisible = this.type != qwebirc.ui.WINDOW_CONNECT && this.type != qwebirc.ui.WINDOW_CUSTOM; this.tab.removeClass("tab-unselected"); this.tab.addClass("tab-selected"); @@ -247,93 +338,3 @@ var QUIWindow = new Class({ } } }); - -var QUI = new Class({ - Extends: NewLoginUI, - initialize: function(parentElement, theme) { - this.parent(parentElement, QUIWindow, "qui"); - this.theme = theme; - this.parentElement = parentElement; - }, - postInitialize: function() { - this.qjsui = new QJSUI("qwebirc-qui", this.parentElement); - - this.qjsui.top.addClass("tabbar"); - - this.qjsui.bottom.addClass("input"); - this.qjsui.right.addClass("nicklist"); - this.qjsui.topic.addClass("topic"); - this.qjsui.middle.addClass("lines"); - - this.tabs = this.qjsui.top; - this.origtopic = this.topic = this.qjsui.topic; - this.origlines = this.lines = this.qjsui.middle; - this.orignicklist = this.nicklist = this.qjsui.right; - - this.input = this.qjsui.bottom; - this.reflow = this.qjsui.reflow.bind(this.qjsui); - - this.createInput(); - this.reflow(); - }, - createInput: function() { - var form = new Element("form"); - this.input.appendChild(form); - form.addClass("input"); - - var inputbox = new Element("input"); - form.appendChild(inputbox); - this.inputbox = inputbox; - - form.addEvent("submit", function(e) { - new Event(e).stop(); - - if(inputbox.value == "") - return; - - this.getActiveWindow().historyExec(inputbox.value); - inputbox.value = ""; - }.bind(this)); - - inputbox.addEvent("keydown", function(e) { - var resultfn; - var cvalue = inputbox.value; - - if(e.key == "up") { - resultfn = this.commandhistory.upLine; - } else if(e.key == "down") { - resultfn = this.commandhistory.downLine; - } else { - return; - } - - if((cvalue != "") && (this.lastcvalue != cvalue)) - this.commandhistory.addLine(cvalue, true); - - var result = resultfn.bind(this.commandhistory)(); - - new Event(e).stop(); - if(!result) - result = ""; - this.lastcvalue = result; - - inputbox.value = result; - setAtEnd(inputbox); - }.bind(this)); - }, - setLines: function(lines) { - this.lines.parentNode.replaceChild(lines, this.lines); - this.qjsui.middle = this.lines = lines; - }, - setChannelItems: function(nicklist, topic) { - if(!$defined(nicklist)) { - nicklist = this.orignicklist; - topic = this.origtopic; - } - this.nicklist.parentNode.replaceChild(nicklist, this.nicklist); - this.qjsui.right = this.nicklist = nicklist; - - this.topic.parentNode.replaceChild(topic, this.topic); - this.qjsui.topic = this.topic = topic; - } -}); diff --git a/js/ui/swmlayout.js b/js/ui/swmlayout.js index dae0b01..41c51ce 100644 --- a/js/ui/swmlayout.js +++ b/js/ui/swmlayout.js @@ -1,10 +1,10 @@ -var SWM_ANCHOR_NONE = 0x00; -var SWM_ANCHOR_TOP = 0x01; -var SWM_ANCHOR_BOTTOM = 0x02; -var SWM_ANCHOR_LEFT = 0x04; -var SWM_ANCHOR_RIGHT = 0x08; +qwebirc.ui.SWMUI.SWM_ANCHOR_NONE = 0x00; +qwebirc.ui.SWMUI.SWM_ANCHOR_TOP = 0x01; +qwebirc.ui.SWMUI.SWM_ANCHOR_BOTTOM = 0x02; +qwebirc.ui.SWMUI.SWM_ANCHOR_LEFT = 0x04; +qwebirc.ui.SWMUI.SWM_ANCHOR_RIGHT = 0x08; -var SWMContainer = new Class({ +qwebirc.ui.SWMUI.Container = new Class({ initialize: function(parentElement) { this.parentElement = parentElement; }, @@ -78,11 +78,11 @@ var SWMContainer = new Class({ }); } - var top = anchorFilter(x, SWM_ANCHOR_TOP); - var bottom = anchorFilter(x, SWM_ANCHOR_BOTTOM); - var left = anchorFilter(x, SWM_ANCHOR_LEFT); - var right = anchorFilter(x, SWM_ANCHOR_RIGHT); - var none = anchorFilter(x, SWM_ANCHOR_NONE); + var top = anchorFilter(x, qwebirc.ui.SWMUI.SWM_ANCHOR_TOP); + var bottom = anchorFilter(x, qwebirc.ui.SWMUI.SWM_ANCHOR_BOTTOM); + var left = anchorFilter(x, qwebirc.ui.SWMUI.SWM_ANCHOR_LEFT); + var right = anchorFilter(x, qwebirc.ui.SWMUI.SWM_ANCHOR_RIGHT); + var none = anchorFilter(x, qwebirc.ui.SWMUI.SWM_ANCHOR_NONE); var x = this.getInnerSize(); var y = this.getOuterSize(); @@ -123,8 +123,8 @@ var SWMContainer = new Class({ } }); -var SWMFrame = new Class({ - Extends: SWMContainer, +qwebirc.ui.SWMUI.Frame = new Class({ + Extends: qwebirc.ui.SWMUI.Container, initialize: function(parentElement) { this.parent(this); @@ -142,8 +142,8 @@ var SWMFrame = new Class({ } }); -var SWMPanel = new Class({ - Extends: SWMContainer, +qwebirc.ui.SWMUI.Panel = new Class({ + Extends: qwebirc.ui.SWMUI.Container, initialize: function(parentPanel, hidden) { this.parent(parentPanel); this.element = new Element("div", {"styles": { @@ -158,7 +158,7 @@ var SWMPanel = new Class({ } parentPanel.element.appendChild(this.element); - this.anchor = SWM_ANCHOR_NONE; + this.anchor = qwebirc.ui.SWMUI.SWM_ANCHOR_NONE; }, setHeight: function(height) { this.height = height; diff --git a/js/ui/swmui.js b/js/ui/swmui.js index ce257ee..50957e3 100644 --- a/js/ui/swmui.js +++ b/js/ui/swmui.js @@ -1,22 +1,76 @@ -var SWMUIWindow = new Class({ - Extends: UIWindow, +qwebirc.ui.SWMUI = new Class({ + Extends: qwebirc.ui.NewLoginUI, + initialize: function(parentElement, theme) { + this.parent(parentElement, qwebirc.ui.SWMUI.Window, "swmui"); + + this.parentElement = parentElement; + this.theme = theme; + }, + postInitialize: function() { + this.rootFrame = new qwebirc.ui.SWMUI.Frame(this.parentElement); + + this.tabPanel = new qwebirc.ui.SWMUI.Panel(this.rootFrame); + this.tabPanel.anchor = qwebirc.ui.SWMUI.SWM_ANCHOR_TOP; + this.tabPanel.addClass("tabs"); + + this.mainPanel = new qwebirc.ui.SWMUI.Panel(this.rootFrame); + this.mainPanel.addClass("main"); + + this.entryPanel = new qwebirc.ui.SWMUI.Panel(this.rootFrame); + this.entryPanel.anchor = qwebirc.ui.SWMUI.SWM_ANCHOR_BOTTOM; + this.entryPanel.addClass("entry"); + + var form = new Element("form"); + + var inputbox = new Element("input"); + inputbox.setStyle("border", "0px"); + + window.addEvent("resize", function() { + var s = this.entryPanel.getInnerSize().x; + inputbox.setStyle("width", s + "px"); + }.bind(this)); + + form.addEvent("submit", function(e) { + new Event(e).stop(); + + this.getActiveWindow().client.exec(inputbox.value); + inputbox.value = ""; + }.bind(this)); + + this.entryPanel.appendChild(form); + form.appendChild(inputbox); + inputbox.focus(); + + this.resize(); + }, + showInput: function(state) { + this.entryPanel.setHidden(state); + this.resize(); + }, + resize: function() { + window.fireEvent("resize"); + } +}); + +qwebirc.ui.SWMUI.Window = new Class({ + Extends: qwebirc.ui.Window, initialize: function(parentObject, client, type, name) { this.parent(parentObject, client, type, name); - this.contentPanel = new SWMPanel(parentObject.mainPanel, true); + this.contentPanel = new qwebirc.ui.SWMUI.Panel(parentObject.mainPanel, true); this.contentPanel.addClass("content"); - if(type == WINDOW_CHANNEL) { - this.nickList = new SWMPanel(this.contentPanel); - this.nickList.anchor = SWM_ANCHOR_RIGHT; + if(type == qwebirc.ui.WINDOW_CHANNEL) { + this.nickList = new qwebirc.ui.SWMUI.Panel(this.contentPanel); + this.nickList.anchor = qwebirc.ui.SWMUI.SWM_ANCHOR_RIGHT; this.nickList.addClass("nicklist"); - this.topic = new SWMPanel(this.contentPanel); - this.topic.anchor = SWM_ANCHOR_TOP; + this.topic = new qwebirc.ui.SWMUI.Panel(this.contentPanel); + this.topic.anchor = qwebirc.ui.SWMUI.SWM_ANCHOR_TOP; this.topic.addClass("topic"); } - this.xlines = new SWMPanel(this.contentPanel); + this.xlines = new qwebirc.ui.SWMUI.Panel(this.contentPanel); this.lines = this.xlines.element; this.tab = new Element("span"); @@ -30,13 +84,13 @@ var SWMUIWindow = new Class({ parentObject.tabPanel.appendChild(this.tab); parentObject.resize(); - if(type != WINDOW_STATUS && type != WINDOW_CONNECT) { + if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) { tabclose = new Element("span"); tabclose.addClass("tabclose"); tabclose.addEvent("click", function(e) { new Event(e).stop(); - if(type == WINDOW_CHANNEL) + if(type == qwebirc.ui.WINDOW_CHANNEL) this.client.exec("/PART " + name); this.close(); @@ -72,7 +126,7 @@ var SWMUIWindow = new Class({ this.parentObject.resize(); this.tab.removeClass("tab-unselected"); this.tab.addClass("tab-selected"); - this.parentObject.showInput(this.type == WINDOW_CONNECT || this.type == WINDOW_CUSTOM); + this.parentObject.showInput(this.type == qwebirc.ui.WINDOW_CONNECT || this.type == qwebirc.ui.WINDOW_CUSTOM); }, deselect: function() { this.parent(); @@ -113,57 +167,3 @@ var SWMUIWindow = new Class({ } } }); - -var SWMUI = new Class({ - Extends: NewLoginUI, - initialize: function(parentElement, theme) { - this.parent(parentElement, SWMUIWindow, "swmui"); - - this.parentElement = parentElement; - this.theme = theme; - }, - postInitialize: function() { - this.rootFrame = new SWMFrame(this.parentElement); - - this.tabPanel = new SWMPanel(this.rootFrame); - this.tabPanel.anchor = SWM_ANCHOR_TOP; - this.tabPanel.addClass("tabs"); - - this.mainPanel = new SWMPanel(this.rootFrame); - this.mainPanel.addClass("main"); - - this.entryPanel = new SWMPanel(this.rootFrame); - this.entryPanel.anchor = SWM_ANCHOR_BOTTOM; - this.entryPanel.addClass("entry"); - - var form = new Element("form"); - - var inputbox = new Element("input"); - inputbox.setStyle("border", "0px"); - - window.addEvent("resize", function() { - var s = this.entryPanel.getInnerSize().x; - inputbox.setStyle("width", s + "px"); - }.bind(this)); - - form.addEvent("submit", function(e) { - new Event(e).stop(); - - this.getActiveWindow().client.exec(inputbox.value); - inputbox.value = ""; - }.bind(this)); - - this.entryPanel.appendChild(form); - form.appendChild(inputbox); - inputbox.focus(); - - this.resize(); - }, - showInput: function(state) { - this.entryPanel.setHidden(state); - this.resize(); - }, - resize: function() { - window.fireEvent("resize"); - } -}); diff --git a/js/ui/theme.js b/js/ui/theme.js index b9e8755..edafc4e 100644 --- a/js/ui/theme.js +++ b/js/ui/theme.js @@ -1,4 +1,4 @@ -var ThemeControlCodeMap = { +qwebirc.ui.themes.ThemeControlCodeMap = { "C": "\x03", "B": "\x02", "U": "\x1F", @@ -6,7 +6,7 @@ var ThemeControlCodeMap = { "$": "$" }; -var DefaultTheme = { +qwebirc.ui.themes.Default = { "PREFIX": ["$C4==$O "], "SIGNON": ["Signed on!", true], "CONNECT": ["Connected to server.", true], @@ -46,12 +46,12 @@ var DefaultTheme = { "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"] }; -var Theme = new Class({ +qwebirc.ui.Theme = new Class({ initialize: function(themeDict) { this.__theme = {}; - for(var k in DefaultTheme) - this.__theme[k] = DefaultTheme[k]; + for(var k in qwebirc.ui.themes.Default) + this.__theme[k] = qwebirc.ui.themes.Default[k]; if(themeDict) for(var k in themeDict) @@ -78,7 +78,7 @@ var Theme = new Class({ if(c == "$" && (i <= n.length - 1)) { var c2 = n[++i]; - var o = ThemeControlCodeMap[c2]; + var o = qwebirc.ui.themes.ThemeControlCodeMap[c2]; if(!o) o = h[c2]; if(o) diff --git a/js/ui/uglyui.js b/js/ui/uglyui.js index d2ebd51..d9ce39b 100644 --- a/js/ui/uglyui.js +++ b/js/ui/uglyui.js @@ -1,5 +1,44 @@ -var UglyUIWindow = new Class({ - Extends: UIWindow, +qwebirc.ui.UglyUI = new Class({ + Extends: qwebirc.ui.NewLoginUI, + initialize: function(parentElement, theme) { + this.parent(parentElement, qwebirc.ui.UglyUI.Window, "uglyui"); + this.theme = theme; + this.parentElement = parentElement; + }, + postInitialize: function() { + this.tabs = new Element("div"); + this.tabs.addClass("tabbar"); + + this.parentElement.appendChild(this.tabs); + + this.container = new Element("div"); + this.container.addClass("container"); + + this.parentElement.appendChild(this.container); + + var form = new Element("form"); + this.form = form; + + var inputbox = new Element("input"); + inputbox.addClass("input"); + + form.addEvent("submit", function(e) { + new Event(e).stop(); + + this.getActiveWindow().client.exec(inputbox.value); + inputbox.value = ""; + }.bind(this)); + this.parentElement.appendChild(form); + form.appendChild(inputbox); + inputbox.focus(); + }, + showInput: function(state) { + this.form.setStyle("display", state?"block":"none"); + } +}); + +qwebirc.ui.UglyUI.Window = new Class({ + Extends: qwebirc.ui.Window, initialize: function(parentObject, client, type, name) { this.parent(parentObject, client, type, name); @@ -10,7 +49,7 @@ var UglyUIWindow = new Class({ parentObject.container.appendChild(this.outerContainer); - if(type == WINDOW_CHANNEL) { + if(type == qwebirc.ui.WINDOW_CHANNEL) { this.nicklist = new Element("div"); this.nicklist.addClass("nicklist"); @@ -21,7 +60,7 @@ var UglyUIWindow = new Class({ innerContainer.addClass("innercontainer"); this.outerContainer.appendChild(innerContainer); - if(type == WINDOW_CHANNEL) { + if(type == qwebirc.ui.WINDOW_CHANNEL) { this.topic = new Element("div"); this.topic.addClass("topic"); innerContainer.appendChild(this.topic); @@ -41,13 +80,13 @@ var UglyUIWindow = new Class({ parentObject.tabs.appendChild(this.tab); - if(type != WINDOW_STATUS && type != WINDOW_CONNECT) { + if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) { tabclose = new Element("span"); tabclose.addClass("tabclose"); tabclose.addEvent("click", function(e) { new Event(e).stop(); - if(type == WINDOW_CHANNEL) + if(type == qwebirc.ui.WINDOW_CHANNEL) this.client.exec("/PART " + name); this.close(); @@ -85,7 +124,7 @@ var UglyUIWindow = new Class({ this.outerContainer.removeClass("tab-invisible"); this.tab.removeClass("tab-unselected"); this.tab.addClass("tab-selected"); - this.parentObject.showInput(this.type != WINDOW_CONNECT && this.type != WINDOW_CUSTOM); + this.parentObject.showInput(this.type != qwebirc.ui.WINDOW_CONNECT && this.type != qwebirc.ui.WINDOW_CUSTOM); }, deselect: function() { this.parent(); @@ -125,42 +164,3 @@ var UglyUIWindow = new Class({ } }); -var UglyUI = new Class({ - Extends: NewLoginUI, - initialize: function(parentElement, theme) { - this.parent(parentElement, UglyUIWindow, "uglyui"); - this.theme = theme; - this.parentElement = parentElement; - }, - postInitialize: function() { - this.tabs = new Element("div"); - this.tabs.addClass("tabbar"); - - this.parentElement.appendChild(this.tabs); - - this.container = new Element("div"); - this.container.addClass("container"); - - this.parentElement.appendChild(this.container); - - var form = new Element("form"); - this.form = form; - - var inputbox = new Element("input"); - inputbox.addClass("input"); - - form.addEvent("submit", function(e) { - new Event(e).stop(); - - this.getActiveWindow().client.exec(inputbox.value); - inputbox.value = ""; - }.bind(this)); - this.parentElement.appendChild(form); - form.appendChild(inputbox); - inputbox.focus(); - }, - showInput: function(state) { - this.form.setStyle("display", state?"block":"none"); - } -}); - diff --git a/js/ui/url.js b/js/ui/url.js index dd4f5b0..5ff4c02 100644 --- a/js/ui/url.js +++ b/js/ui/url.js @@ -1,4 +1,4 @@ -function urlificate(element, text, execfn, cmdfn) { +qwebirc.ui.urlificate = function(element, text, execfn, cmdfn) { var punct_re = /(\.*|\,|;)$/; var txtprocess = function(text, regex, appendfn, matchfn) { diff --git a/js/version.js b/js/version.js index ab31429..a2bbf59 100644 --- a/js/version.js +++ b/js/version.js @@ -1 +1 @@ -QWEBIRC_VERSION = "0.10" +qwebirc.VERSION = "0.10" diff --git a/static/mochaui.html b/static/mochaui.html index fb1fa11..afa24cd 100644 --- a/static/mochaui.html +++ b/static/mochaui.html @@ -15,7 +15,7 @@ diff --git a/static/mochauidebug.html b/static/mochauidebug.html index e69f05d..acc21a0 100644 --- a/static/mochauidebug.html +++ b/static/mochauidebug.html @@ -12,6 +12,7 @@ + @@ -31,7 +32,7 @@ diff --git a/static/qui.html b/static/qui.html index 4416cfe..bfbf99c 100644 --- a/static/qui.html +++ b/static/qui.html @@ -8,7 +8,7 @@ diff --git a/static/quidebug.html b/static/quidebug.html index b93348f..517495a 100644 --- a/static/quidebug.html +++ b/static/quidebug.html @@ -6,6 +6,7 @@ + @@ -25,7 +26,7 @@ diff --git a/static/swmui.html b/static/swmui.html index e4dd7be..41bcacb 100644 --- a/static/swmui.html +++ b/static/swmui.html @@ -8,7 +8,7 @@ diff --git a/static/swmuidebug.html b/static/swmuidebug.html index f7d996f..52a501e 100644 --- a/static/swmuidebug.html +++ b/static/swmuidebug.html @@ -5,6 +5,7 @@ + @@ -21,11 +22,11 @@ - + diff --git a/static/uglyui.html b/static/uglyui.html index 8adb049..b6b9c17 100644 --- a/static/uglyui.html +++ b/static/uglyui.html @@ -8,7 +8,7 @@ diff --git a/static/uglyuidebug.html b/static/uglyuidebug.html index ac5c562..0641ee7 100644 --- a/static/uglyuidebug.html +++ b/static/uglyuidebug.html @@ -5,6 +5,7 @@ + @@ -24,7 +25,7 @@