forked from leftypol/leftypol
Merge pull request 'Various fixes for thread reply notifications' (#52) from auto-refresh-notifications into config
This commit is contained in:
commit
43268fba76
|
@ -188,7 +188,7 @@ $(document).ready(function(){
|
|||
if (typeof end_of_page == "undefined") var end_of_page = false;
|
||||
if (end_of_page || (new_posts && window_active &&
|
||||
$(window).scrollTop() + $(window).height() >=
|
||||
$('div.boardlist.bottom').position().top)) {
|
||||
$('#thread-interactions').position().top)) {
|
||||
|
||||
new_posts = 0;
|
||||
}
|
||||
|
@ -240,10 +240,10 @@ $(document).ready(function(){
|
|||
if (!new_posts) {
|
||||
first_new_post = this;
|
||||
makeIcon('reply');
|
||||
if (notify === "all" || (notify === "mention" && $(this).find('.own_post').length)) {
|
||||
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 (notify === "all" || (notify === "mention" && $(this).find('.own_post').length)) {
|
||||
var body = $(this).children('.body').html().replace(/<br\s*[\/]?>/gi, "\n");
|
||||
var n = new Notification("New reply to "+title, {body: $('<div/>').html(body).text()});
|
||||
}
|
||||
if ($("div.post").length > 1){
|
||||
$(this).insertAfter($('div.post:not(.post-hover):last').next()).after('<br class="clear">');
|
||||
|
|
|
@ -42,24 +42,24 @@ auto_reload_enabled = true; // for watch.js to interop
|
|||
|
||||
$(document).ready(function(){
|
||||
// Adds Options panel item
|
||||
if (typeof localStorage.auto_recent_update === 'undefined') {
|
||||
localStorage.auto_recent_update = 'true'; //default value
|
||||
if (typeof localStorage.auto_recent_update_mod === 'undefined') {
|
||||
localStorage.auto_recent_update_mod = 'true'; //default value
|
||||
}
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
Options.extend_tab("general", "<fieldset id='auto-update-fs'><legend>"+_("Auto update (recent)")+"</legend>"
|
||||
+ ('<label id="auto-recent-update"><input type="checkbox">' + _('Auto update recent') + '</label>')
|
||||
+ ('<label id="auto_recent_desktop_notifications_all"><input type="checkbox">' + _('Show desktop notifications on all replies') + '</label>')
|
||||
+ ('<label id="auto-recent-update-mod"><input type="checkbox">' + _('Auto update recent (mod)') + '</label>')
|
||||
+ ('<label id="auto_recent_desktop_notifications_all_mod"><input type="checkbox">' + _('Show desktop notifications on all replies (mod)') + '</label>')
|
||||
+ '</fieldset>');
|
||||
|
||||
$('#auto-recent-update>input').on('click', function() {
|
||||
if ($('#auto-recent-update>input').is(':checked')) {
|
||||
localStorage.auto_recent_update = 'true';
|
||||
$('#auto-recent-update-mod>input').on('click', function() {
|
||||
if ($('#auto-recent-update-mod>input').is(':checked')) {
|
||||
localStorage.auto_recent_update_mod = 'true';
|
||||
} else {
|
||||
localStorage.auto_recent_update = 'false';
|
||||
localStorage.auto_recent_update_mod = 'false';
|
||||
}
|
||||
});
|
||||
|
||||
$('#auto_recent_desktop_notifications>input,#auto_recent_desktop_notifications_all>input').on('click', function() {
|
||||
$('#auto_recent_desktop_notifications_all_mod>input').on('click', function() {
|
||||
if (!("Notification" in window)) return;
|
||||
|
||||
var setting = $(this).parent().attr('id');
|
||||
|
@ -78,12 +78,12 @@ $(document).ready(function(){
|
|||
}
|
||||
});
|
||||
|
||||
if (localStorage.auto_recent_update === 'true') {
|
||||
$('#auto-recent-update>input').prop('checked', true);
|
||||
if (localStorage.auto_recent_update_mod === 'true') {
|
||||
$('#auto-recent-update-mod>input').prop('checked', true);
|
||||
}
|
||||
|
||||
if (localStorage.auto_recent_desktop_notifications_all === 'true') {
|
||||
$('#auto_recent_desktop_notifications_all>input').prop('checked', true);
|
||||
if (localStorage.auto_recent_desktop_notifications_all_mod === 'true') {
|
||||
$('#auto_recent_desktop_notifications_all_mod>input').prop('checked', true);
|
||||
notify = "all";
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ $(document).ready(function(){
|
|||
$(".bar-bottom span:last-child").append("<span id='updater'><a href='#' id='update_thread'>["+_("Update")+"]</a> (<input type='checkbox' id='auto_update_status'> "+_("Auto")+") <span id='update_secs'></span></span>");
|
||||
|
||||
// Set the updater checkbox according to user setting
|
||||
if (localStorage.auto_recent_update === 'true') {
|
||||
if (localStorage.auto_recent_update_mod === 'true') {
|
||||
$('#auto_update_status').prop('checked', true);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ $(document).ready(function(){
|
|||
var title = document.title;
|
||||
|
||||
if (typeof update_title == "undefined") {
|
||||
var update_title = function() {
|
||||
var update_title = function() {
|
||||
if (new_posts) {
|
||||
document.title = "("+new_posts+") "+title;
|
||||
} else {
|
||||
|
@ -134,6 +134,7 @@ $(document).ready(function(){
|
|||
var window_active = true;
|
||||
$(window).focus(function() {
|
||||
window_active = true;
|
||||
recheck_activated();
|
||||
|
||||
// Reset the delay if needed
|
||||
if(settings.get('reset_focus', true)) {
|
||||
|
@ -155,7 +156,6 @@ $(document).ready(function(){
|
|||
|
||||
});
|
||||
|
||||
|
||||
var decrement_timer = function() {
|
||||
poll_current_time = 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
|
||||
var auto_update = function(delay) {
|
||||
clearInterval(countdown_interval);
|
||||
|
@ -207,10 +217,15 @@ $(document).ready(function(){
|
|||
if($('#' + id).length == 0) {
|
||||
if (!new_posts) {
|
||||
first_new_post = this;
|
||||
makeIcon('reply');
|
||||
if (notify === "all") {
|
||||
}
|
||||
// Notify on all posts, not just the first unread
|
||||
if (notify === "all") {
|
||||
if ($(this).hasClass('thread')){
|
||||
var body = $(this).children('.post').children('.body').html().replace(/<br\s*[\/]?>/gi, "\n");
|
||||
var n = new Notification("New thread in "+title, {body: $('<div/>').html(body).text()});
|
||||
} else {
|
||||
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()});
|
||||
var n = new Notification("New reply to "+title, {body: $('<div/>').html(body).text()});
|
||||
}
|
||||
}
|
||||
if ($("div.post,div.thread").length > 1){
|
||||
|
@ -222,6 +237,7 @@ $(document).ready(function(){
|
|||
new_posts++;
|
||||
loaded_posts++;
|
||||
$(document).trigger('new_post', this);
|
||||
recheck_activated();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -279,6 +295,9 @@ $(document).ready(function(){
|
|||
|
||||
return false;
|
||||
};
|
||||
$(window).scrollStopped(function() {
|
||||
recheck_activated();
|
||||
});
|
||||
|
||||
$('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user