]>
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 this.windows
[client
] = {}
29 var w
= this.newWindow(client
, qwebirc
.ui
.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
== qwebirc
.ui
.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
);
71 } else if(index
== 0) {
72 this.selectWindow(this.windowArray
[1]);
74 this.selectWindow(this.windowArray
[index
- 1]);
79 this.windowArray
= this.windowArray
.erase(window
);
80 delete this.windows
[window
.client
][window
.identifier
];
83 this shouldn't be called by overriding classes!
84 they should implement their own!
85 some form of user input MUST be received before an
86 IRC connection is made, else users are going to get
87 tricked into getting themselves glined
89 loginBox: function(callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
90 qwebirc
.ui
.GenericLoginBox(this.parentElement
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);
94 qwebirc
.ui
.StandardUI
= new Class({
95 Extends: qwebirc
.ui
.BaseUI
,
96 initialize: function(parentElement
, windowClass
, uiName
, options
) {
97 this.parent(parentElement
, windowClass
, uiName
, options
);
98 window
.addEvent("keydown", function(x
) {
99 if(!x
.alt
|| x
.control
)
102 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') {
113 number
= x
.key
- '0';
119 if(number
>= this.windowArray
.length
)
122 this.selectWindow(this.windowArray
[number
]);
126 newCustomWindow: function(name
, select
, type
) {
128 type
= qwebirc
.ui
.WINDOW_CUSTOM
;
130 var w
= this.newWindow(qwebirc
.ui
.CUSTOM_CLIENT
, type
, name
);
131 w
.addEvent("close", function(w
) {
132 delete this.windows
[name
];
136 this.selectWindow(w
);
140 embeddedWindow: function() {
142 this.selectWindow(this.embedded
)
146 this.embedded
= this.newCustomWindow("Embedding wizard", true);
147 this.embedded
.addEvent("close", function() {
148 this.embedded
= null;
151 var ew
= new qwebirc
.ui
.EmbedWizard({parent: this.embedded
.lines
});
152 ew
.addEvent("close", function() {
153 this.embedded
.close();
156 urlDispatcher: function(name
) {
157 if(name
== "embedded")
158 return this.embeddedWindow
.bind(this);
164 qwebirc
.ui
.QuakeNetUI
= new Class({
165 Extends: qwebirc
.ui
.StandardUI
,
166 urlDispatcher: function(name
, window
) {
167 if(name
== "qwhois") {
168 return function(auth
) {
169 this.client
.exec("/MSG Q whois #" + auth
);
173 return this.parent(name
);
177 qwebirc
.ui
.NewLoginUI
= new Class({
178 Extends: qwebirc
.ui
.QuakeNetUI
,
179 loginBox: function(callbackfn
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
180 this.postInitialize();
181 var w
= this.newCustomWindow("Connect", true, qwebirc
.ui
.WINDOW_CONNECT
);
182 var callback = function(args
) {
187 qwebirc
.ui
.GenericLoginBox(w
.lines
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);