added: open note if url param

This commit is contained in:
quenousimporte 2023-05-22 14:04:35 +02:00
parent b3296f2b4d
commit 4a30a5d728
1 changed files with 12 additions and 2 deletions

14
main.js
View File

@ -1039,10 +1039,20 @@ function loadstorage()
var item = window.localStorage.getItem(currentvault); var item = window.localStorage.getItem(currentvault);
localdata = item ? JSON.parse(item) : []; localdata = item ? JSON.parse(item) : [];
// only refresh content? var urlparam = (new URLSearchParams(window.location.search)).get("n");
if (currentnote) if (currentnote)
{ {
currentnote = localdata.find(n => n.title == currentnote.title); currentnote = getnote(currentnote.title);
}
else if (urlparam)
{
currentnote = getnote(urlparam);
if (!currentnote)
{
currentnote = {title: urlparam, content: ""};
localdata.unshift(currentnote);
}
} }
if (currentnote) if (currentnote)