]>
Commit | Line | Data |
---|---|---|
e20e5a6b | 1 | qwebirc.ui.themes.ThemeControlCodeMap = { |
9e769c12 CP |
2 | "C": "\x03", |
3 | "B": "\x02", | |
4 | "U": "\x1F", | |
5 | "O": "\x0F", | |
1d93b67f | 6 | "[": "qwebirc://whois/", |
925fc357 | 7 | "]": "/", |
9e769c12 CP |
8 | "$": "$" |
9 | }; | |
10 | ||
e20e5a6b | 11 | qwebirc.ui.themes.Default = { |
9e769c12 CP |
12 | "PREFIX": ["$C4==$O "], |
13 | "SIGNON": ["Signed on!", true], | |
14 | "CONNECT": ["Connected to server.", true], | |
15 | "RAW": ["$m", true], | |
8dc46dfa | 16 | "DISCONNECT": ["Disconnected from server: $m", true], |
9e769c12 CP |
17 | "ERROR": ["ERROR: $m", true], |
18 | "SERVERNOTICE": ["$m", true], | |
925fc357 CP |
19 | "JOIN": ["$N [$h] has joined $c", true], |
20 | "OURJOIN": ["$N [$h] has joined $c", true], | |
21 | "PART": ["$N [$h] has left $c [$m]", true], | |
22 | "KICK": ["$v was kicked from $c by $N [$m]", true], | |
23 | "MODE": ["mode/$c [$m] by $N", true], | |
24 | "QUIT": ["$N [$h] has quit [$m]", true], | |
25 | "NICK": ["$n has changed nick to $[$w$]", true], | |
26 | "TOPIC": ["$N changed the topic of $c to: $m", true], | |
9f680575 | 27 | "UMODE": ["Usermode change: $m", true], |
925fc357 | 28 | "INVITE": ["$N invites you to join $c", true], |
96f28062 CP |
29 | "HILIGHT": ["$C4"], |
30 | "HILIGHTEND": ["$O"], | |
c6b78d06 | 31 | "CHANMSG": ["<$@$($N$)> $m"], |
925fc357 CP |
32 | "PRIVMSG": ["<$($N$)> $m"], |
33 | "CHANNOTICE": ["-$($N$):$c- $m"], | |
34 | "PRIVNOTICE": ["-$($N$)- $m"], | |
766d8216 CP |
35 | "OURCHANMSG": ["<$B$@$N$B> $m"], |
36 | "OURPRIVMSG": ["<$B$N$B> $m"], | |
925fc357 CP |
37 | "OURTARGETEDMSG": ["*$[$t$]* $m"], |
38 | "OURTARGETEDNOTICE": ["[notice($[$t$])] $m"], | |
39 | "OURCHANNOTICE": ["-$N:$t- $m"], | |
40 | "OURPRIVNOTICE": ["-$N- $m"], | |
41 | "OURCHANACTION": [" * $N $m"], | |
42 | "OURPRIVACTION": [" * $N $m"], | |
43 | "CHANACTION": [" * $($N$) $m"], | |
44 | "PRIVACTION": [" * $($N$) $m"], | |
45 | "CHANCTCP": ["$N [$h] requested CTCP $x from $c: $m"], | |
46 | "PRIVCTCP": ["$N [$h] requested CTCP $x from $-: $m"], | |
47 | "CTCPREPLY": ["CTCP $x reply from $N: $m"], | |
9e769c12 CP |
48 | "OURCHANCTCP": ["[ctcp($t)] $x $m"], |
49 | "OURPRIVCTCP": ["[ctcp($t)] $x $m"], | |
1d6756bc | 50 | "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"], |
925fc357 | 51 | "WHOISUSER": ["$B$N$B [$h]", true], |
1d6756bc CP |
52 | "WHOISREALNAME": [" realname : $m", true], |
53 | "WHOISCHANNELS": [" channels : $m", true], | |
54 | "WHOISSERVER": [" server : $x [$m]", true], | |
2cd9e32d | 55 | "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true], |
1d6756bc CP |
56 | "WHOISIDLE": [" idle : $x [connected: $m]", true], |
57 | "WHOISAWAY": [" away : $m", true], | |
58 | "WHOISOPER": [" : $BIRC Operator$B", true], | |
59 | "WHOISOPERNAME": [" operedas : $m", true], | |
60 | "WHOISACTUALLY": [" realhost : $m [ip: $x]", true], | |
a66bd43f | 61 | "WHOISGENERICTEXT": [" : $m", true], |
1d6756bc | 62 | "WHOISEND": ["End of WHOIS", true], |
925fc357 | 63 | "AWAY": ["$N is away: $m", true], |
574dff59 | 64 | "GENERICERROR": ["$m: $t", true], |
c270c730 CP |
65 | "GENERICMESSAGE": ["$m", true], |
66 | "WALLOPS": ["WALLOP $n: $t", true] | |
9e769c12 CP |
67 | }; |
68 | ||
e20e5a6b | 69 | qwebirc.ui.Theme = new Class({ |
9e769c12 | 70 | initialize: function(themeDict) { |
96f28062 | 71 | this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default); |
9e769c12 | 72 | |
9e769c12 CP |
73 | if(themeDict) |
74 | for(var k in themeDict) | |
75 | this.__theme[k] = themeDict[k]; | |
76 | ||
77 | for(var k in this.__theme) { | |
78 | if(k == "PREFIX") | |
79 | continue; | |
80 | ||
81 | var data = this.__theme[k]; | |
82 | if(data[1]) { | |
83 | this.__theme[k] = this.__theme["PREFIX"] + data[0]; | |
84 | } else { | |
85 | this.__theme[k] = data[0]; | |
86 | } | |
87 | } | |
96f28062 CP |
88 | |
89 | this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap); | |
90 | this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap); | |
925fc357 CP |
91 | |
92 | this.__ccmap["("] = ""; | |
93 | this.__ccmap[")"] = ""; | |
96f28062 | 94 | |
925fc357 CP |
95 | this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap); |
96 | this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap); | |
9e769c12 | 97 | }, |
96f28062 | 98 | __dollarSubstitute: function(x, h, mapper) { |
9e769c12 CP |
99 | var msg = []; |
100 | ||
101 | var n = x.split(""); | |
102 | for(var i=0;i<n.length;i++) { | |
103 | var c = n[i]; | |
104 | if(c == "$" && (i <= n.length - 1)) { | |
105 | var c2 = n[++i]; | |
106 | ||
96f28062 | 107 | var o = mapper[c2]; |
9e769c12 CP |
108 | if(!o) |
109 | o = h[c2]; | |
110 | if(o) | |
111 | msg.push(o); | |
112 | } else { | |
113 | msg.push(c); | |
114 | } | |
115 | } | |
116 | ||
117 | return msg.join(""); | |
118 | }, | |
96f28062 CP |
119 | message: function(type, data, hilight) { |
120 | var map; | |
121 | if(hilight) { | |
122 | map = this.__ccmaph; | |
123 | } else { | |
124 | map = this.__ccmap; | |
125 | } | |
925fc357 CP |
126 | |
127 | if(data && data["n"]) | |
128 | data["N"] = "qwebirc://whois/" + data.n + "/"; | |
96f28062 | 129 | return this.__dollarSubstitute(this.__theme[type], data, map); |
9e769c12 CP |
130 | } |
131 | }); |