refactor remove useless window

change logs
This commit is contained in:
quenousimporte 2024-02-16 15:04:36 +01:00
parent c425725423
commit d767f80874
1 changed files with 10 additions and 7 deletions

17
main.js
View File

@ -356,7 +356,7 @@ function pushitem(key, value)
{
unsavedmark.hidden = false;
pending[key] = true;
var name = metadata[key] ? metadata[key].title : key;
var name = metadata && metadata[key] ? metadata[key].title : key;
queryremote({action: "push", name: key, data: value})
.then( () =>
@ -383,6 +383,9 @@ function serialize(key, value)
{
localStorage.setItem(key, value);
var name = metadata && metadata[key] ? metadata[key].title : key;
console.log("'" + name + "' serialized locally");
if (settings.sync)
{
pushitem(key, value);
@ -496,7 +499,7 @@ function showinfo()
function savesettings()
{
window.serialize("settings", JSON.stringify(settings));
localStorage.setItem("settings", JSON.stringify(settings));
}
function descendants(note)
@ -1422,6 +1425,7 @@ function init()
window.onbeforeunload = checksaved;
window.onclick = focuseditor;
title.value = "";
initsnippets();
@ -1509,7 +1513,7 @@ function queryremote(params)
}
var paramstring = paramlist.join("&");
console.log("http request length: " + formatsize(paramstring.length));
console.log("http '" + encparams.action + "' request length: " + formatsize(paramstring.length));
xhr.send(paramstring);
});
});
@ -1901,7 +1905,7 @@ function flush()
clearTimeout(workerid);
workerid = null;
var guid = getguid(window.title.value);
var guid = getguid(title.value);
if (guid)
{
var item = metadata[guid];
@ -1921,11 +1925,10 @@ function flush()
}
else if (title.value == "pgpkeys")
{
serialize("pgpkeys", md.value);
localStorage.setItem("pgpkeys", md.value);
}
unsavedmark.hidden = Object.keys(pending).length == 0;
console.log("'" + title.value + "' serialized locally");
}
function escapeHtml(unsafe) {
@ -2630,7 +2633,7 @@ function renameinternallinks(from, to)
if (content != newcontent)
{
serialize(guid, newcontent);
if (item.title == window.title.value)
if (item.title == title.value)
{
seteditorcontent(newcontent);
}