From 9a0edbc42199f874a13cb04736abf27c7cde8bff Mon Sep 17 00:00:00 2001 From: quenousimporte <76260127+quenousimporte@users.noreply.github.com> Date: Wed, 1 Feb 2023 14:19:31 +0100 Subject: [PATCH] added: use search list to ask questions --- main.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index ff275ae..9186a33 100644 --- a/main.js +++ b/main.js @@ -354,6 +354,19 @@ var snippets = [ cursor: 0 }]; +function ask(question) +{ + return new Promise( (resolve) => + { + filter.placeholder = question; + return searchinlist(["Yes", "No"]) + .then(answer => + { + resolve(answer); + }); + }); +} + function getnote(title) { return localdata.find(note => note.title == title); @@ -413,21 +426,25 @@ function includesub() if (range) { var title = linkatpos(); - if (confirm("Replace [[" + title + "]] by its content?")) + ask("Replace [[" + title + "]] by its content?") + .then( (answser) => { + if (answser != "Yes") return; + var subnote = getnote(title); md.value = md.value.substring(0, range.start) + subnote.content + md.value.substring(range.end); - if (confirm("Delete '" + title + "'?")) + ask("Delete '" + title + "'?") + .then( (answser) => { + if (answser != "Yes") return; deletenote(subnote); - } - - datachanged(); - } + }) + .finally(datachanged); + }); } }