]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/theme.js
add base URL support to generated stylesheet
[irc/quakenet/qwebirc.git] / js / ui / theme.js
CommitLineData
e20e5a6b 1qwebirc.ui.themes.ThemeControlCodeMap = {
9e769c12
CP
2 "C": "\x03",
3 "B": "\x02",
4 "U": "\x1F",
5 "O": "\x0F",
f121b688
CP
6 "{": "\x00",
7 "}": "\x00",
1d93b67f 8 "[": "qwebirc://whois/",
925fc357 9 "]": "/",
9e769c12
CP
10 "$": "$"
11};
12
e20e5a6b 13qwebirc.ui.themes.Default = {
9e769c12
CP
14 "PREFIX": ["$C4==$O "],
15 "SIGNON": ["Signed on!", true],
fc38a626
CP
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],
9e769c12 19 "RAW": ["$m", true],
8dc46dfa 20 "DISCONNECT": ["Disconnected from server: $m", true],
9e769c12
CP
21 "ERROR": ["ERROR: $m", true],
22 "SERVERNOTICE": ["$m", true],
f121b688
CP
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],
9f680575 31 "UMODE": ["Usermode change: $m", true],
925fc357 32 "INVITE": ["$N invites you to join $c", true],
96f28062
CP
33 "HILIGHT": ["$C4"],
34 "HILIGHTEND": ["$O"],
bd3f317a 35 "CHANMSG": ["<$C15$@$O${$($N$)$}> $m"],
925fc357 36 "PRIVMSG": ["<$($N$)> $m"],
f121b688 37 "CHANNOTICE": ["-${$($N$)$}:$c- $m"],
925fc357 38 "PRIVNOTICE": ["-$($N$)- $m"],
bd3f317a 39 "OURCHANMSG": ["<$C15$@$O$U$N$O> $m"],
4dacb477 40 "OURPRIVMSG": ["<$U$N$O> $m"],
925fc357
CP
41 "OURTARGETEDMSG": ["*$[$t$]* $m"],
42 "OURTARGETEDNOTICE": ["[notice($[$t$])] $m"],
43 "OURCHANNOTICE": ["-$N:$t- $m"],
44 "OURPRIVNOTICE": ["-$N- $m"],
4dacb477
CP
45 "OURCHANACTION": [" * $U$N$O $m"],
46 "OURPRIVACTION": [" * $U$N$O $m"],
f121b688 47 "CHANACTION": [" * ${$($N$)$} $m"],
925fc357
CP
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"],
9e769c12
CP
52 "OURCHANCTCP": ["[ctcp($t)] $x $m"],
53 "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
1d6756bc 54 "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
925fc357 55 "WHOISUSER": ["$B$N$B [$h]", true],
1d6756bc
CP
56 "WHOISREALNAME": [" realname : $m", true],
57 "WHOISCHANNELS": [" channels : $m", true],
58 "WHOISSERVER": [" server : $x [$m]", true],
2cd9e32d 59 "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true],
1d6756bc
CP
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],
a66bd43f 65 "WHOISGENERICTEXT": [" : $m", true],
1d6756bc 66 "WHOISEND": ["End of WHOIS", true],
925fc357 67 "AWAY": ["$N is away: $m", true],
574dff59 68 "GENERICERROR": ["$m: $t", true],
c270c730 69 "GENERICMESSAGE": ["$m", true],
a7048d8f
CP
70 "WALLOPS": ["WALLOP $n: $t", true],
71 "CHANNELCREATIONTIME": ["Channel $c was created at: $m", true],
b90b6d5f
CP
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],
885c7006
CP
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]
9e769c12
CP
92};
93
e20e5a6b 94qwebirc.ui.Theme = new Class({
9e769c12 95 initialize: function(themeDict) {
96f28062 96 this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
9e769c12 97
9e769c12
CP
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 }
96f28062
CP
113
114 this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
115 this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
925fc357 116
925fc357
CP
117 this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
118 this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
f121b688 119 this.__ccmaph["{"] = this.__ccmaph["}"] = "";
9e769c12 120 },
96f28062 121 __dollarSubstitute: function(x, h, mapper) {
9e769c12
CP
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
96f28062 130 var o = mapper[c2];
9e769c12
CP
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 },
96f28062
CP
142 message: function(type, data, hilight) {
143 var map;
144 if(hilight) {
145 map = this.__ccmaph;
146 } else {
147 map = this.__ccmap;
148 }
925fc357
CP
149
150 if(data && data["n"])
151 data["N"] = "qwebirc://whois/" + data.n + "/";
96f28062 152 return this.__dollarSubstitute(this.__theme[type], data, map);
9e769c12
CP
153 }
154});