From a9722c1cd84b8220e5a591a5c908e5e2bac77d28 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Wed, 5 Jul 2023 13:40:13 +0200 Subject: [PATCH] added: load next note added: message after sms fixed: put on top before serializing --- handler.php | 4 ++-- main.js | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/handler.php b/handler.php index 696cc28..a7bc736 100644 --- a/handler.php +++ b/handler.php @@ -13,8 +13,8 @@ else if (isset($_POST['action'])) switch ($action) { case 'sms': - echo file_get_contents($smsurl . $_POST['data']); - echo '{}'; + $res = file_get_contents($smsurl . $_POST['data']); + echo '{"result": "' . $res . '"}'; break; case 'fetch': diff --git a/main.js b/main.js index f2363ee..4595190 100644 --- a/main.js +++ b/main.js @@ -238,6 +238,11 @@ var commands = [ action: loadprevious, shortcut: "ctrl+b" }, +{ + hint: "Load next note", + action: loadnext, + shortcut: "ctrl+shift+B" +}, { hint: "Sort text", action: sortselection, @@ -385,7 +390,7 @@ function sms() queryremote({action: "sms", data: currentnote.content.replace(/\n/g, " ")}) .then(data => { - console.log("SMS sent to server"); + showtemporaryinfo("SMS sent. Result: '" + data.result + "'"); }); } @@ -1537,12 +1542,21 @@ function loadlast() function loadprevious() { var index = localdata.indexOf(currentnote); - if (index > -1) + if (index > -1 && index < localdata.length - 1) { loadnote(localdata[index + 1].title); } } +function loadnext() +{ + var index = localdata.indexOf(currentnote); + if (index > -1 && index > 1) + { + loadnote(localdata[index - 1].title); + } +} + function grep(needle) { var result = {}; @@ -1825,6 +1839,7 @@ function save() currentnote.pos = md.selectionStart; currentnote.content = content; + putontop(); window.localStorage.setItem(currentvault, JSON.stringify(localdata)); console.log("data serialized in local storage") @@ -1838,7 +1853,6 @@ function save() .then(() => { console.log("...data saved on server"); - putontop(); saved = true; }) .catch(remotecallfailed) @@ -1859,7 +1873,6 @@ function save() } else { - putontop(); saved = true; } }