From 320fc8e86d114a29a05a7b05b6dc40323a3f2736 Mon Sep 17 00:00:00 2001 From: discomrade Date: Thu, 14 Oct 2021 21:03:28 -0100 Subject: [PATCH 1/7] Separate mod auto-update settings from normal settings --- js/mod/recent-posts-auto-reload.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/mod/recent-posts-auto-reload.js b/js/mod/recent-posts-auto-reload.js index 1c269c18..90ba9fdb 100644 --- a/js/mod/recent-posts-auto-reload.js +++ b/js/mod/recent-posts-auto-reload.js @@ -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", "
"+_("Auto update (recent)")+"" - + ('') - + ('') + + ('') + + ('') + '
'); - $('#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("["+_("Update")+"] ( "+_("Auto")+") "); // 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); } From a0f586dfa2d22f06bb96d1236133501d7f47f030 Mon Sep 17 00:00:00 2001 From: discomrade Date: Thu, 14 Oct 2021 23:08:10 +0000 Subject: [PATCH 2/7] Fix notifications: replace reference to undisplayed div --- js/auto-reload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index aedbea4f..0d64a77b 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -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; } From bea6c371b11a7a80a74c41bc1163918c92803c7c Mon Sep 17 00:00:00 2001 From: discomrade Date: Fri, 15 Oct 2021 00:06:24 +0000 Subject: [PATCH 3/7] Make all notifications show, not just the first unread --- js/auto-reload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index 0d64a77b..5cdf12ae 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -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)) { + } + if (notify === "all" || (notify === "mention" && $(this).find('.own_post').length)) { var body = $(this).children('.body').html().replace(//gi, "\n"); var n = new Notification("New reply to "+$('title').text(), {body: $('
').html(body).text()}); - } } if ($("div.post").length > 1){ $(this).insertAfter($('div.post:not(.post-hover):last').next()).after('
'); From 04289c6613e3e9311f039a252bd44e37cd7c1d60 Mon Sep 17 00:00:00 2001 From: discomrade Date: Fri, 15 Oct 2021 00:09:00 +0000 Subject: [PATCH 4/7] Fix notifications --- js/mod/recent-posts-auto-reload.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/js/mod/recent-posts-auto-reload.js b/js/mod/recent-posts-auto-reload.js index 90ba9fdb..e2d661d2 100644 --- a/js/mod/recent-posts-auto-reload.js +++ b/js/mod/recent-posts-auto-reload.js @@ -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,11 +217,11 @@ $(document).ready(function(){ if($('#' + id).length == 0) { if (!new_posts) { first_new_post = this; - makeIcon('reply'); - if (notify === "all") { - var body = $(this).children('.body').html().replace(//gi, "\n"); - var n = new Notification("New reply to "+$('title').text(), {body: $('
').html(body).text()}); - } + } + // Notify on all posts, not just the first unread + if (notify === "all") { + var body = $(this).children('.body').html().replace(//gi, "\n"); + var n = new Notification("New reply to "+$('title').text(), {body: $('
').html(body).text()}); } if ($("div.post,div.thread").length > 1){ $(this).parent().insertBefore($($('div.post,div.thread').not('.post-hover').first()).parent()); @@ -222,6 +232,7 @@ $(document).ready(function(){ new_posts++; loaded_posts++; $(document).trigger('new_post', this); + recheck_activated(); } }); @@ -279,6 +290,9 @@ $(document).ready(function(){ return false; }; + $(window).scrollStopped(function() { + recheck_activated(); + }); $('#update_thread').on('click', function() { poll(manualUpdate = true); return false; }); From 47ac8c7ae9aeabda129344fecd2bf0287f3146c9 Mon Sep 17 00:00:00 2001 From: discomrade Date: Fri, 15 Oct 2021 00:52:23 +0000 Subject: [PATCH 5/7] Use stored title instead of document.title in notifications Prevents number of unreads being added to notificaiton thread name --- js/auto-reload.js | 4 ++-- js/mod/recent-posts-auto-reload.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index 5cdf12ae..3e291f01 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -242,8 +242,8 @@ $(document).ready(function(){ makeIcon('reply'); } if (notify === "all" || (notify === "mention" && $(this).find('.own_post').length)) { - var body = $(this).children('.body').html().replace(//gi, "\n"); - var n = new Notification("New reply to "+$('title').text(), {body: $('
').html(body).text()}); + var body = $(this).children('.body').html().replace(//gi, "\n"); + var n = new Notification("New reply to "+title, {body: $('
').html(body).text()}); } if ($("div.post").length > 1){ $(this).insertAfter($('div.post:not(.post-hover):last').next()).after('
'); diff --git a/js/mod/recent-posts-auto-reload.js b/js/mod/recent-posts-auto-reload.js index e2d661d2..0bad51bd 100644 --- a/js/mod/recent-posts-auto-reload.js +++ b/js/mod/recent-posts-auto-reload.js @@ -221,7 +221,7 @@ $(document).ready(function(){ // Notify on all posts, not just the first unread if (notify === "all") { var body = $(this).children('.body').html().replace(//gi, "\n"); - var n = new Notification("New reply to "+$('title').text(), {body: $('
').html(body).text()}); + var n = new Notification("New reply to "+title, {body: $('
').html(body).text()}); } if ($("div.post,div.thread").length > 1){ $(this).parent().insertBefore($($('div.post,div.thread').not('.post-hover').first()).parent()); From 58d1e37c1a4cea9d5015eaab61959cf558d4dac4 Mon Sep 17 00:00:00 2001 From: tmp-server Date: Sat, 16 Oct 2021 02:34:44 +0000 Subject: [PATCH 6/7] Fix new thread notifications breaking script Tried to access invalid child. --- js/mod/recent-posts-auto-reload.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/mod/recent-posts-auto-reload.js b/js/mod/recent-posts-auto-reload.js index 0bad51bd..0db4ea62 100644 --- a/js/mod/recent-posts-auto-reload.js +++ b/js/mod/recent-posts-auto-reload.js @@ -220,7 +220,11 @@ $(document).ready(function(){ } // Notify on all posts, not just the first unread if (notify === "all") { - var body = $(this).children('.body').html().replace(//gi, "\n"); + if ($(this).hasClass('thread')){ + var body = $(this).children('.post').children('.body').html().replace(//gi, "\n"); + } else { + var body = $(this).children('.body').html().replace(//gi, "\n"); + } var n = new Notification("New reply to "+title, {body: $('
').html(body).text()}); } if ($("div.post,div.thread").length > 1){ From 78ab47d433b12cc96d00775ab19df5f702d6de9d Mon Sep 17 00:00:00 2001 From: discomrade Date: Sun, 17 Oct 2021 21:57:12 -0100 Subject: [PATCH 7/7] Correct notification text for threads --- js/mod/recent-posts-auto-reload.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/mod/recent-posts-auto-reload.js b/js/mod/recent-posts-auto-reload.js index 0db4ea62..c16d5fdb 100644 --- a/js/mod/recent-posts-auto-reload.js +++ b/js/mod/recent-posts-auto-reload.js @@ -222,10 +222,11 @@ $(document).ready(function(){ if (notify === "all") { if ($(this).hasClass('thread')){ var body = $(this).children('.post').children('.body').html().replace(//gi, "\n"); + var n = new Notification("New thread in "+title, {body: $('
').html(body).text()}); } else { var body = $(this).children('.body').html().replace(//gi, "\n"); + var n = new Notification("New reply to "+title, {body: $('
').html(body).text()}); } - var n = new Notification("New reply to "+title, {body: $('
').html(body).text()}); } if ($("div.post,div.thread").length > 1){ $(this).parent().insertBefore($($('div.post,div.thread').not('.post-hover').first()).parent());