]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseui.js
3 var WINDOW_CHANNEL
= 3;
5 var WINDOW_CONNECT
= 5;
6 var CUSTOM_CLIENT
= "custom";
8 var BaseUI
= new Class({
9 Implements: [Events
, Options
],
11 appTitle: "QuakeNet Web IRC",
14 initialize: function(parentElement
, windowClass
, uiName
, options
) {
15 this.setOptions(options
);
18 this.windows
[CUSTOM_CLIENT
] = {};
19 this.windowArray
= [];
20 this.windowClass
= windowClass
;
21 this.parentElement
= parentElement
;
22 this.parentElement
.addClass("qwebirc");
23 this.parentElement
.addClass("qwebirc-" + uiName
);
24 this.firstClient
= false;
25 this.commandhistory
= new CommandHistory();
27 newClient: function(client
) {
28 this.windows
[client
] = {}
29 var w
= this.newWindow(client
, WINDOW_STATUS
, "Status");
31 if(!this.firstClient
) {
32 this.firstClient
= true;
33 w
.addLine("", "qwebirc v" + QWEBIRC_VERSION
);
34 w
.addLine("", "Copyright (C) 2008 Chris Porter. All rights reserved.");
35 w
.addLine("", "http://webchat.quakenet.org/");
36 w
.addLine("", "This is BETA quality software, please report bugs to slug@quakenet.org");
40 newWindow: function(client
, type
, name
) {
41 var identifier
= name
;
42 if(type
== WINDOW_STATUS
)
45 var w
= this.windows
[client
][identifier
] = new this.windowClass(this, client
, type
, name
, identifier
);
46 this.windowArray
.push(w
);
50 getActiveWindow: function() {
53 __setActiveWindow: function(window
) {
56 selectWindow: function(window
) {
58 this.active
.deselect();
59 window
.select(); /* calls setActiveWindow */
60 document
.title
= window
.name
+ " - " + this.options
.appTitle
;
62 __closed: function(window
) {
64 this.active
= undefined;
65 if(this.windowArray
.length
== 1) {
66 this.windowArray
= [];
68 var index
= this.windowArray
.indexOf(window
);
70 this.selectWindow(this.windowArray
[1]);
72 this.selectWindow(this.windowArray
[index
- 1]);
75 this.windowArray
= this.windowArray
.erase(window
);
79 delete this.windows
[window
.client
][window
.identifier
];
82 this shouldn't be called by overriding classes!
83 they should implement their own!
84 some form of user input MUST be received before an
85 IRC connection is made, else users are going to get
86 tricked into getting themselves glined
88 loginBox: function(callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
89 GenericLoginBox(this.parentElement
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);
91 var c = initialChannels.split(",");
96 ctext = c.join(", ") + " and " + last;
105 nicktext = " (as '" + initialNickname + "')"
107 if(confirm("Connect to IRC and join channels " + ctext + nicktext + "?"))
108 callback({"nickname": initialNickname, "autojoin": initialChannels});
112 var nick = prompt("Nickname:", initialNickname);
118 var chans = prompt("Channels (seperate by comma):", initialChannels);
119 callback({"nickname": nick, "autojoin": chans});
126 initialize: function(parentElement
, windowClass
, uiName
, options
) {
127 this.parent(parentElement
, windowClass
, uiName
, options
);
128 window
.addEvent("keydown", function(x
) {
132 if(x
.key
== "a" || x
.key
== "A") {
134 for(var i
=0;i
<this.windowArray
.length
;i
++) {
135 if(this.windowArray
[i
].hilighted
) {
136 this.selectWindow(this.windowArray
[i
]);
140 } else if(x
.key
>= '0' && x
.key
<= '9') {
143 number
= x
.key
- '0';
149 if(number
>= this.windowArray
.length
)
152 this.selectWindow(this.windowArray
[number
]);
156 newCustomWindow: function(name
, select
, type
) {
158 type
= WINDOW_CUSTOM
;
160 var w
= this.newWindow(CUSTOM_CLIENT
, type
, name
);
161 w
.addEvent("close", function(w
) {
162 delete this.windows
[name
];
166 this.selectWindow(w
);
170 embeddedWindow: function() {
172 this.selectWindow(this.embedded
)
176 this.embedded
= this.newCustomWindow("Embedded wizard", true);
177 this.embedded
.addEvent("close", function() {
178 this.embedded
= null;
181 var ew
= new WebmasterGuide({parent: this.embedded
.lines
});
182 ew
.addEvent("close", function() {
183 this.embedded
.close();
186 urlDispatcher: function(name
) {
187 if(name
== "embedded")
188 return this.embeddedWindow
.bind(this);