]>
Commit | Line | Data |
---|---|---|
1 | qwebirc.ui.themes.ThemeControlCodeMap = { | |
2 | "C": "\x03", | |
3 | "B": "\x02", | |
4 | "U": "\x1F", | |
5 | "O": "\x0F", | |
6 | "{": "\x00", | |
7 | "}": "\x00", | |
8 | "[": "qwebirc://whois/", | |
9 | "]": "/", | |
10 | "$": "$" | |
11 | }; | |
12 | ||
13 | qwebirc.ui.themes.Default = { | |
14 | "PREFIX": ["$C4==$O "], | |
15 | "SIGNON": ["Signed on!", true], | |
16 | "CONNECT": ["Connected to server.", true], | |
17 | "RAW": ["$m", true], | |
18 | "DISCONNECT": ["Disconnected from server: $m", true], | |
19 | "ERROR": ["ERROR: $m", true], | |
20 | "SERVERNOTICE": ["$m", true], | |
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], | |
29 | "UMODE": ["Usermode change: $m", true], | |
30 | "INVITE": ["$N invites you to join $c", true], | |
31 | "HILIGHT": ["$C4"], | |
32 | "HILIGHTEND": ["$O"], | |
33 | "CHANMSG": ["<${$@$($N$)$}> $m"], | |
34 | "PRIVMSG": ["<$($N$)> $m"], | |
35 | "CHANNOTICE": ["-${$($N$)$}:$c- $m"], | |
36 | "PRIVNOTICE": ["-$($N$)- $m"], | |
37 | "OURCHANMSG": ["<$@$N> $m"], | |
38 | "OURPRIVMSG": ["<$N> $m"], | |
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"], | |
45 | "CHANACTION": [" * ${$($N$)$} $m"], | |
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"], | |
50 | "OURCHANCTCP": ["[ctcp($t)] $x $m"], | |
51 | "OURPRIVCTCP": ["[ctcp($t)] $x $m"], | |
52 | "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"], | |
53 | "WHOISUSER": ["$B$N$B [$h]", true], | |
54 | "WHOISREALNAME": [" realname : $m", true], | |
55 | "WHOISCHANNELS": [" channels : $m", true], | |
56 | "WHOISSERVER": [" server : $x [$m]", true], | |
57 | "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true], | |
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], | |
63 | "WHOISGENERICTEXT": [" : $m", true], | |
64 | "WHOISEND": ["End of WHOIS", true], | |
65 | "AWAY": ["$N is away: $m", true], | |
66 | "GENERICERROR": ["$m: $t", true], | |
67 | "GENERICMESSAGE": ["$m", true], | |
68 | "WALLOPS": ["WALLOP $n: $t", true], | |
69 | "CHANNELCREATIONTIME": ["Channel $c was created at: $m", true], | |
70 | "CHANNELMODEIS": ["Channel modes on $c are: $m", true] | |
71 | }; | |
72 | ||
73 | qwebirc.ui.Theme = new Class({ | |
74 | initialize: function(themeDict) { | |
75 | this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default); | |
76 | ||
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 | } | |
92 | ||
93 | this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap); | |
94 | this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap); | |
95 | ||
96 | this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap); | |
97 | this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap); | |
98 | this.__ccmaph["{"] = this.__ccmaph["}"] = ""; | |
99 | }, | |
100 | __dollarSubstitute: function(x, h, mapper) { | |
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 | ||
109 | var o = mapper[c2]; | |
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 | }, | |
121 | message: function(type, data, hilight) { | |
122 | var map; | |
123 | if(hilight) { | |
124 | map = this.__ccmaph; | |
125 | } else { | |
126 | map = this.__ccmap; | |
127 | } | |
128 | ||
129 | if(data && data["n"]) | |
130 | data["N"] = "qwebirc://whois/" + data.n + "/"; | |
131 | return this.__dollarSubstitute(this.__theme[type], data, map); | |
132 | } | |
133 | }); |