]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/theme.js
Merge pull request #324 from retropc/master
[irc/quakenet/qwebirc.git] / js / ui / theme.js
index 806a93e62d599784a78cbc9bad2d7b915c01e1e5..beffc0b84eab3de9cfd15e1c8350b3b777d9fa84 100644 (file)
-var ThemeControlCodeMap = {
+qwebirc.ui.themes.ThemeControlCodeMap = {
   "C": "\x03",
   "B": "\x02",
   "U": "\x1F",
   "O": "\x0F",
+  "{": "\x00",
+  "}": "\x00",
+  "[": "qwebirc://whois/",
+  "]": "/",
   "$": "$"
 };
 
-var DefaultTheme = {
+qwebirc.ui.themes.Default = {
   "PREFIX": ["$C4==$O "],
   "SIGNON": ["Signed on!", true],
-  "CONNECT": ["Connected to server.", true],
+  "CONNECTING": ["Connecting to server, please wait...", true],
+  "CONNECT": ["Logging in, please wait...", true],
+  "CONNECTED": ["Connected and logged in -- ready to go!", true],
   "RAW": ["$m", true],
   "DISCONNECT": ["Disconnected from server: $m", true],
   "ERROR": ["ERROR: $m", true],
   "SERVERNOTICE": ["$m", true],
-  "JOIN": ["$n [$h] has joined $c", true],
-  "PART": ["$n [$h] has left $c [$m]", true],
-  "KICK": ["$v was kicked from $c by $n [$m]", true],
-  "MODE": ["mode/$c [$m] by $n", true],
-  "QUIT": ["$n [$h] has quit [$m]", true],
-  "NICK": ["$n has changed nick to $w", true],
-  "TOPIC": ["$n changed the topic of $c to: $m", true],
-  "UMODE": ["MODE $n $m", true],
-  "INVITE": ["$n invites you to join $c", true],
-  "CHANMSG": ["<$n> $m"],
-  "PRIVMSG": ["<$n> $m"],
-  "CHANNOTICE": ["-$n:$c- $m"],
-  "PRIVNOTICE": ["-$n- $m"],
-  "OURCHANMSG": ["<$n> $m"],
-  "OURPRIVMSG": ["<$n> $m"],
-  "OURTARGETEDMSG": ["*$t* $m"],
-  "OURTARGETEDNOTICE": ["[notice($t)] $m"],
-  "OURCHANNOTICE": ["-$n:$t- $m"],
-  "OURPRIVNOTICE": ["-$n- $m"],
-  "OURCHANACTION": [" * $n $m"],
-  "OURPRIVACTION": [" * $n $m"],
-  "CHANACTION": [" * $n $m"],
-  "PRIVACTION": [" * $n $m"],
-  "CHANCTCP": ["$n [$h] requested CTCP $x from $c: $m"],
-  "PRIVCTCP": ["$n [$h] requested CTCP $x from $-: $m"],
-  "CTCPREPLY": ["CTCP $x reply from $n: $m"],
+  "JOIN": ["${$N$} [$h] has joined $c", true],
+  "OURJOIN": ["${$N$} [$h] has joined $c", true],
+  "PART": ["${$N$} [$h] has left $c [$m]", true],
+  "KICK": ["${$v$} was kicked from $c by ${$N$} [$m]", true],
+  "MODE": ["mode/$c [$m] by ${$N$}", true],
+  "QUIT": ["${$N$} [$h] has quit [$m]", true],
+  "NICK": ["${$n$} has changed nick to ${$[$w$]$}", true],
+  "TOPIC": ["${$N$} changed the topic of $c to: $m", true],
+  "UMODE": ["Usermode change: $m", true],
+  "INVITE": ["$N invites you to join $c", true],
+  "HILIGHT": ["$C4"],
+  "HILIGHTEND": ["$O"],
+  "CHANMSG": ["<$C15$@$O${$($N$)$}> $m"],
+  "PRIVMSG": ["<$($N$)> $m"],
+  "CHANNOTICE": ["-${$($N$)$}:$c- $m"],
+  "PRIVNOTICE": ["-$($N$)- $m"],
+  "OURCHANMSG": ["<$C15$@$O$U$N$O> $m"],
+  "OURPRIVMSG": ["<$U$N$O> $m"],
+  "OURTARGETEDMSG": ["*$[$t$]* $m"],
+  "OURTARGETEDNOTICE": ["[notice($[$t$])] $m"],
+  "OURCHANNOTICE": ["-$N:$t- $m"],
+  "OURPRIVNOTICE": ["-$N- $m"],
+  "OURCHANACTION": [" * $U$N$O $m"],
+  "OURPRIVACTION": [" * $U$N$O $m"],
+  "CHANACTION": [" * ${$($N$)$} $m"],
+  "PRIVACTION": [" * $($N$) $m"],
+  "CHANCTCP": ["$N [$h] requested CTCP $x from $c: $m"],
+  "PRIVCTCP": ["$N [$h] requested CTCP $x from $-: $m"],
+  "CTCPREPLY": ["CTCP $x reply from $N: $m"],
   "OURCHANCTCP": ["[ctcp($t)] $x $m"],
   "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
-  "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"]
+  "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
+  "WHOISUSER": ["$B$N$B [$h]", true],
+  "WHOISREALNAME": [" realname : $m", true],
+  "WHOISCHANNELS": [" channels : $m", true],
+  "WHOISSERVER": [" server   : $x [$m]", true],
+  "WHOISACCOUNT": [" account  : qwebirc://qwhois/$m", true],
+  "WHOISIDLE": [" idle     : $x [connected: $m]", true],
+  "WHOISAWAY": [" away     : $m", true],
+  "WHOISOPER": ["          : $BIRC Operator$B", true],
+  "WHOISOPERNAME": [" operedas : $m", true],
+  "WHOISACTUALLY": [" realhost : $m [ip: $x]", true],
+  "WHOISGENERICTEXT": ["          : $m", true],
+  "WHOISEND": ["End of WHOIS", true],
+  "AWAY": ["$N is away: $m", true],
+  "GENERICERROR": ["$m: $t", true],
+  "GENERICMESSAGE": ["$m", true],
+  "WALLOPS": ["WALLOP $n: $t", true],
+  "CHANNELCREATIONTIME": ["Channel $c was created at: $m", true],
+  "CHANNELMODEIS": ["Channel modes on $c are: $m", true],
+  "IGNORED": ["Ignored $n, to unignore type: /UNIGNORE $n", false],
+  "UNIGNORED": ["Unignored $n.", false],
+  "IGNOREHEADER": ["Ignore list:", false],
+  "IGNOREENTRY": ["- $h", false],
+  "IGNOREEMPTY": ["Ignore list is empty.", false],
+  "SILENCE": ["Silenced: $h", false],
+
+  "NOTIFYCHANMSGTITLE": ["Mentioned on $c:", false],
+  "NOTIFYCHANMSGBODY": ["<$@$n> $m", false],
+  "NOTIFYCHANACTIONTITLE": ["Mentioned on $c:", false],
+  "NOTIFYCHANACTIONBODY": [" * $n $m", false],
+  "NOTIFYPRIVMSGTITLE": ["Private message from $n:", false],
+  "NOTIFYPRIVMSGBODY": ["$m", false],
+  "NOTIFYPRIVACTIONTITLE": ["Private message from $n:", false],
+  "NOTIFYPRIVACTIONBODY": [" * $n $m", false],
+  "NOTIFYCHANNOTICETITLE": ["Mentioned on $c:", false],
+  "NOTIFYCHANNOTICEBODY": ["-$n- $m", false],
+  "NOTIFYPRIVNOTICETITLE": ["Private notice from $n:", false],
+  "NOTIFYPRIVNOTICEBODY": ["$m", false]
 };
 
-var Theme = new Class({
+qwebirc.ui.Theme = new Class({
   initialize: function(themeDict) {
-    this.__theme = {};
+    this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
     
-    for(var k in DefaultTheme)
-      this.__theme[k] = DefaultTheme[k];
-  
     if(themeDict)
       for(var k in themeDict)
         this.__theme[k] = themeDict[k];
@@ -67,8 +110,15 @@ var Theme = new Class({
         this.__theme[k] = data[0];
       }
     }
+    
+    this.__ccmap = qwebirc.util.dictCopy(qwebirc.ui.themes.ThemeControlCodeMap);
+    this.__ccmaph = qwebirc.util.dictCopy(this.__ccmap);
+
+    this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
+    this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
+    this.__ccmaph["{"] = this.__ccmaph["}"] = "";
   },
-  __dollarSubstitute: function(x, h) {
+  __dollarSubstitute: function(x, h, mapper) {
     var msg = [];
 
     var n = x.split("");
@@ -77,7 +127,7 @@ var Theme = new Class({
       if(c == "$" && (i <= n.length - 1)) {
         var c2 = n[++i];
 
-        var o = ThemeControlCodeMap[c2];
+        var o = mapper[c2];
         if(!o)
           o = h[c2];
         if(o)
@@ -89,11 +139,16 @@ var Theme = new Class({
     
     return msg.join("");
   },
-  message: function(type, data) {
-    var msg = this.__theme[type];
+  message: function(type, data, hilight) {
+    var map;
+    if(hilight) {
+      map = this.__ccmaph;
+    } else {
+      map = this.__ccmap;
+    }
     
-    msg = this.__dollarSubstitute(msg, data);
-
-    return msg;
+    if(data && data["n"])
+      data["N"] = "qwebirc://whois/" + data.n + "/";
+    return this.__dollarSubstitute(this.__theme[type], data, map);
   }
 });