]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseui.js
1aadf51645cda569a38c65890761401e56df9981
3 var WINDOW_CHANNEL
= 3;
5 var BaseUI
= new Class({
6 Implements: [Events
, Options
],
8 appTitle: "QuakeNet Web IRC",
11 initialize: function(parentElement
, windowClass
, uiName
, options
) {
12 this.setOptions(options
);
15 this.windowArray
= [];
16 this.windowClass
= windowClass
;
17 this.parentElement
= parentElement
;
18 this.parentElement
.addClass("qwebirc");
19 this.parentElement
.addClass("qwebirc-" + uiName
);
20 this.firstClient
= false;
21 this.commandhistory
= new CommandHistory();
23 newClient: function(client
) {
24 this.windows
[client
] = {}
25 var w
= this.newWindow(client
, WINDOW_STATUS
, "Status");
27 if(!this.firstClient
) {
28 this.firstClient
= true;
29 w
.addLine("", "qwebirc v" + QWEBIRC_VERSION
);
30 w
.addLine("", "Copyright (C) 2008 Chris Porter. All rights reserved.");
31 w
.addLine("", "http://webchat.quakenet.org/");
32 w
.addLine("", "This is BETA quality software, please report bugs to slug@quakenet.org");
36 newWindow: function(client
, type
, name
) {
37 var identifier
= name
;
38 if(type
== WINDOW_STATUS
)
41 var w
= this.windows
[client
][identifier
] = new this.windowClass(this, client
, type
, name
, identifier
);
42 this.windowArray
.push(w
);
46 getActiveWindow: function() {
49 __setActiveWindow: function(window
) {
52 selectWindow: function(window
) {
54 this.active
.deselect();
55 window
.select(); /* calls setActiveWindow */
56 document
.title
= window
.name
+ " - " + this.options
.appTitle
;
58 __closed: function(window
) {
60 this.active
= undefined;
61 if(this.windowArray
.length
== 1) {
62 this.windowArray
= [];
64 var index
= this.windowArray
.indexOf(window
);
66 this.selectWindow(this.windowArray
[1]);
68 this.selectWindow(this.windowArray
[index
- 1]);
71 this.windowArray
= this.windowArray
.erase(window
);
75 delete this.windows
[window
.client
][window
.identifier
];
78 this shouldn't be called by overriding classes!
79 they should implement their own!
80 some form of user input MUST be received before an
81 IRC connection is made, else users are going to get
82 tricked into getting themselves glined
84 loginBox: function(callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
) {
85 GenericLoginBox(this.parentElement
, callback
, initialNickname
, initialChannels
, autoConnect
, autoNick
);
87 var c = initialChannels.split(",");
92 ctext = c.join(", ") + " and " + last;
101 nicktext = " (as '" + initialNickname + "')"
103 if(confirm("Connect to IRC and join channels " + ctext + nicktext + "?"))
104 callback({"nickname": initialNickname, "autojoin": initialChannels});
108 var nick = prompt("Nickname:", initialNickname);
114 var chans = prompt("Channels (seperate by comma):", initialChannels);
115 callback({"nickname": nick, "autojoin": chans});
122 initialize: function(parentElement
, windowClass
, uiName
, options
) {
123 this.parent(parentElement
, windowClass
, uiName
, options
);
124 window
.addEvent("keydown", function(x
) {
128 if(x
.key
== "a" || x
.key
== "A") {
130 for(var i
=0;i
<this.windowArray
.length
;i
++) {
131 if(this.windowArray
[i
].hilighted
) {
132 this.selectWindow(this.windowArray
[i
]);
136 } else if(x
.key
>= '0' && x
.key
<= '9') {
139 number
= x
.key
- '0';
145 if(number
>= this.windowArray
.length
)
148 this.selectWindow(this.windowArray
[number
]);
152 urlDispatcher: function(name
) {
153 if(name
== "embedded") {