]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseui.js
3 var WINDOW_CHANNEL
= 3;
5 var BaseUI
= new Class({
6 Implements: [Events
, Options
],
8 appTitle: "QuakeNet Web IRC"
10 initialize: function(parentElement
, windowClass
, uiName
, options
) {
11 this.setOptions(options
);
14 this.windowArray
= [];
15 this.windowClass
= windowClass
;
16 this.parentElement
= parentElement
;
17 this.parentElement
.addClass("qwebirc");
18 this.parentElement
.addClass("qwebirc-" + uiName
);
19 this.firstClient
= false;
20 this.commandhistory
= new CommandHistory();
22 newClient: function(client
) {
23 this.windows
[client
] = {}
24 var w
= this.newWindow(client
, WINDOW_STATUS
, "Status");
26 if(!this.firstClient
) {
27 this.firstClient
= true;
28 w
.addLine("", "qwebirc v" + QWEBIRC_VERSION
);
29 w
.addLine("", "Copyright (C) 2008 Chris Porter. All rights reserved.");
30 w
.addLine("", "http://webchat.quakenet.org/");
31 w
.addLine("", "This is BETA quality software, please report bugs to slug@quakenet.org");
35 newWindow: function(client
, type
, name
) {
36 var identifier
= name
;
37 if(type
== WINDOW_STATUS
)
40 var w
= this.windows
[client
][identifier
] = new this.windowClass(this, client
, type
, name
, identifier
);
41 this.windowArray
.push(w
);
45 getActiveWindow: function() {
48 __setActiveWindow: function(window
) {
51 selectWindow: function(window
) {
53 this.active
.deselect();
54 window
.select(); /* calls setActiveWindow */
55 document
.title
= window
.name
+ " - " + this.options
.appTitle
;
57 __closed: function(window
) {
59 this.active
= undefined;
60 if(this.windowArray
.length
== 1) {
61 this.windowArray
= [];
63 var index
= this.windowArray
.indexOf(window
);
65 this.selectWindow(this.windowArray
[1]);
67 this.selectWindow(this.windowArray
[index
- 1]);
70 this.windowArray
= this.windowArray
.erase(window
);
74 delete this.windows
[window
.client
][window
.identifier
];
76 loginBox: function(callback
, initialNickname
, initialChannels
) {
78 this shouldn't be called by overriding classes!
79 some form of user input MUST be received before an
80 IRC connection is made, else users are going to get
81 tricked into getting themselves glined
84 var nick
= prompt("Nickname:", initialNickname
);
90 var chans
= prompt("Channels (seperate by comma):", initialChannels
);
91 callback({"nickname": nick
, "autojoin": chans
});
97 initialize: function(parentElement
, windowClass
, uiName
, options
) {
98 this.parent(parentElement
, windowClass
, uiName
, options
);
99 window
.addEvent("keydown", function(x
) {
103 if(x
.key
== "a" || x
.key
== "A") {
104 for(var i
=0;i
<this.windowArray
.length
;i
++) {
105 if(this.windowArray
[i
].hilighted
) {
106 this.selectWindow(this.windowArray
[i
]);
110 } else if(x
.key
>= '0' && x
.key
<= '9') {
111 number
= x
.key
- '0';
117 if(number
>= this.windowArray
.length
)
120 this.selectWindow(this.windowArray
[number
]);