diff --git a/main.js b/main.js index d9c79e9..84002fe 100644 --- a/main.js +++ b/main.js @@ -203,10 +203,6 @@ var commands = [ hint: "Decrypt note", action: decryptnote }, -{ - hint: "Restore deleted note", - action: restoredeleted -}, { hint: "Replace", shortcut: "ctrl+h", @@ -995,7 +991,7 @@ function sharehtml() function getfilename(title) { - return title.replace(/[\?\"<>|\*:\/\\]/g, "_") + ".md"; + return title.replace(/[\?\"<>|\*:\/\\]/g, "_"); } function download(filename, content) @@ -1050,7 +1046,7 @@ function downloadhtmlnotes() var zip = new JSZip(); Object.keys(metadata).forEach(guid => { - zip.file(getfilename(metadata[guid].title).replace(".md", ".html"), md2html(localStorage.getItem(guid))); + zip.file(getfilename(metadata[guid].title) + ".html", md2html(localStorage.getItem(guid))); }); zip.generateAsync({type:"blob"}) .then(function(content) @@ -1618,14 +1614,10 @@ function loadnext() } } -function sortedlist(deleted) +function sortedlist() { return Object .values(metadata) - .filter(i => - { - return deleted === true ? i.deleted : !i.deleted; - }) .sort( (i,j) => j.lastchanged - i.lastchanged); } @@ -2380,22 +2372,6 @@ function searchandreplace() seteditorcontent(md.value.replaceAll(oldvalue, newvalue)); } -function restoredeleted() -{ - searchinlist(sortedlist(true).map(i => i.title)) - .then(title => - { - if (confirm("Restore " + title + "?")) - { - var guid = getguid(title); - metadata[guid].deleted = false; - metadata[guid].lastchanged = Date.now(); - renameinternallinks(title + " (deleted)", title); - serializeindex(); - } - }); -} - function serializeindex() { serialize("index", JSON.stringify(metadata)); @@ -2404,10 +2380,11 @@ function serializeindex() function deletenote(title) { var guid = getguid(title); - metadata[guid].deleted = true; - metadata[guid].lastchanged = Date.now(); + delete metadata[guid]; renameinternallinks(title, title + " (deleted)"); - serializeindex() + var content = localStorage.getItem(guid); + localStorage.setItem(guid, "Deleted. Title: " + title + ". Date: " + timestamp() + "\r\n" + content); + serializeindex(); } function deletecurrentnote() @@ -2881,7 +2858,6 @@ function loadnote(title) } var content = localStorage.getItem(guid); var item = metadata[guid]; - delete item.deleted; if (item.header.tags.includes("journal")) {