From b95a59185e6a514ed971959117339ec830c69483 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 2 Sep 2011 12:31:55 -0700 Subject: [PATCH] Added /leave to close event --- Chat/Chat.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Chat/Chat.js b/Chat/Chat.js index de367b9ef..a18fb54f0 100644 --- a/Chat/Chat.js +++ b/Chat/Chat.js @@ -226,11 +226,11 @@ $(function () { chat.changeGravatar = function (currentUser) { $('#u-' + currentUser.Id).replaceWith( - $('#new-user-template').tmpl({ - name: currentUser.Name, - hash: currentUser.Hash, - id: currentUser.Id - }) + $('#new-user-template').tmpl({ + name: currentUser.Name, + hash: currentUser.Hash, + id: currentUser.Id + }) ); refreshUsers(); @@ -241,7 +241,7 @@ $(function () { else { addMessage(currentUser.Name + "'s gravatar changed.", 'notification'); } - } + }; chat.showCommands = function (commands) { addMessage('

Help

'); @@ -303,6 +303,12 @@ $(function () { document.title = 'SignalR Chat'; }); + $(window).unload(function () { + if (chat.room) + chat.send("/leave"); + //ignore errors + }); + function updateUnread() { if (!chat.focus) { if (!chat.unread) {