]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseui.js
1 qwebirc
.ui
.WINDOW_STATUS
= 1;
2 qwebirc
.ui
.WINDOW_QUERY
= 2;
3 qwebirc
.ui
.WINDOW_CHANNEL
= 3;
4 qwebirc
.ui
.WINDOW_CUSTOM
= 4;
5 qwebirc
.ui
.WINDOW_CONNECT
= 5;
6 qwebirc
.ui
.CUSTOM_CLIENT
= "custom";
8 qwebirc
.ui
.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
[qwebirc
.ui
.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 qwebirc
.irc
.CommandHistory();
27 newClient: function(client
) {
28 client
.hilightController
= new qwebirc
.ui
.HilightController(client
);
30 this.windows
[client
] = {}
31 var w
= this.newWindow(client
, qwebirc
.ui
.WINDOW_STATUS
, "Status");
33 if(!this.firstClient
) {
34 this.firstClient
= true;
35 w
.addLine("", "qwebirc v" + qwebirc
.VERSION
);
36 w
.addLine("", "Copyright (C) 2008 Chris Porter. All rights reserved.");
37 w
.addLine("", "http://webchat.quakenet.org/");
38 w
.addLine("", "This is BETA quality software, please report bugs to slug@quakenet.org");
42 newWindow: function(client
, type
, name
) {
43 var identifier
= name
;
44 if(type
== qwebirc
.ui
.WINDOW_STATUS
)
47 var w
= this.windows
[client
][identifier
] = new this.windowClass(this, client
, type
, name
, identifier
);
48 this.windowArray
.push(w
);
52 getActiveWindow: function() {
55 __setActiveWindow: function(window
) {
58 selectWindow: function(window
) {
60 this.active
.deselect();
61 window
.select(); /* calls setActiveWindow */
62 document
.title
= window
.name
+ " - " + this.options
.appTitle
;
64 nextWindow: function(direction
) {
65 if(this.windowArray
.length
== 0 || !this.active
)
71 var index
= this.windowArray
.indexOf(this.active
);
75 index
= index
+ direction
;
77 index
= this.windowArray
.length
- 1;
78 } else if(index
>= this.windowArray
.length
) {
82 this.selectWindow(this.windowArray
[index
]);
84 prevWindow: function() {
87 __closed: function(window
) {
89 this.active
= undefined;
90 if(this.windowArray
.length
== 1) {
91 this.windowArray
= [];
93 var index
= this.windowArray
.indexOf(window
);
96 } else if(index
== 0) {
97 this.selectWindow(this.windowArray
[1]);
99 this.selectWindow(this.windowArray
[index
- 1]);
104 this.windowArray
= this.windowArray
.erase(window
);
105 delete this.windows
[window
.client
][window
.identifier
];
108 this shouldn't be called by overriding classes!
109 they should implement their own!
110 some form of user input MUST be received before an
111 IRC connection is made, else users are going to get
112 tricked into getting themselves glined
114 loginBox: function(callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
115 qwebirc
.ui
.GenericLoginBox(this.parentElement
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);
119 qwebirc
.ui
.StandardUI
= new Class({
120 Extends: qwebirc
.ui
.BaseUI
,
121 initialize: function(parentElement
, windowClass
, uiName
, options
) {
122 this.parent(parentElement
, windowClass
, uiName
, options
);
124 this.tabCompleter
= new qwebirc
.ui
.TabCompleterFactory(this);
126 window
.addEvent("keydown", function(x
) {
127 if(!x
.alt
|| x
.control
)
131 if(x
.key
== "a" || x
.key
== "A") {
133 var highestIndex
= -1;
137 for(var i
=0;i
<this.windowArray
.length
;i
++) {
138 var h
= this.windowArray
[i
].hilighted
;
144 if(highestIndex
> -1)
145 this.selectWindow(this.windowArray
[highestIndex
]);
146 } else if(x
.key
>= '0' && x
.key
<= '9') {
149 number
= x
.key
- '0';
155 if(number
>= this.windowArray
.length
)
158 this.selectWindow(this.windowArray
[number
]);
159 } else if(x
.key
== "left") {
162 } else if(x
.key
== "right") {
170 newCustomWindow: function(name
, select
, type
) {
172 type
= qwebirc
.ui
.WINDOW_CUSTOM
;
174 var w
= this.newWindow(qwebirc
.ui
.CUSTOM_CLIENT
, type
, name
);
175 w
.addEvent("close", function(w
) {
176 delete this.windows
[name
];
180 this.selectWindow(w
);
184 embeddedWindow: function() {
186 this.selectWindow(this.embedded
)
190 this.embedded
= this.newCustomWindow("Embedding wizard", true);
191 this.embedded
.addEvent("close", function() {
192 this.embedded
= null;
195 this.embedded
.lines
.addClass("embeddedwizard");
196 var ew
= new qwebirc
.ui
.EmbedWizard({parent: this.embedded
.lines
});
197 ew
.addEvent("close", function() {
198 this.embedded
.close();
201 urlDispatcher: function(name
) {
202 if(name
== "embedded")
203 return ["a", this.embeddedWindow
.bind(this)];
207 tabComplete: function(element
) {
208 this.tabCompleter
.tabComplete(element
);
210 resetTabComplete: function() {
211 this.tabCompleter
.reset();
215 qwebirc
.ui
.QuakeNetUI
= new Class({
216 Extends: qwebirc
.ui
.StandardUI
,
217 urlDispatcher: function(name
, window
) {
218 if(name
== "qwhois") {
219 return ["span", function(auth
) {
220 this.client
.exec("/MSG Q whois #" + auth
);
223 if(name
== "whois") {
224 return ["span", function(nick
) {
225 this.client
.exec("/WHOIS " + nick
);
229 return this.parent(name
);
233 qwebirc
.ui
.NewLoginUI
= new Class({
234 Extends: qwebirc
.ui
.QuakeNetUI
,
235 loginBox: function(callbackfn
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
236 this.postInitialize();
237 var w
= this.newCustomWindow("Connect", true, qwebirc
.ui
.WINDOW_CONNECT
);
238 var callback = function(args
) {
243 qwebirc
.ui
.GenericLoginBox(w
.lines
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);