diff --git a/main.js b/main.js index 9753449..75a6f0d 100644 --- a/main.js +++ b/main.js @@ -190,11 +190,6 @@ var commands = [ hint: "Download all notes (json file)", action: downloadnotesjson }, -{ - hint: "Download all notes (encrypted json file)", - action: downloadencrypted, - remoteonly: true -}, { hint: "Insert text in todo", action: promptinserttodo @@ -767,11 +762,6 @@ function clickeditor() var word, link; if (event.ctrlKey) { - if (!saved) - { - console.log("Not saved, ctrl+click ignored."); - return; - } link = linkatpos(); var tag = tagatpos(); word = wordatpos(); @@ -914,10 +904,10 @@ function tagslist() { tags = {}; - localdata + Object.values(metadata) .forEach(n => { - var ts = gettags(n); + var ts = n.header.tags; ts.forEach(t => { tags[t] = tags[t] || []; @@ -999,9 +989,9 @@ function download(filename, content) function downloadnotes() { var zip = new JSZip(); - localdata.forEach(note => + Object.keys(metadata).forEach(guid => { - zip.file(getfilename(note.title), note.content); + zip.file(getfilename(metadata[guid].title), localStorage.getItem(guid)); }); zip.generateAsync({type:"blob"}) .then(function(content) @@ -1013,9 +1003,9 @@ function downloadnotes() function downloadhtmlnotes() { var zip = new JSZip(); - localdata.forEach(note => + Object.keys(metadata).forEach(guid => { - zip.file(getfilename(note.title).replace(".md", ".html"), md2html(note.content)); + zip.file(getfilename(metadata[guid].title).replace(".md", ".html"), md2html(localStorage.getItem(guid))); }); zip.generateAsync({type:"blob"}) .then(function(content) @@ -1079,15 +1069,6 @@ function downloadnotesjson() download("notes-" + timestamp() + ".json", window.localStorage.getItem("data")); } -function downloadencrypted() -{ - encryptstring(JSON.stringify(localdata)) - .then(encrypted => - { - download("notes-encrypted-" + timestamp() + ".acs", encrypted); - }); -} - function downloadnotewithsubs() { var note = withsubs(); @@ -1224,10 +1205,11 @@ function loadsettings() function checksaved() { - if (!saved) + // todo + /*if (!saved) { return "not saved"; - } + }*/ } function initsnippets() @@ -1442,9 +1424,9 @@ function getlinesrange() function backlinks() { - searchinlist(localdata - .filter(n => n.content.includes("[[" + title.value + "]]")) - .map(n => n.title)) + searchinlist(Object.keys(metadata) + .filter(guid => localStorage.getItem(guid).includes("[[" + title.value + "]]")) + .map(guid => metadata[guid].title)) .then(loadnote); } @@ -2780,19 +2762,9 @@ function togglepreview() function withsubs() { + // todo: handle loops var currentguid = getguid(title.value); - // probe for infinite loop - try - { - descendants(currentguid); - } - catch (err) - { - showtemporaryinfo(err); - return null; - } - var content = md.value; var kids = children(currentguid); while (kids.length)