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