Fix notifications
This commit is contained in:
parent
bea6c371b1
commit
04289c6613
|
@ -116,7 +116,7 @@ $(document).ready(function(){
|
||||||
var title = document.title;
|
var title = document.title;
|
||||||
|
|
||||||
if (typeof update_title == "undefined") {
|
if (typeof update_title == "undefined") {
|
||||||
var update_title = function() {
|
var update_title = function() {
|
||||||
if (new_posts) {
|
if (new_posts) {
|
||||||
document.title = "("+new_posts+") "+title;
|
document.title = "("+new_posts+") "+title;
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,6 +134,7 @@ $(document).ready(function(){
|
||||||
var window_active = true;
|
var window_active = true;
|
||||||
$(window).focus(function() {
|
$(window).focus(function() {
|
||||||
window_active = true;
|
window_active = true;
|
||||||
|
recheck_activated();
|
||||||
|
|
||||||
// Reset the delay if needed
|
// Reset the delay if needed
|
||||||
if(settings.get('reset_focus', true)) {
|
if(settings.get('reset_focus', true)) {
|
||||||
|
@ -155,7 +156,6 @@ $(document).ready(function(){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var decrement_timer = function() {
|
var decrement_timer = function() {
|
||||||
poll_current_time = poll_current_time - 1000;
|
poll_current_time = poll_current_time - 1000;
|
||||||
$('#update_secs').text(poll_current_time/1000);
|
$('#update_secs').text(poll_current_time/1000);
|
||||||
|
@ -165,6 +165,16 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var recheck_activated = function() {
|
||||||
|
if (new_posts && window_active &&
|
||||||
|
$(window).scrollTop() <=
|
||||||
|
$('header').position().top + $('header').outerHeight(true)) {
|
||||||
|
new_posts = 0;
|
||||||
|
}
|
||||||
|
update_title();
|
||||||
|
first_new_post = null;
|
||||||
|
};
|
||||||
|
|
||||||
// automatically updates the thread after a specified delay
|
// automatically updates the thread after a specified delay
|
||||||
var auto_update = function(delay) {
|
var auto_update = function(delay) {
|
||||||
clearInterval(countdown_interval);
|
clearInterval(countdown_interval);
|
||||||
|
@ -207,11 +217,11 @@ $(document).ready(function(){
|
||||||
if($('#' + id).length == 0) {
|
if($('#' + id).length == 0) {
|
||||||
if (!new_posts) {
|
if (!new_posts) {
|
||||||
first_new_post = this;
|
first_new_post = this;
|
||||||
makeIcon('reply');
|
}
|
||||||
if (notify === "all") {
|
// Notify on all posts, not just the first unread
|
||||||
var body = $(this).children('.body').html().replace(/<br\s*[\/]?>/gi, "\n");
|
if (notify === "all") {
|
||||||
var n = new Notification("New reply to "+$('title').text(), {body: $('<div/>').html(body).text()});
|
var body = $(this).children('.body').html().replace(/<br\s*[\/]?>/gi, "\n");
|
||||||
}
|
var n = new Notification("New reply to "+$('title').text(), {body: $('<div/>').html(body).text()});
|
||||||
}
|
}
|
||||||
if ($("div.post,div.thread").length > 1){
|
if ($("div.post,div.thread").length > 1){
|
||||||
$(this).parent().insertBefore($($('div.post,div.thread').not('.post-hover').first()).parent());
|
$(this).parent().insertBefore($($('div.post,div.thread').not('.post-hover').first()).parent());
|
||||||
|
@ -222,6 +232,7 @@ $(document).ready(function(){
|
||||||
new_posts++;
|
new_posts++;
|
||||||
loaded_posts++;
|
loaded_posts++;
|
||||||
$(document).trigger('new_post', this);
|
$(document).trigger('new_post', this);
|
||||||
|
recheck_activated();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -279,6 +290,9 @@ $(document).ready(function(){
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
$(window).scrollStopped(function() {
|
||||||
|
recheck_activated();
|
||||||
|
});
|
||||||
|
|
||||||
$('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });
|
$('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user