From 9b674e7e9390d19c1a9686710d78164a41ad31d1 Mon Sep 17 00:00:00 2001 From: maTh Date: Sun, 20 Nov 2022 15:10:33 +0100 Subject: Improved: show bigmarkasread button only, when there are unread articles (#4681) * function toggle_bigMarkAsRead_button() * nothing_to_load text outside of bigmarkasread button * improved * fix * Update p/scripts/main.js Co-authored-by: Alexandre Alapetite Co-authored-by: Alexandre Alapetite --- p/scripts/main.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'p') diff --git a/p/scripts/main.js b/p/scripts/main.js index 436796b52..bf2c56f56 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -264,6 +264,7 @@ function send_mark_read_queue(queue, asRead, callback) { incUnreadsTag(tagId, (asRead ? -1 : 1) * json.tags[tagId].length); } } + toggle_bigMarkAsRead_button(); onScroll(); if (callback) { callback(); @@ -1661,6 +1662,23 @@ function refreshUnreads() { req.send(); } +function toggle_bigMarkAsRead_button() { + const bigMarkAsRead_button = document.getElementById('bigMarkAsRead'); + if (bigMarkAsRead_button) { + if (document.querySelector('.flux.not_read') != null) { + bigMarkAsRead_button.style = ''; + bigMarkAsRead_button.querySelector('.markAllRead').style.visibility = ''; + } else { + if (bigMarkAsRead_button.querySelector('.jumpNext')) { + bigMarkAsRead_button.querySelector('.markAllRead').style.visibility = 'hidden'; + } else { + bigMarkAsRead_button.querySelector('.markAllRead').style.visibility = ''; + bigMarkAsRead_button.style.visibility = 'hidden'; + } + } + } +} + // let url_load_more = ''; let load_more = false; @@ -1697,6 +1715,7 @@ function load_more_posts() { } else { bigMarkAsRead.formAction = readAll.formAction; } + toggle_bigMarkAsRead_button(); } document.querySelectorAll('[id^=day_]').forEach(function (div) { @@ -1849,6 +1868,7 @@ function init_main_afterDOM() { init_posts(); init_nav_entries(); init_notifs_html5(); + toggle_bigMarkAsRead_button(); setTimeout(faviconNbUnread, 1000); setInterval(refreshUnreads, 120000); } -- cgit v1.2.3