+
+qwebirc.ui.NotificationUI = new Class({
+ Extends: qwebirc.ui.StandardUI,
+ initialize: function(parentElement, windowClass, uiName, options) {
+ this.parent(parentElement, windowClass, uiName, options);
+
+ this.__beeper = new qwebirc.ui.Beeper(this.uiOptions);
+ this.__flasher = new qwebirc.ui.Flasher(this.uiOptions);
+ this.__notifier = new qwebirc.ui.Notifier(this.uiOptions);
+
+ this.cancelFlash = this.__flasher.cancelFlash.bind(this.__flasher);
+ },
+ beep: function() {
+ this.__beeper.beep();
+ },
+ notify: function(title, message, callback) {
+ this.__beeper.beep();
+ this.__flasher.flash();
+ this.__notifier.notify(title, message, callback);
+ },
+ setBeepOnMention: function(value) {
+ if(value)
+ this.__beeper.soundInit();
+ },
+ setNotifications: function(value) {
+ this.__notifier.setEnabled(value);
+ },
+ updateTitle: function(text) {
+ if(this.__flasher.updateTitle(text))
+ this.parent(text);
+ },
+ focusChange: function(value) {
+ this.parent(value);
+ this.__flasher.focusChange(value);
+ this.__notifier.focusChange(value);
+ }
+});
+
+qwebirc.ui.NewLoginUI = new Class({
+ Extends: qwebirc.ui.NotificationUI,
+ loginBox: function(callbackfn, initialNickname, initialChannels, autoConnect, autoNick) {
+ this.postInitialize();
+
+ /* I'd prefer something shorter and snappier! */
+ 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, this.options.networkName);
+ }
+});
+
+qwebirc.ui.QuakeNetUI = new Class({
+ Extends: qwebirc.ui.NewLoginUI,
+ urlDispatcher: function(name, window) {
+ if(name == "qwhois") {
+ return ["span", function(auth) {
+ this.client.exec("/MSG Q whois #" + auth);
+ }.bind(window)];
+ }
+ return this.parent(name, window);
+ },
+ logout: function() {
+ if(!qwebirc.auth.loggedin())
+ return;
+ if(confirm("Log out?")) {
+ this.clients.each(function(k, v) {
+ v.quit("Logged out");
+ }, this);
+
+ /* HACK */
+ var foo = function() { document.location = qwebirc.global.dynamicBaseURL + "auth?logout=1"; };
+ foo.delay(500);
+ }
+ }
+});
+
+qwebirc.ui.RootUI = qwebirc.ui.QuakeNetUI;
+
+qwebirc.ui.RequestTransformHTML = function(options) {
+ var HREF_ELEMENTS = {
+ "IMG": 1
+ };
+
+ var update = options.update;
+ var onSuccess = options.onSuccess;
+
+ var fixUp = function(node) {
+ if(node.nodeType != 1)
+ return;
+
+ var tagName = node.nodeName.toUpperCase();
+ if(HREF_ELEMENTS[tagName]) {
+ var attr = node.getAttribute("transform_attr");
+ var value = node.getAttribute("transform_value");
+ if($defined(attr) && $defined(value)) {
+ node.removeAttribute("transform_attr");
+ node.removeAttribute("transform_value");
+ node.setAttribute(attr, qwebirc.global.staticBaseURL + value);
+ }
+ }
+
+ for(var i=0;i<node.childNodes.length;i++)
+ fixUp(node.childNodes[i]);
+ };
+
+ delete options["update"];
+ options.onSuccess = function(tree, elements, html, js) {
+ var container = new Element("div");
+ container.set("html", html);
+ fixUp(container);
+ update.empty();
+
+ while(container.childNodes.length > 0) {
+ var x = container.firstChild;
+ container.removeChild(x);
+ update.appendChild(x);
+ }
+ onSuccess();
+ };
+
+ return new Request.HTML(options);
+};
+