From 0c793f7f21339606808799d513d28f86f7fa6bfd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Nov 2010 15:51:20 +0100 Subject: [PATCH] =?utf8?q?Mark=20the=20document=20title=20with=20a=20?= =?utf8?q?=E2=80=9C(!)=E2=80=9D=20when=20activity=20is=20detected,=20clear?= =?utf8?q?=20on=20focus.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/javascript/sone.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index e7d19e6..8be0282 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -569,6 +569,7 @@ function getStatus() { $("#sone #notification-area").append(notification); notification.slideDown(); } + setActivity(); }); $.each(data.removedNotifications, function(index, value) { $("#sone #notification-area .notification#" + value.id).slideUp(); @@ -618,6 +619,7 @@ function loadNewPost(postId) { } ajaxifyPost(newPost); newPost.slideDown(); + setActivity(); } }); } @@ -650,6 +652,7 @@ function loadNewReply(replyId) { } ajaxifyReply(newReply); newReply.slideDown(); + setActivity(); }); } }); @@ -682,6 +685,20 @@ function markReplyAsKnown(replyElements) { }); } +function resetActivity() { + title = document.title; + if (title.indexOf('(') == 0) { + document.title = title.substr(title.indexOf(' ') + 1); + } +} + +function setActivity() { + title = document.title; + if (title.indexOf('(') != 0) { + document.title = "(!) " + title; + } +} + /** * Creates a new notification. * @@ -807,4 +824,10 @@ $(document).ready(function() { /* activate status polling. */ setTimeout(getStatus, 5000); + + /* reset activity counter when the page has focus. */ + $(window).focus(function() { + resetActivity(); + }); + }); -- 2.7.4