+ },
+ newCustomWindow: function(name, select, type) {
+ if(!type)
+ type = qwebirc.ui.WINDOW_CUSTOM;
+
+ var w = this.newWindow(qwebirc.ui.CUSTOM_CLIENT, type, name);
+ w.addEvent("close", function(w) {
+ delete this.windows[qwebirc.ui.CUSTOM_CLIENT][w.identifier];
+ }.bind(this));
+
+ if(select)
+ this.selectWindow(w);
+
+ return w;
+ },
+ addCustomWindow: function(windowName, class_, cssClass, options) {
+ if(!$defined(options))
+ options = {};
+
+ if(this.customWindows[windowName]) {
+ this.selectWindow(this.customWindows[windowName]);
+ return;
+ }
+
+ var d = this.newCustomWindow(windowName, true);
+ this.customWindows[windowName] = d;
+
+ d.addEvent("close", function() {
+ this.customWindows[windowName] = null;
+ }.bind(this));
+
+ if(cssClass)
+ d.lines.addClass(cssClass);
+
+ var ew = new class_(d.lines, options);
+ ew.addEvent("close", function() {
+ d.close();
+ }.bind(this));
+ },
+ embeddedWindow: function() {
+ this.addCustomWindow("Embedded Wizard", qwebirc.ui.EmbedWizard, "embeddedwizard");
+ },
+ optionsWindow: function() {
+ this.addCustomWindow("Options", qwebirc.ui.OptionsPane, "optionspane", this.uiOptions);
+ },
+ urlDispatcher: function(name) {
+ if(name == "embedded")
+ return ["a", this.embeddedWindow.bind(this)];
+
+ if(name == "options")
+ return ["a", this.optionsWindow.bind(this)];
+
+ return null;
+ },
+ tabComplete: function(element) {
+ this.tabCompleter.tabComplete(element);
+ },
+ resetTabComplete: function() {
+ this.tabCompleter.reset();
+ }
+});
+
+qwebirc.ui.SoundUI = new Class({
+ Extends: qwebirc.ui.StandardUI,
+ initialize: function(parentElement, windowClass, uiName, options) {
+ this.parent(parentElement, windowClass, uiName, options);
+
+ this.soundInited = false;
+ this.soundReady = false;
+
+ this.setBeepOnMention(this.uiOptions.BEEP_ON_MENTION);
+ },
+ soundInit: function() {
+ if(this.soundInited)
+ return;
+ if(!$defined(Browser.Plugins.Flash) || Browser.Plugins.Flash.version < 8)
+ return;
+ this.soundInited = true;
+
+ this.soundPlayer = new qwebirc.sound.SoundPlayer();
+ this.soundPlayer.addEvent("ready", function() {
+ this.soundReady = true;
+ }.bind(this));
+ this.soundPlayer.go();
+ },
+ setBeepOnMention: function(value) {
+ if(value)
+ this.soundInit();
+ this.beepOnMention = value;
+ },
+ beep: function() {
+ if(!this.soundReady || !this.beepOnMention)
+ return;
+
+ this.soundPlayer.beep();
+ }
+});
+
+qwebirc.ui.QuakeNetUI = new Class({
+ Extends: qwebirc.ui.SoundUI,
+ urlDispatcher: function(name, window) {
+ if(name == "qwhois") {
+ return ["span", function(auth) {
+ this.client.exec("/MSG Q whois #" + auth);
+ }.bind(window)];
+ }
+ if(name == "whois") {
+ return ["span", function(nick) {
+ this.client.exec("/WHOIS " + nick);
+ }.bind(window)];
+ }
+ return this.parent(name);
+ },
+ logout: function() {
+ if(!qwebirc.auth.loggedin())
+ return;
+ if(confirm("Log out?")) {
+ for(var client in this.clients) {
+ this.clients[client].quit("Logged out");
+ };
+ document.location = "/auth?logout=1";
+ }
+ }
+});
+
+qwebirc.ui.NewLoginUI = new Class({
+ Extends: qwebirc.ui.QuakeNetUI,
+ loginBox: function(callbackfn, initialNickname, initialChannels, autoConnect, autoNick) {
+ this.postInitialize();
+
+ var w = this.newCustomWindow("Connect", true, qwebirc.ui.WINDOW_CONNECT);
+ var callback = function(args) {
+ w.close();
+ callbackfn(args);
+ };
+
+ qwebirc.ui.GenericLoginBox(w.lines, callback, initialNickname, initialChannels, autoConnect, autoNick);