From 7edb42ef834ce340e3fd60f42a10703bd1baa0ec Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Wed, 7 Feb 2024 21:52:25 +0100 Subject: [PATCH] fix load previous and next --- main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index eca43a4..5f663d9 100644 --- a/main.js +++ b/main.js @@ -1532,20 +1532,21 @@ function loadlast() function loadprevious() { - //var list = sortedlist(); - var index = localdata.indexOf(currentnote); - if (index > -1 && index < localdata.length - 1) + var list = sortedlist(); + var index = list.findIndex(i => i.title == title.value); + if (index > -1 && index < list.length - 1) { - loadnote(localdata[index + 1].title); + loadnote(list[index + 1].title); } } function loadnext() { - var index = localdata.indexOf(currentnote); + var list = sortedlist(); + var index = list.findIndex(i => i.title == title.value); if (index > -1 && index > 0) { - loadnote(localdata[index - 1].title); + loadnote(list[index - 1].title); } }