change delete is harder
This commit is contained in:
parent
0fb64cc945
commit
13906080b5
38
main.js
38
main.js
|
@ -203,10 +203,6 @@ var commands = [
|
||||||
hint: "Decrypt note",
|
hint: "Decrypt note",
|
||||||
action: decryptnote
|
action: decryptnote
|
||||||
},
|
},
|
||||||
{
|
|
||||||
hint: "Restore deleted note",
|
|
||||||
action: restoredeleted
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
hint: "Replace",
|
hint: "Replace",
|
||||||
shortcut: "ctrl+h",
|
shortcut: "ctrl+h",
|
||||||
|
@ -995,7 +991,7 @@ function sharehtml()
|
||||||
|
|
||||||
function getfilename(title)
|
function getfilename(title)
|
||||||
{
|
{
|
||||||
return title.replace(/[\?\"<>|\*:\/\\]/g, "_") + ".md";
|
return title.replace(/[\?\"<>|\*:\/\\]/g, "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
function download(filename, content)
|
function download(filename, content)
|
||||||
|
@ -1050,7 +1046,7 @@ function downloadhtmlnotes()
|
||||||
var zip = new JSZip();
|
var zip = new JSZip();
|
||||||
Object.keys(metadata).forEach(guid =>
|
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"})
|
zip.generateAsync({type:"blob"})
|
||||||
.then(function(content)
|
.then(function(content)
|
||||||
|
@ -1618,14 +1614,10 @@ function loadnext()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortedlist(deleted)
|
function sortedlist()
|
||||||
{
|
{
|
||||||
return Object
|
return Object
|
||||||
.values(metadata)
|
.values(metadata)
|
||||||
.filter(i =>
|
|
||||||
{
|
|
||||||
return deleted === true ? i.deleted : !i.deleted;
|
|
||||||
})
|
|
||||||
.sort( (i,j) => j.lastchanged - i.lastchanged);
|
.sort( (i,j) => j.lastchanged - i.lastchanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2380,22 +2372,6 @@ function searchandreplace()
|
||||||
seteditorcontent(md.value.replaceAll(oldvalue, newvalue));
|
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()
|
function serializeindex()
|
||||||
{
|
{
|
||||||
serialize("index", JSON.stringify(metadata));
|
serialize("index", JSON.stringify(metadata));
|
||||||
|
@ -2404,10 +2380,11 @@ function serializeindex()
|
||||||
function deletenote(title)
|
function deletenote(title)
|
||||||
{
|
{
|
||||||
var guid = getguid(title);
|
var guid = getguid(title);
|
||||||
metadata[guid].deleted = true;
|
delete metadata[guid];
|
||||||
metadata[guid].lastchanged = Date.now();
|
|
||||||
renameinternallinks(title, title + " (deleted)");
|
renameinternallinks(title, title + " (deleted)");
|
||||||
serializeindex()
|
var content = localStorage.getItem(guid);
|
||||||
|
localStorage.setItem(guid, "Deleted. Title: " + title + ". Date: " + timestamp() + "\r\n" + content);
|
||||||
|
serializeindex();
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletecurrentnote()
|
function deletecurrentnote()
|
||||||
|
@ -2881,7 +2858,6 @@ function loadnote(title)
|
||||||
}
|
}
|
||||||
var content = localStorage.getItem(guid);
|
var content = localStorage.getItem(guid);
|
||||||
var item = metadata[guid];
|
var item = metadata[guid];
|
||||||
delete item.deleted;
|
|
||||||
|
|
||||||
if (item.header.tags.includes("journal"))
|
if (item.header.tags.includes("journal"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue