added: load next note

added: message after sms
fixed: put on top before serializing
This commit is contained in:
quenousimporte 2023-07-05 13:40:13 +02:00
parent 6c2ed80992
commit a9722c1cd8
2 changed files with 19 additions and 6 deletions

View File

@ -13,8 +13,8 @@ else if (isset($_POST['action']))
switch ($action) switch ($action)
{ {
case 'sms': case 'sms':
echo file_get_contents($smsurl . $_POST['data']); $res = file_get_contents($smsurl . $_POST['data']);
echo '{}'; echo '{"result": "' . $res . '"}';
break; break;
case 'fetch': case 'fetch':

21
main.js
View File

@ -238,6 +238,11 @@ var commands = [
action: loadprevious, action: loadprevious,
shortcut: "ctrl+b" shortcut: "ctrl+b"
}, },
{
hint: "Load next note",
action: loadnext,
shortcut: "ctrl+shift+B"
},
{ {
hint: "Sort text", hint: "Sort text",
action: sortselection, action: sortselection,
@ -385,7 +390,7 @@ function sms()
queryremote({action: "sms", data: currentnote.content.replace(/\n/g, " ")}) queryremote({action: "sms", data: currentnote.content.replace(/\n/g, " ")})
.then(data => .then(data =>
{ {
console.log("SMS sent to server"); showtemporaryinfo("SMS sent. Result: '" + data.result + "'");
}); });
} }
@ -1537,12 +1542,21 @@ function loadlast()
function loadprevious() function loadprevious()
{ {
var index = localdata.indexOf(currentnote); var index = localdata.indexOf(currentnote);
if (index > -1) if (index > -1 && index < localdata.length - 1)
{ {
loadnote(localdata[index + 1].title); 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) function grep(needle)
{ {
var result = {}; var result = {};
@ -1825,6 +1839,7 @@ function save()
currentnote.pos = md.selectionStart; currentnote.pos = md.selectionStart;
currentnote.content = content; currentnote.content = content;
putontop();
window.localStorage.setItem(currentvault, JSON.stringify(localdata)); window.localStorage.setItem(currentvault, JSON.stringify(localdata));
console.log("data serialized in local storage") console.log("data serialized in local storage")
@ -1838,7 +1853,6 @@ function save()
.then(() => .then(() =>
{ {
console.log("...data saved on server"); console.log("...data saved on server");
putontop();
saved = true; saved = true;
}) })
.catch(remotecallfailed) .catch(remotecallfailed)
@ -1859,7 +1873,6 @@ function save()
} }
else else
{ {
putontop();
saved = true; saved = true;
} }
} }