From 63286cd4ec9d06d301d9b960fac40e348bc06752 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 8 Jan 2024 11:50:27 +0100 Subject: [PATCH] refactor open bookmark --- main.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index 809f19a..cf3a13a 100644 --- a/main.js +++ b/main.js @@ -321,14 +321,7 @@ function browsebookmarks() { var bookmarks = JSON.parse(getnote("bookmarks").content); searchinlist(bookmarks.map(b => b.title)) - .then(title => - { - var url = bookmarks - .find(b => b.title == title) - .url; - - window.open(url, "_blank"); - }); + .then(openbookmark); } function purgetodo() @@ -1639,6 +1632,11 @@ function titlewithtags(note) return text; } +function openbookmark(title) +{ + window.open(JSON.parse(getnote("bookmarks").content).find(b => b.title == title).url, "_blank"); +} + function commandpalette() { searchinlist(commands @@ -1699,7 +1697,7 @@ function commandpalette() } else if (selected.prefix == "open bookmark ") { - window.open(JSON.parse(getnote("bookmarks").content).find(b => b.title == selected.text).url, "_blank"); + openbookmark(selected.text); } else {