]>
Commit | Line | Data |
---|---|---|
f3d0c9f5 CP |
1 | qwebirc.ui.UI_COMMANDS = [ |
2 | ["Options", "options"], | |
3 | ["Add webchat to your site", "embedded"], | |
4 | ["Privacy policy", "privacy"], | |
5 | ["Feedback", "feedback"], | |
6 | ["Frequently asked questions", "faq"], | |
7 | ["About qwebirc", "about"] | |
8 | ]; | |
27add99a CP |
9 | |
10 | qwebirc.ui.MENU_ITEMS = function() { | |
11 | var isOpped = function(nick) { | |
12 | var channel = this.name; /* window name */ | |
13 | var myNick = this.client.nickname; | |
14 | ||
6b12b682 | 15 | return this.client.nickOnChanHasAtLeastPrefix(myNick, channel, "@"); |
27add99a CP |
16 | }; |
17 | ||
18 | var isVoiced = function(nick) { | |
19 | var channel = this.name; | |
20 | var myNick = this.client.nickname; | |
21 | ||
22 | return this.client.nickOnChanHasPrefix(myNick, channel, "+"); | |
23 | }; | |
24 | ||
25 | var targetOpped = function(nick) { | |
26 | var channel = this.name; | |
27 | return this.client.nickOnChanHasPrefix(nick, channel, "@"); | |
28 | }; | |
29 | ||
30 | var targetVoiced = function(nick) { | |
31 | var channel = this.name; | |
32 | return this.client.nickOnChanHasPrefix(nick, channel, "+"); | |
33 | }; | |
34 | ||
35 | var invert = qwebirc.util.invertFn, compose = qwebirc.util.composeAnd; | |
36 | ||
37 | var command = function(cmd) { | |
38 | return function(nick) { this.client.exec("/" + cmd + " " + nick); }; | |
39 | }; | |
40 | ||
41 | return [ | |
42 | { | |
43 | text: "whois", | |
44 | fn: command("whois"), | |
45 | predicate: true | |
46 | }, | |
47 | { | |
48 | text: "query", | |
49 | fn: command("query"), | |
50 | predicate: true | |
51 | }, | |
52 | { | |
53 | text: "slap", | |
54 | fn: function(nick) { this.client.exec("/ME slaps " + nick + " around a bit with a large fishbot"); }, | |
55 | predicate: true | |
56 | }, | |
57 | { | |
58 | text: "kick", /* TODO: disappear when we're deopped */ | |
59 | fn: function(nick) { this.client.exec("/KICK " + nick + " wibble"); }, | |
60 | predicate: isOpped | |
61 | }, | |
62 | { | |
63 | text: "op", | |
64 | fn: command("op"), | |
65 | predicate: compose(isOpped, invert(targetOpped)) | |
66 | }, | |
67 | { | |
68 | text: "deop", | |
69 | fn: command("deop"), | |
70 | predicate: compose(isOpped, targetOpped) | |
71 | }, | |
72 | { | |
73 | text: "voice", | |
74 | fn: command("voice"), | |
75 | predicate: compose(isOpped, invert(targetVoiced)) | |
76 | }, | |
77 | { | |
78 | text: "devoice", | |
79 | fn: command("devoice"), | |
80 | predicate: compose(isOpped, targetVoiced) | |
81 | } | |
82 | ]; | |
83 | }(); |