From c230e3db2dfb60b141c3eea4c3fbe43241c7b918 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 4 Dec 2011 19:51:45 +0000 Subject: [PATCH] Fix issue where chat increment would go up even if the chat box was in focus, makes sense, apologies this wasn't in first commit --- static/js/chat.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index 1bc44d201..6572fbfd6 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -108,19 +108,23 @@ var chat = (function() //should we increment the counter?? if(increment) { - var count = Number($("#chatcounter").text()); - count++; - $("#chatcounter").text(count); - // chat throb stuff -- Just make it throw for twice as long - if(wasMentioned) - { // If the user was mentioned show for twice as long and flash the browser window - if (chatMentions == 0){ - title = document.title; + // Only increment if the chat window is not already open + if(!$('#chattext').is(':visible')) + { + var count = Number($("#chatcounter").text()); + count++; + $("#chatcounter").text(count); + // chat throb stuff -- Just make it throw for twice as long + if(wasMentioned) + { // If the user was mentioned show for twice as long and flash the browser window + if (chatMentions == 0){ + title = document.title; + } + $('#chatthrob').html(""+authorName+"" + ": " + text); + $('#chatthrob').effect("pulsate", {times:1,mode:"hide"},4000); + chatMentions++; + document.title = "("+chatMentions+") " + title; } - $('#chatthrob').html(""+authorName+"" + ": " + text); - $('#chatthrob').effect("pulsate", {times:1,mode:"hide"},4000); - chatMentions++; - document.title = "("+chatMentions+") " + title; } else {