]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/theme.js
Merge.
[irc/quakenet/qwebirc.git] / js / ui / theme.js
1 qwebirc.ui.themes.ThemeControlCodeMap = {
2 "C": "\x03",
3 "B": "\x02",
4 "U": "\x1F",
5 "O": "\x0F",
6 "[": "qwebirc://whois/",
7 "]": "/",
8 "$": "$"
9 };
10
11 qwebirc.ui.themes.Default = {
12 "PREFIX": ["$C4==$O "],
13 "SIGNON": ["Signed on!", true],
14 "CONNECT": ["Connected to server.", true],
15 "RAW": ["$m", true],
16 "DISCONNECT": ["Disconnected from server: $m", true],
17 "ERROR": ["ERROR: $m", true],
18 "SERVERNOTICE": ["$m", true],
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],
27 "UMODE": ["Usermode change: $m", true],
28 "INVITE": ["$N invites you to join $c", true],
29 "HILIGHT": ["$C4"],
30 "HILIGHTEND": ["$O"],
31 "CHANMSG": ["<$@$($N$)> $m"],
32 "PRIVMSG": ["<$($N$)> $m"],
33 "CHANNOTICE": ["-$($N$):$c- $m"],
34 "PRIVNOTICE": ["-$($N$)- $m"],
35 "OURCHANMSG": ["<$@$N> $m"],
36 "OURPRIVMSG": ["<$N> $m"],
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"],
48 "OURCHANCTCP": ["[ctcp($t)] $x $m"],
49 "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
50 "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
51 "WHOISUSER": ["$B$N$B [$h]", true],
52 "WHOISREALNAME": [" realname : $m", true],
53 "WHOISCHANNELS": [" channels : $m", true],
54 "WHOISSERVER": [" server : $x [$m]", true],
55 "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true],
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],
61 "WHOISEND": ["End of WHOIS", true],
62 "AWAY": ["$N is away: $m", true],
63 "GENERICERROR": ["$m: $t", true],
64 "GENERICMESSAGE": ["$m", true],
65 "WALLOPS": ["WALLOP $n: $t", true]
66 };
67
68 qwebirc.ui.Theme = new Class({
69 initialize: function(themeDict) {
70 this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
71
72 if(themeDict)
73 for(var k in themeDict)
74 this.__theme[k] = themeDict[k];
75
76 for(var k in this.__theme) {
77 if(k == "PREFIX")
78 continue;
79
80 var data = this.__theme[k];
81 if(data[1]) {
82 this.__theme[k] = this.__theme["PREFIX"] + data[0];
83 } else {
84 this.__theme[k] = data[0];
85 }
86 }
87
88 this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
89 this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
90
91 this.__ccmap["("] = "";
92 this.__ccmap[")"] = "";
93
94 this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
95 this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
96 },
97 __dollarSubstitute: function(x, h, mapper) {
98 var msg = [];
99
100 var n = x.split("");
101 for(var i=0;i<n.length;i++) {
102 var c = n[i];
103 if(c == "$" && (i <= n.length - 1)) {
104 var c2 = n[++i];
105
106 var o = mapper[c2];
107 if(!o)
108 o = h[c2];
109 if(o)
110 msg.push(o);
111 } else {
112 msg.push(c);
113 }
114 }
115
116 return msg.join("");
117 },
118 message: function(type, data, hilight) {
119 var map;
120 if(hilight) {
121 map = this.__ccmaph;
122 } else {
123 map = this.__ccmap;
124 }
125
126 if(data && data["n"])
127 data["N"] = "qwebirc://whois/" + data.n + "/";
128 return this.__dollarSubstitute(this.__theme[type], data, map);
129 }
130 });