]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/theme.js
Menu closing suggestion from Microbe.
[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",
6 "$": "$"
7};
8
e20e5a6b 9qwebirc.ui.themes.Default = {
9e769c12
CP
10 "PREFIX": ["$C4==$O "],
11 "SIGNON": ["Signed on!", true],
12 "CONNECT": ["Connected to server.", true],
13 "RAW": ["$m", true],
8dc46dfa 14 "DISCONNECT": ["Disconnected from server: $m", true],
9e769c12
CP
15 "ERROR": ["ERROR: $m", true],
16 "SERVERNOTICE": ["$m", true],
17 "JOIN": ["$n [$h] has joined $c", true],
ebb220d3 18 "OURJOIN": ["$n [$h] has joined $c", true],
9e769c12
CP
19 "PART": ["$n [$h] has left $c [$m]", true],
20 "KICK": ["$v was kicked from $c by $n [$m]", true],
21 "MODE": ["mode/$c [$m] by $n", true],
22 "QUIT": ["$n [$h] has quit [$m]", true],
23 "NICK": ["$n has changed nick to $w", true],
24 "TOPIC": ["$n changed the topic of $c to: $m", true],
25 "UMODE": ["MODE $n $m", true],
26 "INVITE": ["$n invites you to join $c", true],
96f28062
CP
27 "HILIGHT": ["$C4"],
28 "HILIGHTEND": ["$O"],
29 "CHANMSG": ["<$z$n$Z> $m"],
30 "PRIVMSG": ["<$z$n$Z> $m"],
31 "CHANNOTICE": ["-$z$n$Z:$c- $m"],
32 "PRIVNOTICE": ["-$z$n$Z- $m"],
33 "OURCHANMSG": ["<$z$n$Z> $m"],
34 "OURPRIVMSG": ["<$z$n$Z> $m"],
35 "OURTARGETEDMSG": ["*$z$t$Z* $m"],
36 "OURTARGETEDNOTICE": ["[notice($z$t$Z)] $m"],
37 "OURCHANNOTICE": ["-$z$n$Z:$t- $m"],
38 "OURPRIVNOTICE": ["-$z$n$Z- $m"],
39 "OURCHANACTION": [" * $z$n$Z $m"],
40 "OURPRIVACTION": [" * $z$n$Z $m"],
41 "CHANACTION": [" * $z$n$Z $m"],
42 "PRIVACTION": [" * $z$n$Z $m"],
9e769c12
CP
43 "CHANCTCP": ["$n [$h] requested CTCP $x from $c: $m"],
44 "PRIVCTCP": ["$n [$h] requested CTCP $x from $-: $m"],
45 "CTCPREPLY": ["CTCP $x reply from $n: $m"],
46 "OURCHANCTCP": ["[ctcp($t)] $x $m"],
47 "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
1d6756bc
CP
48 "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
49 "WHOISUSER": ["$B$n$B [$h]", true],
50 "WHOISREALNAME": [" realname : $m", true],
51 "WHOISCHANNELS": [" channels : $m", true],
52 "WHOISSERVER": [" server : $x [$m]", true],
2cd9e32d 53 "WHOISACCOUNT": [" account : qwebirc://qwhois/$m", true],
1d6756bc
CP
54 "WHOISIDLE": [" idle : $x [connected: $m]", true],
55 "WHOISAWAY": [" away : $m", true],
56 "WHOISOPER": [" : $BIRC Operator$B", true],
57 "WHOISOPERNAME": [" operedas : $m", true],
58 "WHOISACTUALLY": [" realhost : $m [ip: $x]", true],
59 "WHOISEND": ["End of WHOIS", true],
68413dcb 60 "AWAY": ["$n is away: $m", true],
574dff59 61 "GENERICERROR": ["$m: $t", true],
41cc1a57 62 "GENERICMESSAGE": ["$m", true]
9e769c12
CP
63};
64
e20e5a6b 65qwebirc.ui.Theme = new Class({
9e769c12 66 initialize: function(themeDict) {
96f28062 67 this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
9e769c12 68
9e769c12
CP
69 if(themeDict)
70 for(var k in themeDict)
71 this.__theme[k] = themeDict[k];
72
73 for(var k in this.__theme) {
74 if(k == "PREFIX")
75 continue;
76
77 var data = this.__theme[k];
78 if(data[1]) {
79 this.__theme[k] = this.__theme["PREFIX"] + data[0];
80 } else {
81 this.__theme[k] = data[0];
82 }
83 }
96f28062
CP
84
85 this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
86 this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
87
88 this.__ccmap["z"] = "";
89 this.__ccmap["Z"] = "";
90
91 this.__ccmaph["z"] = this.message("HILIGHT", {}, this.__ccmap);
92 this.__ccmaph["Z"] = this.message("HILIGHTEND", {}, this.__ccmap);
9e769c12 93 },
96f28062 94 __dollarSubstitute: function(x, h, mapper) {
9e769c12
CP
95 var msg = [];
96
97 var n = x.split("");
98 for(var i=0;i<n.length;i++) {
99 var c = n[i];
100 if(c == "$" && (i <= n.length - 1)) {
101 var c2 = n[++i];
102
96f28062 103 var o = mapper[c2];
9e769c12
CP
104 if(!o)
105 o = h[c2];
106 if(o)
107 msg.push(o);
108 } else {
109 msg.push(c);
110 }
111 }
112
113 return msg.join("");
114 },
96f28062
CP
115 message: function(type, data, hilight) {
116 var map;
117 if(hilight) {
118 map = this.__ccmaph;
119 } else {
120 map = this.__ccmap;
121 }
122 return this.__dollarSubstitute(this.__theme[type], data, map);
9e769c12
CP
123 }
124});