diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -27,6 +27,7 @@ var THREAD_UPDATE_DELAY = 10000; var loading = false; var lastUpdateTime = null; +var unreadPosts = 0 function blink(node) { var blinkCount = 2; @@ -99,7 +100,7 @@ function updateThread() { updatePostBumpableStatus(); if (data.added.length + data.updated.length > 0) { - showNewPostsTitle(); + showNewPostsTitle(data.added.length); } }) .error(function(data) { @@ -171,15 +172,19 @@ var documentOriginalTitle = ''; /** * Show 'new posts' text in the title if the document is not visible to a user */ -function showNewPostsTitle() { +function showNewPostsTitle(newPostCount) { if (document.hidden) { - documentOriginalTitle = document.title; - document.title = gettext('[new posts]') + ' ' + document.title; + if (documentOriginalTitle === '') { + documentOriginalTitle = document.title; + } + unreadPosts = unreadPosts + newPostCount; + document.title = '[' + unreadPosts + '] ' + documentOriginalTitle; document.addEventListener('visibilitychange', function() { if (documentOriginalTitle !== '') { document.title = documentOriginalTitle; documentOriginalTitle = ''; + unreadPosts = 0; } document.removeEventListener('visibilitychange', null);