From f465ebaab9af24f7d5c562640138ddfc70d302c7 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 27 Nov 2011 16:35:20 +0000 Subject: [PATCH] Being mentioned in a chat --- static/js/chat.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index c3eddacb..1f6267be 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -87,6 +87,17 @@ var chat = (function() }); var text = padutils.escapeHtmlWithClickableLinks(padutils.escapeHtml(msg.text), "_blank"); + + /* Performs an action if your name is mentioned */ + var myName = $('#myusernameedit').val(); + myName = myName.toLowerCase(); + var chatText = text.toLowerCase(); + var wasMentioned = false; + if (chatText.indexOf(myName) !== -1 && myName != "undefined"){ + wasMentioned = true; + } + /* End of new action */ + var authorName = msg.userName == null ? "unnamed" : padutils.escapeHtml(msg.userName); var html = "

" + authorName + ":" + timeStr + " " + text + "

"; @@ -98,9 +109,18 @@ var chat = (function() var count = Number($("#chatcounter").text()); count++; $("#chatcounter").text(count); - // chat throb stuff -- Just make it throb in for ~2 secs then fadeotu - $('#chatthrob').html(""+authorName+"" + ": " + text); - $('#chatthrob').effect("pulsate", {times:1,mode:"hide"},2000); + // 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 + $('#chatthrob').html(""+authorName+"" + ": " + text); + $('#chatthrob').effect("pulsate", {times:1,mode:"hide"},4000); + document.title = "You were mentioned in a chat: " + document.title; + } + else + { + $('#chatthrob').html(""+authorName+"" + ": " + text); + $('#chatthrob').effect("pulsate", {times:1,mode:"hide"},2000); + } } self.scrollDown();