From b50dc3a62687fcd572710fe1c70fbe30805ff3ed Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 19 Nov 2013 16:14:33 -0600 Subject: [PATCH] Fix greentext bug --- lib/channel.js | 15 ++++++++++++--- lib/chatcommand.js | 6 +++++- www/assets/js/util.js | 9 +++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/channel.js b/lib/channel.js index c5f09fe7..ce7818ff 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -604,7 +604,10 @@ Channel.prototype.tryNameBan = function(actor, name) { var notice = { username: "[server]", msg: actor.name + " banned " + name, - meta: { addClass: "server-whisper" }, + meta: { + addClass: "server-whisper" , + addClassToNameAndTimestamp: true + }, time: Date.now() }; self.users.forEach(function(u) { @@ -716,7 +719,10 @@ Channel.prototype.tryIPBan = function(actor, name, range) { username: "[server]", msg: actor.name + " banned " + $util.maskIP(ip) + " (" + name + ")", - meta: { addClass: "server-whisper" }, + meta: { + addClass: "server-whisper", + addClassToNameAndTimestamp: true + }, time: Date.now() }; self.users.forEach(function(u) { @@ -1133,7 +1139,10 @@ Channel.prototype.broadcastNewUser = function(user) { var pkt = { username: "[server]", msg: msg, - meta: { addClass: "server-whisper" }, + meta: { + addClass: "server-whisper", + addClassToNameAndTimestamp: true + }, time: Date.now() }; self.sendAllWithRank(2, "joinMessage", pkt); diff --git a/lib/chatcommand.js b/lib/chatcommand.js index 08d5e047..967c1fdb 100644 --- a/lib/chatcommand.js +++ b/lib/chatcommand.js @@ -26,6 +26,7 @@ var handlers = { "say": function (chan, user, msg, meta) { if (user.rank >= 1.5) { meta.addClass = "shout"; + meta.addClassToNameAndTimestamp = true; meta.forceShowName = true; chan.sendMessage(user, msg, meta); } @@ -196,7 +197,10 @@ function handleShadowMute(chan, user, args) { var pkt = { username: "[server]", msg: user.name + " shadow muted " + args[0], - meta: { addClass: "server-whisper" }, + meta: { + addClass: "server-whisper", + addClassToNameAndTimestamp: true + }, time: Date.now() }; chan.users.forEach(function (u) { diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 774a7c27..f2b96f9f 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -1445,7 +1445,9 @@ function formatChatMessage(data) { // Backwards compat if (!data.meta || data.msgclass) { data.meta = { - addClass: data.msgclass + addClass: data.msgclass, + // And the award for "variable name most like Java source code" goes to... + addClassToNameAndTimestamp: data.msgclass }; } // Phase 1: Determine whether to show the username or not @@ -1473,8 +1475,7 @@ function formatChatMessage(data) { var time = $("").addClass("timestamp").appendTo(div); var timestamp = new Date(data.time).toTimeString().split(" ")[0]; time.text("["+timestamp+"] "); - if (data.meta.addClass && - data.meta.addClass.match(/shout|server-whisper/)) { + if (data.meta.addClass && data.meta.addClassToNameAndTimestamp) { time.addClass(data.meta.addClass); } } @@ -1488,7 +1489,7 @@ function formatChatMessage(data) { if (data.meta.modflair) { name.addClass(getNameColor(data.meta.modflair)); } - if (data.meta.addClass) { + if (data.meta.addClass && data.meta.addClassToNameAndTimestamp) { name.addClass(data.meta.addClass); } if (data.meta.superadminflair) {