]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/menuitems.js
iframes should not have borders -- breaks page layout
[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 ["Feedback", "feedback"],
8 ["About qwebirc", "about"]
9 ];
10
11 qwebirc.ui.MENU_ITEMS = function() {
12 var isOpped = function(nick) {
13 var channel = this.name; /* window name */
14 var myNick = this.client.nickname;
15
16 return this.client.nickOnChanHasAtLeastPrefix(myNick, channel, "@");
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
36 var isIgnored = function(nick) {
37 return this.client.isIgnored(nick);
38 };
39
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)
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
96 }
97 ];
98 }();