]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/theme.js
Belt and braces against flashing overload, also fix a bug in auth in conventional...
[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",
1d93b67f 6 "[": "qwebirc://whois/",
925fc357 7 "]": "/",
9e769c12
CP
8 "$": "$"
9};
10
e20e5a6b 11qwebirc.ui.themes.Default = {
9e769c12
CP
12 "PREFIX": ["$C4==$O "],
13 "SIGNON": ["Signed on!", true],
14 "CONNECT": ["Connected to server.", true],
15 "RAW": ["$m", true],
8dc46dfa 16 "DISCONNECT": ["Disconnected from server: $m", true],
9e769c12
CP
17 "ERROR": ["ERROR: $m", true],
18 "SERVERNOTICE": ["$m", true],
925fc357
CP
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],
9f680575 27 "UMODE": ["Usermode change: $m", true],
925fc357 28 "INVITE": ["$N invites you to join $c", true],
96f28062
CP
29 "HILIGHT": ["$C4"],
30 "HILIGHTEND": ["$O"],
c6b78d06 31 "CHANMSG": ["<$@$($N$)> $m"],
925fc357
CP
32 "PRIVMSG": ["<$($N$)> $m"],
33 "CHANNOTICE": ["-$($N$):$c- $m"],
34 "PRIVNOTICE": ["-$($N$)- $m"],
766d8216
CP
35 "OURCHANMSG": ["<$B$@$N$B> $m"],
36 "OURPRIVMSG": ["<$B$N$B> $m"],
925fc357
CP
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"],
9e769c12
CP
48 "OURCHANCTCP": ["[ctcp($t)] $x $m"],
49 "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
1d6756bc 50 "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
925fc357 51 "WHOISUSER": ["$B$N$B [$h]", true],
1d6756bc
CP
52 "WHOISREALNAME": [" realname : $m", true],
53 "WHOISCHANNELS": [" channels : $m", true],
54 "WHOISSERVER": [" server : $x [$m]", true],
2cd9e32d 55 "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true],
1d6756bc
CP
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],
a66bd43f 61 "WHOISGENERICTEXT": [" : $m", true],
1d6756bc 62 "WHOISEND": ["End of WHOIS", true],
925fc357 63 "AWAY": ["$N is away: $m", true],
574dff59 64 "GENERICERROR": ["$m: $t", true],
c270c730 65 "GENERICMESSAGE": ["$m", true],
a7048d8f
CP
66 "WALLOPS": ["WALLOP $n: $t", true],
67 "CHANNELCREATIONTIME": ["Channel $c was created at: $m", true],
68 "CHANNELMODEIS": ["Channel modes on $c are: $m", true]
9e769c12
CP
69};
70
e20e5a6b 71qwebirc.ui.Theme = new Class({
9e769c12 72 initialize: function(themeDict) {
96f28062 73 this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
9e769c12 74
9e769c12
CP
75 if(themeDict)
76 for(var k in themeDict)
77 this.__theme[k] = themeDict[k];
78
79 for(var k in this.__theme) {
80 if(k == "PREFIX")
81 continue;
82
83 var data = this.__theme[k];
84 if(data[1]) {
85 this.__theme[k] = this.__theme["PREFIX"] + data[0];
86 } else {
87 this.__theme[k] = data[0];
88 }
89 }
96f28062
CP
90
91 this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
92 this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
925fc357
CP
93
94 this.__ccmap["("] = "";
95 this.__ccmap[")"] = "";
96f28062 96
925fc357
CP
97 this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
98 this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
9e769c12 99 },
96f28062 100 __dollarSubstitute: function(x, h, mapper) {
9e769c12
CP
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
96f28062 109 var o = mapper[c2];
9e769c12
CP
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 },
96f28062
CP
121 message: function(type, data, hilight) {
122 var map;
123 if(hilight) {
124 map = this.__ccmaph;
125 } else {
126 map = this.__ccmap;
127 }
925fc357
CP
128
129 if(data && data["n"])
130 data["N"] = "qwebirc://whois/" + data.n + "/";
96f28062 131 return this.__dollarSubstitute(this.__theme[type], data, map);
9e769c12
CP
132 }
133});