From 4bc76af7548dd610e575236faba5d8dadd745bbf Mon Sep 17 00:00:00 2001 From: xDashh Date: Wed, 3 Aug 2016 00:00:07 +0200 Subject: [PATCH] Apply highlighting changes immediately --- static/chat/js/chat.js | 10 ++++++---- static/chat/js/gui.js | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/static/chat/js/chat.js b/static/chat/js/chat.js index e960b543a..a2cce78ed 100644 --- a/static/chat/js/chat.js +++ b/static/chat/js/chat.js @@ -593,14 +593,16 @@ chat.prototype.handleCommand = function(str) { } nick = parts[1].toLowerCase(); - if (command == "unhighlight") { - delete(highlightnicks[nick]); - this.gui.push(new ChatInfoMessage("No longer highlighting: " + nick)); - } else { + dohighlight = command == "highlight"; + if (dohighlight) { highlightnicks[nick] = true; this.gui.push(new ChatInfoMessage("Now highlighting: " + nick)); + } else { + delete(highlightnicks[nick]); + this.gui.push(new ChatInfoMessage("No longer highlighting: " + nick)); } + this.gui.renewHighlight(nick, dohighlight); this.gui.setPreference('highlightnicks', highlightnicks); break; diff --git a/static/chat/js/gui.js b/static/chat/js/gui.js index 29beed756..0730555e5 100644 --- a/static/chat/js/gui.js +++ b/static/chat/js/gui.js @@ -688,6 +688,14 @@ } }, + renewHighlight: function(nick, dohighlight){ + if (dohighlight){ + this.lines.children('div[data-username="'+nick.toLowerCase()+'"]').addClass("highlight"); + } else { + this.lines.children('div[data-username="'+nick.toLowerCase()+'"]').removeClass("highlight"); + } + }, + handleHighlight: function(message){ if (!message.user || !message.user.username || message.user.username == this.engine.user.username || !this.getPreference('highlight')) return false; @@ -1079,4 +1087,4 @@ }; // END EMOTE COUNT -})(jQuery); \ No newline at end of file +})(jQuery);