##// END OF EJS Templates
Showing unread posts count when new posts appear in the background tab
neko259 -
r468:1829c2a6 default
parent child Browse files
Show More
@@ -27,6 +27,7 b' var THREAD_UPDATE_DELAY = 10000;'
27
27
28 var loading = false;
28 var loading = false;
29 var lastUpdateTime = null;
29 var lastUpdateTime = null;
30 var unreadPosts = 0
30
31
31 function blink(node) {
32 function blink(node) {
32 var blinkCount = 2;
33 var blinkCount = 2;
@@ -99,7 +100,7 b' function updateThread() {'
99 updatePostBumpableStatus();
100 updatePostBumpableStatus();
100
101
101 if (data.added.length + data.updated.length > 0) {
102 if (data.added.length + data.updated.length > 0) {
102 showNewPostsTitle();
103 showNewPostsTitle(data.added.length);
103 }
104 }
104 })
105 })
105 .error(function(data) {
106 .error(function(data) {
@@ -171,15 +172,19 b" var documentOriginalTitle = '';"
171 /**
172 /**
172 * Show 'new posts' text in the title if the document is not visible to a user
173 * Show 'new posts' text in the title if the document is not visible to a user
173 */
174 */
174 function showNewPostsTitle() {
175 function showNewPostsTitle(newPostCount) {
175 if (document.hidden) {
176 if (document.hidden) {
176 documentOriginalTitle = document.title;
177 if (documentOriginalTitle === '') {
177 document.title = gettext('[new posts]') + ' ' + document.title;
178 documentOriginalTitle = document.title;
179 }
180 unreadPosts = unreadPosts + newPostCount;
181 document.title = '[' + unreadPosts + '] ' + documentOriginalTitle;
178
182
179 document.addEventListener('visibilitychange', function() {
183 document.addEventListener('visibilitychange', function() {
180 if (documentOriginalTitle !== '') {
184 if (documentOriginalTitle !== '') {
181 document.title = documentOriginalTitle;
185 document.title = documentOriginalTitle;
182 documentOriginalTitle = '';
186 documentOriginalTitle = '';
187 unreadPosts = 0;
183 }
188 }
184
189
185 document.removeEventListener('visibilitychange', null);
190 document.removeEventListener('visibilitychange', null);
General Comments 0
You need to be logged in to leave comments. Login now