var WINDOW_QUERY = 2;
var WINDOW_CHANNEL = 3;
-var UIWindow = new Class({
- Implements: [Events],
- initialize: function(parentObject, client, type, name, identifier) {
- this.parentObject = parentObject;
- this.type = type;
- this.name = name;
- this.active = false;
- this.client = client;
- this.identifier = identifier;
+var BaseUI = new Class({
+ Implements: [Events, Options],
+ options: {
+ appTitle: "QuakeNet Web IRC",
+ singleWindow: true
},
- updateNickList: function(nicks) {
- },
- updateTopic: function(topic) {
- },
- close: function() {
- this.parentObject.__closed(this);
- this.fireEvent("close", this);
- },
- select: function() {
- this.active = true;
- this.parentObject.__setActiveWindow(this);
- },
- deselect: function() {
- this.active = false;
- },
- addLine: function(type, line, colour) {
- },
- errorMessage: function(message) {
- this.addLine("", message, "red");
- }
-});
-
-var UI = new Class({
- initialize: function(parentElement, windowClass, uiName) {
+ initialize: function(parentElement, windowClass, uiName, options) {
+ this.setOptions(options);
+
this.windows = {};
this.windowArray = [];
this.windowClass = windowClass;
this.parentElement.addClass("qwebirc");
this.parentElement.addClass("qwebirc-" + uiName);
this.firstClient = false;
+ this.commandhistory = new CommandHistory();
},
newClient: function(client) {
this.windows[client] = {}
this.selectWindow(w);
if(!this.firstClient) {
this.firstClient = true;
- w.addLine("", "qwebirc v" + QWEBIRC_VERSION + " -- Copyright (C) 2008 Chris Porter. All rights reserved.");
+ w.addLine("", "qwebirc v" + QWEBIRC_VERSION);
+ w.addLine("", "Copyright (C) 2008 Chris Porter. All rights reserved.");
w.addLine("", "http://webchat.quakenet.org/");
+ w.addLine("", "This is BETA quality software, please report bugs to slug@quakenet.org");
}
return w;
},
if(this.active)
this.active.deselect();
window.select(); /* calls setActiveWindow */
+ document.title = window.name + " - " + this.options.appTitle;
},
__closed: function(window) {
if(window.active) {
delete this.windows[window.client][window.identifier];
},
- loginBox: function(callback, initialNickname, initialChannels) {
/*
this shouldn't be called by overriding classes!
+ they should implement their own!
some form of user input MUST be received before an
IRC connection is made, else users are going to get
tricked into getting themselves glined
*/
+ loginBox: function(callback, initialNickname, initialChannels, autoConnect, autoNick) {
+ GenericLoginBox(this.parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick);
+ /*if(autoConnect) {
+ var c = initialChannels.split(",");
+ var ctext;
+
+ if(c.length > 1) {
+ var last = c.pop();
+ ctext = c.join(", ") + " and " + last;
+ } else {
+ ctext = c[0];
+ }
+
+ var nicktext;
+ if(autoNick) {
+ nicktext = "";
+ } else {
+ nicktext = " (as '" + initialNickname + "')"
+ }
+ if(confirm("Connect to IRC and join channels " + ctext + nicktext + "?"))
+ callback({"nickname": initialNickname, "autojoin": initialChannels});
+ return;
+ }
var nick = prompt("Nickname:", initialNickname);
if(!nick) {
var chans = prompt("Channels (seperate by comma):", initialChannels);
callback({"nickname": nick, "autojoin": chans});
+ */
+ }
+});
+
+var UI = new Class({
+ Extends: BaseUI,
+ initialize: function(parentElement, windowClass, uiName, options) {
+ this.parent(parentElement, windowClass, uiName, options);
+ window.addEvent("keydown", function(x) {
+ if(!x.alt)
+ return;
+
+ if(x.key == "a" || x.key == "A") {
+ new Event(x).stop();
+ for(var i=0;i<this.windowArray.length;i++) {
+ if(this.windowArray[i].hilighted) {
+ this.selectWindow(this.windowArray[i]);
+ break;
+ }
+ }
+ } else if(x.key >= '0' && x.key <= '9') {
+ new Event(x).stop();
+
+ number = x.key - '0';
+ if(number == 0)
+ number = 10
+
+ number = number - 1;
+
+ if(number >= this.windowArray.length)
+ return;
+
+ this.selectWindow(this.windowArray[number]);
+ }
+ }.bind(this));
}
});