]>
Commit | Line | Data |
---|---|---|
1 | var QWebIRCInterface = new Class({ | |
2 | Implements: [Options], | |
3 | options: { | |
4 | initialNickname: "qwebirc" + Math.ceil(Math.random() * 100000), | |
5 | initialChannels: "", | |
6 | searchURL: true, | |
7 | theme: undefined | |
8 | }, | |
9 | initialize: function(element, ui, options) { | |
10 | this.setOptions(options); | |
11 | ||
12 | window.addEvent("domready", function() { | |
13 | var ui_ = new ui($(element), new Theme(this.options.theme)); | |
14 | var inick = this.options.initialNickname; | |
15 | var ichans = this.options.initialChannels; | |
16 | var autoNick = true; | |
17 | ||
18 | var callback = function(options) { | |
19 | var IRC = new IRCClient(options, ui_); | |
20 | IRC.connect(); | |
21 | window.addEvent("beforeunload", function() { | |
22 | IRC.quit("Page closed"); | |
23 | }); | |
24 | }; | |
25 | ||
26 | var supplied = false; | |
27 | if(this.options.searchURL) { | |
28 | var args = parseURI(String(document.location)); | |
29 | ||
30 | var chans = args["channels"]; | |
31 | var nick = args["nick"]; | |
32 | ||
33 | if(chans) { | |
34 | chans = chans.split(","); | |
35 | var chans2 = []; | |
36 | ||
37 | for(i=0;i<chans.length;i++) { | |
38 | chans2[i] = chans[i]; | |
39 | ||
40 | if(chans[i].charAt(0) != '#') | |
41 | chans2[i] = "#" + chans2[i] | |
42 | } | |
43 | ichans = chans2.join(","); | |
44 | supplied = true; | |
45 | } | |
46 | ||
47 | if(nick) { | |
48 | inick = nick; | |
49 | autoNick = false; | |
50 | } | |
51 | } | |
52 | ||
53 | var details = ui_.loginBox(callback, inick, ichans, supplied, autoNick); | |
54 | }.bind(this)); | |
55 | } | |
56 | }); |