aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar stysebae <32852093+stysebae@users.noreply.github.com> 2021-10-19 10:46:39 +0200
committerGravatar GitHub <noreply@github.com> 2021-10-19 10:46:39 +0200
commit85b898c623ae09d5caa88041bd8ceb26d4f1defc (patch)
tree2ac16791bc739d58b732f06c8cf60b6aefae9b18 /p/scripts
parentf96563ebb0c1e38a320eda1e7fdd8490785cd047 (diff)
Add shortcut to jump to next unread article (issue #3393) (#3891)
* Add shortcut to jump to next unread article * phpcbf Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 1707a09b8..f44692103 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -470,6 +470,21 @@ function next_entry(skipping) {
toggleContent(new_active, old_active, skipping);
}
+function next_unread_entry(skipping) {
+ const old_active = document.querySelector('.flux.current');
+ let new_active = old_active;
+ if (new_active) {
+ do new_active = new_active.nextElementSibling;
+ while (new_active && !new_active.classList.contains('not_read'));
+ if (!new_active) {
+ next_feed();
+ }
+ } else {
+ new_active = document.querySelector('.not_read');
+ }
+ toggleContent(new_active, old_active, skipping);
+}
+
function prev_feed() {
let found = false;
let adjacent = null;
@@ -568,6 +583,20 @@ function next_category() {
}
}
+function next_unread_category() {
+ const active_cat = document.querySelector('#aside_feed .category.active');
+ if (active_cat) {
+ let cat = active_cat;
+ do cat = cat.nextElementSibling;
+ while (cat && cat.getAttribute('data-unread') <= 0);
+ if (cat) {
+ delayedClick(cat.querySelector('a.title'));
+ }
+ } else {
+ first_category();
+ }
+}
+
function first_category() {
const a = document.querySelector('#aside_feed .category:not([data-unread="0"]) a.title');
delayedClick(a);
@@ -831,6 +860,16 @@ function init_shortcuts() {
}
return false;
}
+ if (k === s.next_unread_entry) {
+ if (ev.altKey) {
+ next_unread_category();
+ } else if (ev.shiftKey) {
+ next_feed();
+ } else {
+ next_unread_entry(false);
+ }
+ return false;
+ }
if (k === s.prev_entry) {
if (ev.altKey) {
prev_category();