]>
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], | |
68413dcb | 58 | "AWAY": ["$n is away: $m", true], |
574dff59 | 59 | "GENERICERROR": ["$m: $t", true], |
41cc1a57 | 60 | "GENERICMESSAGE": ["$m", true] |
9e769c12 CP |
61 | }; |
62 | ||
e20e5a6b | 63 | qwebirc.ui.Theme = new Class({ |
9e769c12 CP |
64 | initialize: function(themeDict) { |
65 | this.__theme = {}; | |
66 | ||
e20e5a6b CP |
67 | for(var k in qwebirc.ui.themes.Default) |
68 | this.__theme[k] = qwebirc.ui.themes.Default[k]; | |
9e769c12 CP |
69 | |
70 | if(themeDict) | |
71 | for(var k in themeDict) | |
72 | this.__theme[k] = themeDict[k]; | |
73 | ||
74 | for(var k in this.__theme) { | |
75 | if(k == "PREFIX") | |
76 | continue; | |
77 | ||
78 | var data = this.__theme[k]; | |
79 | if(data[1]) { | |
80 | this.__theme[k] = this.__theme["PREFIX"] + data[0]; | |
81 | } else { | |
82 | this.__theme[k] = data[0]; | |
83 | } | |
84 | } | |
85 | }, | |
86 | __dollarSubstitute: function(x, h) { | |
87 | var msg = []; | |
88 | ||
89 | var n = x.split(""); | |
90 | for(var i=0;i<n.length;i++) { | |
91 | var c = n[i]; | |
92 | if(c == "$" && (i <= n.length - 1)) { | |
93 | var c2 = n[++i]; | |
94 | ||
e20e5a6b | 95 | var o = qwebirc.ui.themes.ThemeControlCodeMap[c2]; |
9e769c12 CP |
96 | if(!o) |
97 | o = h[c2]; | |
98 | if(o) | |
99 | msg.push(o); | |
100 | } else { | |
101 | msg.push(c); | |
102 | } | |
103 | } | |
104 | ||
105 | return msg.join(""); | |
106 | }, | |
107 | message: function(type, data) { | |
108 | var msg = this.__theme[type]; | |
109 | ||
110 | msg = this.__dollarSubstitute(msg, data); | |
111 | ||
112 | return msg; | |
113 | } | |
114 | }); |