]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/theme.js
notifier now uses themes
[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 "{": "\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 "CONNECTING": ["Connecting to server, please wait...", true],
17 "CONNECT": ["Logging in, please wait...", true],
18 "CONNECTED": ["Connected and logged in -- ready to go!", true],
19 "RAW": ["$m", true],
20 "DISCONNECT": ["Disconnected from server: $m", true],
21 "ERROR": ["ERROR: $m", true],
22 "SERVERNOTICE": ["$m", true],
23 "JOIN": ["${$N$} [$h] has joined $c", true],
24 "OURJOIN": ["${$N$} [$h] has joined $c", true],
25 "PART": ["${$N$} [$h] has left $c [$m]", true],
26 "KICK": ["${$v$} was kicked from $c by ${$N$} [$m]", true],
27 "MODE": ["mode/$c [$m] by ${$N$}", true],
28 "QUIT": ["${$N$} [$h] has quit [$m]", true],
29 "NICK": ["${$n$} has changed nick to ${$[$w$]$}", true],
30 "TOPIC": ["${$N$} changed the topic of $c to: $m", true],
31 "UMODE": ["Usermode change: $m", true],
32 "INVITE": ["$N invites you to join $c", true],
33 "HILIGHT": ["$C4"],
34 "HILIGHTEND": ["$O"],
35 "CHANMSG": ["<${$@$($N$)$}> $m"],
36 "PRIVMSG": ["<$($N$)> $m"],
37 "CHANNOTICE": ["-${$($N$)$}:$c- $m"],
38 "PRIVNOTICE": ["-$($N$)- $m"],
39 "OURCHANMSG": ["<$@$N> $m"],
40 "OURPRIVMSG": ["<$N> $m"],
41 "OURTARGETEDMSG": ["*$[$t$]* $m"],
42 "OURTARGETEDNOTICE": ["[notice($[$t$])] $m"],
43 "OURCHANNOTICE": ["-$N:$t- $m"],
44 "OURPRIVNOTICE": ["-$N- $m"],
45 "OURCHANACTION": [" * $N $m"],
46 "OURPRIVACTION": [" * $N $m"],
47 "CHANACTION": [" * ${$($N$)$} $m"],
48 "PRIVACTION": [" * $($N$) $m"],
49 "CHANCTCP": ["$N [$h] requested CTCP $x from $c: $m"],
50 "PRIVCTCP": ["$N [$h] requested CTCP $x from $-: $m"],
51 "CTCPREPLY": ["CTCP $x reply from $N: $m"],
52 "OURCHANCTCP": ["[ctcp($t)] $x $m"],
53 "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
54 "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
55 "WHOISUSER": ["$B$N$B [$h]", true],
56 "WHOISREALNAME": [" realname : $m", true],
57 "WHOISCHANNELS": [" channels : $m", true],
58 "WHOISSERVER": [" server : $x [$m]", true],
59 "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true],
60 "WHOISIDLE": [" idle : $x [connected: $m]", true],
61 "WHOISAWAY": [" away : $m", true],
62 "WHOISOPER": [" : $BIRC Operator$B", true],
63 "WHOISOPERNAME": [" operedas : $m", true],
64 "WHOISACTUALLY": [" realhost : $m [ip: $x]", true],
65 "WHOISGENERICTEXT": [" : $m", true],
66 "WHOISEND": ["End of WHOIS", true],
67 "AWAY": ["$N is away: $m", true],
68 "GENERICERROR": ["$m: $t", true],
69 "GENERICMESSAGE": ["$m", true],
70 "WALLOPS": ["WALLOP $n: $t", true],
71 "CHANNELCREATIONTIME": ["Channel $c was created at: $m", true],
72 "CHANNELMODEIS": ["Channel modes on $c are: $m", true],
73 "IGNORED": ["Ignored $n, to unignore type: /UNIGNORE $n", false],
74 "UNIGNORED": ["Unignored $n.", false],
75 "IGNOREHEADER": ["Ignore list:", false],
76 "IGNOREENTRY": ["- $h", false],
77 "IGNOREEMPTY": ["Ignore list is empty.", false],
78 "SILENCE": ["Silenced: $h", false],
79
80 "NOTIFYCHANMSGTITLE": ["Mentioned on $c:", false],
81 "NOTIFYCHANMSGBODY": ["<$@$n> $m", false],
82 "NOTIFYCHANACTIONTITLE": ["Mentioned on $c:", false],
83 "NOTIFYCHANACTIONBODY": [" * $n $m", false],
84 "NOTIFYPRIVMSGTITLE": ["Private message from $n:", false],
85 "NOTIFYPRIVMSGBODY": ["$m", false],
86 "NOTIFYPRIVACTIONTITLE": ["Private message from $n:", false],
87 "NOTIFYPRIVACTIONBODY": [" * $n $m", false],
88 "NOTIFYCHANNOTICETITLE": ["Mentioned on $c:", false],
89 "NOTIFYCHANNOTICEBODY": ["-$n- $m", false],
90 "NOTIFYPRIVNOTICETITLE": ["Private notice from $n:", false],
91 "NOTIFYPRIVNOTICEBODY": ["$m", false]
92 };
93
94 qwebirc.ui.Theme = new Class({
95 initialize: function(themeDict) {
96 this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
97
98 if(themeDict)
99 for(var k in themeDict)
100 this.__theme[k] = themeDict[k];
101
102 for(var k in this.__theme) {
103 if(k == "PREFIX")
104 continue;
105
106 var data = this.__theme[k];
107 if(data[1]) {
108 this.__theme[k] = this.__theme["PREFIX"] + data[0];
109 } else {
110 this.__theme[k] = data[0];
111 }
112 }
113
114 this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
115 this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
116
117 this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
118 this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
119 this.__ccmaph["{"] = this.__ccmaph["}"] = "";
120 },
121 __dollarSubstitute: function(x, h, mapper) {
122 var msg = [];
123
124 var n = x.split("");
125 for(var i=0;i<n.length;i++) {
126 var c = n[i];
127 if(c == "$" && (i <= n.length - 1)) {
128 var c2 = n[++i];
129
130 var o = mapper[c2];
131 if(!o)
132 o = h[c2];
133 if(o)
134 msg.push(o);
135 } else {
136 msg.push(c);
137 }
138 }
139
140 return msg.join("");
141 },
142 message: function(type, data, hilight) {
143 var map;
144 if(hilight) {
145 map = this.__ccmaph;
146 } else {
147 map = this.__ccmap;
148 }
149
150 if(data && data["n"])
151 data["N"] = "qwebirc://whois/" + data.n + "/";
152 return this.__dollarSubstitute(this.__theme[type], data, map);
153 }
154 });