From 624b3dde79cf8ffa51a67c3ff2f5bd8927ba388e Mon Sep 17 00:00:00 2001 From: quenousimporte <76260127+quenousimporte@users.noreply.github.com> Date: Thu, 2 Feb 2023 08:50:17 +0100 Subject: [PATCH] added: quick local/remote switch command --- main.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index 940559d..c7bbd46 100644 --- a/main.js +++ b/main.js @@ -264,7 +264,11 @@ var commands = [ shortcut: "ctrl+l" }, { - hint: "Change vault", + hint: "Select vault", + action: selectvault +}, +{ + hint: "Switch local/remote vault", action: switchvault, shortcut: "ctrl+shift+V" }, @@ -426,7 +430,7 @@ function includesub() if (range) { var title = linkatpos(); - if confirm("Replace [[" + title + "]] by its content?") + if (confirm("Replace [[" + title + "]] by its content?")) { var subnote = getnote(title); md.value = @@ -434,7 +438,7 @@ function includesub() + subnote.content + md.value.substring(range.end); - if confirm("Delete '" + title + "'?") + if (confirm("Delete '" + title + "'?")) { deletenote(subnote); datachanged(); @@ -513,15 +517,24 @@ function addtagfilter() } } +function applyvault(vault) +{ + window.localStorage.setItem("vault", vault); + init(); + datafile.hidden = vault != "sandbox"; +} + function switchvault() { - searchinlist(vaults) + applyvault(currentvault == "local" ? "remote" : "local"); +} + +function selectvault() +{ + searchinlist(vaults, null, vaults.findIndex( (v) => v == currentvault)) .then(vault => { - window.localStorage.setItem("vault", vault); - init(); - - datafile.hidden = vault != "sandbox"; + applyvault(vault); }); }