+function qwebirc_ui_onbeforeunload(e) { /* IE sucks */
+ var message = "This action will close all active IRC connections.";
+ var e = e || window.event;
+ if(e)
+ e.returnValue = message;
+ return message;
+}
+
qwebirc.ui.Interface = new Class({
Implements: [Options],
options: {
loginRegex: null,
appTitle: "ExampleNetwork Web IRC",
searchURL: true,
- theme: undefined
+ theme: undefined,
+ baseURL: null,
+ hue: null,
+ uiOptionsArg: null,
+ dynamicBaseURL: "/",
+ staticBaseURL: "/"
},
initialize: function(element, ui, options) {
+ qwebirc.global = {dynamicBaseURL: options.dynamicBaseURL, staticBaseURL: options.staticBaseURL}; /* HACK */
+
this.setOptions(options);
window.addEvent("domready", function() {
- var ui_ = new ui($(element), new qwebirc.ui.Theme(this.options.theme), this.options);
-
var callback = function(options) {
var IRC = new qwebirc.irc.IRCClient(options, ui_);
IRC.connect();
- window.addEvent("beforeunload", function() {
+ window.onbeforeunload = qwebirc_ui_onbeforeunload;
+ window.addEvent("unload", function() {
IRC.quit("Page closed");
});
};
if(this.options.searchURL) {
var args = qwebirc.util.parseURI(String(document.location));
+ this.options.hue = this.getHueArg(args);
+ if($defined(args["uio"]))
+ this.options.uiOptionsArg = args["uio"];
+
var url = args["url"];
var chans, nick = args["nick"];
chans = cdata[0].split(",");
var chans2 = [];
- for(i=0;i<chans.length;i++) {
+ for(var i=0;i<chans.length;i++) {
chans2[i] = chans[i];
if(chans[i].charAt(0) != '#')
}
}
+ var ui_ = new ui($(element), new qwebirc.ui.Theme(this.options.theme), this.options);
+
var usingAutoNick = !$defined(nick);
if(usingAutoNick && autoConnect)
inick = this.options.initialNickname;
var details = ui_.loginBox(callback, inick, ichans, autoConnect, usingAutoNick);
}.bind(this));
},
+ getHueArg: function(args) {
+ var hue = args["hue"];
+ if(!$defined(hue))
+ return null;
+ hue = parseInt(hue);
+ if(hue > 360 || hue < 0)
+ return null;
+ return hue;
+ },
randSub: function(nick) {
var getDigit = function() { return Math.floor(Math.random() * 10); }