X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=8be028279d2b549a4a15e9eef9c57cd3d88b1f2d;hp=e7d19e6d4bce03ecfe22c967ca021018071e4603;hb=0c793f7f21339606808799d513d28f86f7fa6bfd;hpb=95789c708a5c886410e860e72c7fca0c7f21cb17 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(); + }); + });