]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/theme.js
enhancements:
[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"],
f121b688 35 "CHANMSG": ["<${$@$($N$)$}> $m"],
925fc357 36 "PRIVMSG": ["<$($N$)> $m"],
f121b688 37 "CHANNOTICE": ["-${$($N$)$}:$c- $m"],
925fc357 38 "PRIVNOTICE": ["-$($N$)- $m"],
f121b688
CP
39 "OURCHANMSG": ["<$@$N> $m"],
40 "OURPRIVMSG": ["<$N> $m"],
925fc357
CP
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"],
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],
72 "CHANNELMODEIS": ["Channel modes on $c are: $m", true]
9e769c12
CP
73};
74
e20e5a6b 75qwebirc.ui.Theme = new Class({
9e769c12 76 initialize: function(themeDict) {
96f28062 77 this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
9e769c12 78
9e769c12
CP
79 if(themeDict)
80 for(var k in themeDict)
81 this.__theme[k] = themeDict[k];
82
83 for(var k in this.__theme) {
84 if(k == "PREFIX")
85 continue;
86
87 var data = this.__theme[k];
88 if(data[1]) {
89 this.__theme[k] = this.__theme["PREFIX"] + data[0];
90 } else {
91 this.__theme[k] = data[0];
92 }
93 }
96f28062
CP
94
95 this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
96 this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
925fc357 97
925fc357
CP
98 this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
99 this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
f121b688 100 this.__ccmaph["{"] = this.__ccmaph["}"] = "";
9e769c12 101 },
96f28062 102 __dollarSubstitute: function(x, h, mapper) {
9e769c12
CP
103 var msg = [];
104
105 var n = x.split("");
106 for(var i=0;i<n.length;i++) {
107 var c = n[i];
108 if(c == "$" && (i <= n.length - 1)) {
109 var c2 = n[++i];
110
96f28062 111 var o = mapper[c2];
9e769c12
CP
112 if(!o)
113 o = h[c2];
114 if(o)
115 msg.push(o);
116 } else {
117 msg.push(c);
118 }
119 }
120
121 return msg.join("");
122 },
96f28062
CP
123 message: function(type, data, hilight) {
124 var map;
125 if(hilight) {
126 map = this.__ccmaph;
127 } else {
128 map = this.__ccmap;
129 }
925fc357
CP
130
131 if(data && data["n"])
132 data["N"] = "qwebirc://whois/" + data.n + "/";
96f28062 133 return this.__dollarSubstitute(this.__theme[type], data, map);
9e769c12
CP
134 }
135});