]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/menuitems.js
Add custom menu items.
[irc/quakenet/qwebirc.git] / js / ui / menuitems.js
CommitLineData
09f39d2e 1qwebirc.ui.UI_COMMANDS_P1 = [
f3d0c9f5 2 ["Options", "options"],
09f39d2e
CP
3 ["Add webchat to your site", "embedded"]
4];
5
6qwebirc.ui.UI_COMMANDS_P2 = [
f3d0c9f5 7 ["Feedback", "feedback"],
f3d0c9f5
CP
8 ["About qwebirc", "about"]
9];
27add99a
CP
10
11qwebirc.ui.MENU_ITEMS = function() {
12 var isOpped = function(nick) {
13 var channel = this.name; /* window name */
14 var myNick = this.client.nickname;
15
6b12b682 16 return this.client.nickOnChanHasAtLeastPrefix(myNick, channel, "@");
27add99a
CP
17 };
18
19 var isVoiced = function(nick) {
20 var channel = this.name;
21 var myNick = this.client.nickname;
22
23 return this.client.nickOnChanHasPrefix(myNick, channel, "+");
24 };
25
26 var targetOpped = function(nick) {
27 var channel = this.name;
28 return this.client.nickOnChanHasPrefix(nick, channel, "@");
29 };
30
31 var targetVoiced = function(nick) {
32 var channel = this.name;
33 return this.client.nickOnChanHasPrefix(nick, channel, "+");
34 };
35
b90b6d5f
CP
36 var isIgnored = function(nick) {
37 return this.client.isIgnored(nick);
38 };
39
27add99a
CP
40 var invert = qwebirc.util.invertFn, compose = qwebirc.util.composeAnd;
41
42 var command = function(cmd) {
43 return function(nick) { this.client.exec("/" + cmd + " " + nick); };
44 };
45
46 return [
47 {
48 text: "whois",
49 fn: command("whois"),
50 predicate: true
51 },
52 {
53 text: "query",
54 fn: command("query"),
55 predicate: true
56 },
57 {
58 text: "slap",
59 fn: function(nick) { this.client.exec("/ME slaps " + nick + " around a bit with a large fishbot"); },
60 predicate: true
61 },
62 {
63 text: "kick", /* TODO: disappear when we're deopped */
64 fn: function(nick) { this.client.exec("/KICK " + nick + " wibble"); },
65 predicate: isOpped
66 },
67 {
68 text: "op",
69 fn: command("op"),
70 predicate: compose(isOpped, invert(targetOpped))
71 },
72 {
73 text: "deop",
74 fn: command("deop"),
75 predicate: compose(isOpped, targetOpped)
76 },
77 {
78 text: "voice",
79 fn: command("voice"),
80 predicate: compose(isOpped, invert(targetVoiced))
81 },
82 {
83 text: "devoice",
84 fn: command("devoice"),
85 predicate: compose(isOpped, targetVoiced)
b90b6d5f
CP
86 },
87 {
88 text: "ignore",
89 fn: command("ignore"),
90 predicate: invert(isIgnored)
91 },
92 {
93 text: "unignore",
94 fn: command("unignore"),
95 predicate: isIgnored
27add99a
CP
96 }
97 ];
98}();