]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/menuitems.js
Merge pull request #402 from retropc/reqs
[irc/quakenet/qwebirc.git] / js / ui / menuitems.js
1 qwebirc.ui.UI_COMMANDS_P1 = [
2 ["Options", "options"],
3 ["Add webchat to your site", "embedded"]
4 ];
5
6 qwebirc.ui.UI_COMMANDS_P2 = [
7 ["About qwebirc", "about"]
8 ];
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
15 return this.client.nickOnChanHasAtLeastPrefix(myNick, channel, "@");
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 isIgnored = function(nick) {
36 return this.client.isIgnored(nick);
37 };
38
39 var invert = qwebirc.util.invertFn, compose = qwebirc.util.composeAnd;
40
41 var command = function(cmd) {
42 return function(nick) { this.client.exec("/" + cmd + " " + nick); };
43 };
44
45 return [
46 {
47 text: "whois",
48 fn: command("whois"),
49 predicate: true
50 },
51 {
52 text: "query",
53 fn: command("query"),
54 predicate: true
55 },
56 {
57 text: "slap",
58 fn: function(nick) { this.client.exec("/ME slaps " + nick + " around a bit with a large fishbot"); },
59 predicate: true
60 },
61 {
62 text: "kick", /* TODO: disappear when we're deopped */
63 fn: function(nick) { this.client.exec("/KICK " + nick + " wibble"); },
64 predicate: isOpped
65 },
66 {
67 text: "op",
68 fn: command("op"),
69 predicate: compose(isOpped, invert(targetOpped))
70 },
71 {
72 text: "deop",
73 fn: command("deop"),
74 predicate: compose(isOpped, targetOpped)
75 },
76 {
77 text: "voice",
78 fn: command("voice"),
79 predicate: compose(isOpped, invert(targetVoiced))
80 },
81 {
82 text: "devoice",
83 fn: command("devoice"),
84 predicate: compose(isOpped, targetVoiced)
85 },
86 {
87 text: "ignore",
88 fn: command("ignore"),
89 predicate: invert(isIgnored)
90 },
91 {
92 text: "unignore",
93 fn: command("unignore"),
94 predicate: isIgnored
95 }
96 ];
97 }();