]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/theme.js
IE fixes.
[irc/quakenet/qwebirc.git] / js / ui / theme.js
index d0a4ed0c0b2296fff2a037f985bb5711265e44d3..98af54ac55e83e4a291bfe6eaaa4487dfb04e3c4 100644 (file)
@@ -3,6 +3,8 @@ qwebirc.ui.themes.ThemeControlCodeMap = {
   "B": "\x02",
   "U": "\x1F",
   "O": "\x0F",
+  "[": "qwebirc://whois/",
+  "]": "/",
   "$": "$"
 };
 
@@ -14,37 +16,39 @@ qwebirc.ui.themes.Default = {
   "DISCONNECT": ["Disconnected from server: $m", true],
   "ERROR": ["ERROR: $m", true],
   "SERVERNOTICE": ["$m", true],
-  "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],
+  "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": ["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"],
+  "INVITE": ["$N invites you to join $c", true],
+  "HILIGHT": ["$C4"],
+  "HILIGHTEND": ["$O"],
+  "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"],
   "OURCHANCTCP": ["[ctcp($t)] $x $m"],
   "OURPRIVCTCP": ["[ctcp($t)] $x $m"],
   "OURTARGETEDCTCP": ["[ctcp($t)] $x $m"],
-  "WHOISUSER": ["$B$n$B [$h]", true],
+  "WHOISUSER": ["$B$N$B [$h]", true],
   "WHOISREALNAME": [" realname : $m", true],
   "WHOISCHANNELS": [" channels : $m", true],
   "WHOISSERVER": [" server   : $x [$m]", true],
@@ -55,17 +59,15 @@ qwebirc.ui.themes.Default = {
   "WHOISOPERNAME": [" operedas : $m", true],
   "WHOISACTUALLY": [" realhost : $m [ip: $x]", true],
   "WHOISEND": ["End of WHOIS", true],
-  "AWAY": ["$n is away: $m", true],
-  "WHOISNOSUCHNICK": ["No such nick: $n", true]
+  "AWAY": ["$N is away: $m", true],
+  "GENERICERROR": ["$m: $t", true],
+  "GENERICMESSAGE": ["$m", true]
 };
 
 qwebirc.ui.Theme = new Class({
   initialize: function(themeDict) {
-    this.__theme = {};
+    this.__theme = qwebirc.util.dictCopy(qwebirc.ui.themes.Default);
     
-    for(var k in qwebirc.ui.themes.Default)
-      this.__theme[k] = qwebirc.ui.themes.Default[k];
-  
     if(themeDict)
       for(var k in themeDict)
         this.__theme[k] = themeDict[k];
@@ -81,8 +83,17 @@ qwebirc.ui.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.__ccmap["("] = "";
+    this.__ccmap[")"] = "";
+    
+    this.__ccmaph["("] = this.message("HILIGHT", {}, this.__ccmap);
+    this.__ccmaph[")"] = this.message("HILIGHTEND", {}, this.__ccmap);
   },
-  __dollarSubstitute: function(x, h) {
+  __dollarSubstitute: function(x, h, mapper) {
     var msg = [];
 
     var n = x.split("");
@@ -91,7 +102,7 @@ qwebirc.ui.Theme = new Class({
       if(c == "$" && (i <= n.length - 1)) {
         var c2 = n[++i];
 
-        var o = qwebirc.ui.themes.ThemeControlCodeMap[c2];
+        var o = mapper[c2];
         if(!o)
           o = h[c2];
         if(o)
@@ -103,11 +114,16 @@ qwebirc.ui.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);
   }
 });