]>
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 __closed: function(window
) {
66 this.active
= undefined;
67 if(this.windowArray
.length
== 1) {
68 this.windowArray
= [];
70 var index
= this.windowArray
.indexOf(window
);
73 } else if(index
== 0) {
74 this.selectWindow(this.windowArray
[1]);
76 this.selectWindow(this.windowArray
[index
- 1]);
81 this.windowArray
= this.windowArray
.erase(window
);
82 delete this.windows
[window
.client
][window
.identifier
];
85 this shouldn't be called by overriding classes!
86 they should implement their own!
87 some form of user input MUST be received before an
88 IRC connection is made, else users are going to get
89 tricked into getting themselves glined
91 loginBox: function(callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
92 qwebirc
.ui
.GenericLoginBox(this.parentElement
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);
96 qwebirc
.ui
.StandardUI
= new Class({
97 Extends: qwebirc
.ui
.BaseUI
,
98 initialize: function(parentElement
, windowClass
, uiName
, options
) {
99 this.parent(parentElement
, windowClass
, uiName
, options
);
100 window
.addEvent("keydown", function(x
) {
101 if(!x
.alt
|| x
.control
)
104 if(x
.key
== "a" || x
.key
== "A") {
106 var highestIndex
= -1;
108 for(var i
=0;i
<this.windowArray
.length
;i
++) {
109 var h
= this.windowArray
[i
].hilighted
;
115 if(highestIndex
> -1)
116 this.selectWindow(this.windowArray
[highestIndex
]);
117 } else if(x
.key
>= '0' && x
.key
<= '9') {
120 number
= x
.key
- '0';
126 if(number
>= this.windowArray
.length
)
129 this.selectWindow(this.windowArray
[number
]);
133 newCustomWindow: function(name
, select
, type
) {
135 type
= qwebirc
.ui
.WINDOW_CUSTOM
;
137 var w
= this.newWindow(qwebirc
.ui
.CUSTOM_CLIENT
, type
, name
);
138 w
.addEvent("close", function(w
) {
139 delete this.windows
[name
];
143 this.selectWindow(w
);
147 embeddedWindow: function() {
149 this.selectWindow(this.embedded
)
153 this.embedded
= this.newCustomWindow("Embedding wizard", true);
154 this.embedded
.addEvent("close", function() {
155 this.embedded
= null;
158 var ew
= new qwebirc
.ui
.EmbedWizard({parent: this.embedded
.lines
});
159 ew
.addEvent("close", function() {
160 this.embedded
.close();
163 urlDispatcher: function(name
) {
164 if(name
== "embedded")
165 return ["a", this.embeddedWindow
.bind(this)];
171 qwebirc
.ui
.QuakeNetUI
= new Class({
172 Extends: qwebirc
.ui
.StandardUI
,
173 urlDispatcher: function(name
, window
) {
174 if(name
== "qwhois") {
175 return ["a", function(auth
) {
176 this.client
.exec("/MSG Q whois #" + auth
);
179 if(name
== "whois") {
180 return ["span", function(nick
) {
181 this.client
.exec("/WHOIS " + nick
);
185 return this.parent(name
);
189 qwebirc
.ui
.NewLoginUI
= new Class({
190 Extends: qwebirc
.ui
.QuakeNetUI
,
191 loginBox: function(callbackfn
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
192 this.postInitialize();
193 var w
= this.newCustomWindow("Connect", true, qwebirc
.ui
.WINDOW_CONNECT
);
194 var callback = function(args
) {
199 qwebirc
.ui
.GenericLoginBox(w
.lines
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);