From 3150a4c3ec38a7983226eb14794a869e2da1fe28 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 31 Jan 2024 20:52:22 +0200 Subject: [PATCH] move "next post" to navbar --- files/assets/js/post_navigation.js | 23 +---------------------- files/templates/header.html | 9 +++++++++ files/templates/post.html | 15 --------------- 3 files changed, 10 insertions(+), 37 deletions(-) diff --git a/files/assets/js/post_navigation.js b/files/assets/js/post_navigation.js index 796d7e198..d1d4bbfa2 100644 --- a/files/assets/js/post_navigation.js +++ b/files/assets/js/post_navigation.js @@ -2,30 +2,9 @@ const post_permalinks = sessionStorage.getItem("post_permalinks").split(', '); const current_index = post_permalinks.indexOf(`'${location.href}'`) if (current_index > -1) { const id_after = post_permalinks[current_index+1] - const id_before = post_permalinks[current_index-1] - - if (id_before || id_after) { - document.getElementById('post_navigation').classList.remove('d-none') - } - - if (id_before) { - document.getElementById('post_before').classList.remove('disabled') - document.getElementById('post_before').href = id_before.slice(1, -1) - } if (id_after) { - document.getElementById('post_after').classList.remove('disabled') + document.getElementById('post_navigation').classList.remove('d-none') document.getElementById('post_after').href = id_after.slice(1, -1) } - - document.addEventListener('keydown', (e) => { - if (document.activeElement.tagName != 'TEXTAREA' && document.activeElement.tagName != 'INPUT') { - if (id_before && e.key == 'ArrowLeft') { - location.href = id_before.slice(1, -1) - } - else if (id_after && e.key == 'ArrowRight') { - location.href = id_after.slice(1, -1) - } - } - }) } diff --git a/files/templates/header.html b/files/templates/header.html index 8e1767ed1..37b56d19f 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -243,6 +243,15 @@