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