changed: clip in todo instead of bookmarks

This commit is contained in:
quenousimporte 2024-01-17 09:09:25 +01:00
parent 5bb7742d15
commit cfc781721b
2 changed files with 18 additions and 32 deletions

View File

@ -1,10 +1,5 @@
javascript: (function() javascript: (function()
{ {
var notesurl = ""; var notesurl = "";
var bm = { window.open("https://" + notesurl + "?c=" + encodeURIComponent(document.location.href), "_blank", "popup,width=100,height=100");
title: document.title,
url: document.location.href,
time: Date.now()
};
window.open("https://" + notesurl + "?c=" + encodeURIComponent(JSON.stringify(bm)), "_blank", "popup,width=100,height=100");
})(); })();

43
main.js
View File

@ -228,7 +228,7 @@ var commands = [
}, },
{ {
hint: "Insert text in todo", hint: "Insert text in todo",
action: inserttodo action: promptinserttodo
}, },
{ {
hint: "Edit pgp keys", hint: "Edit pgp keys",
@ -1123,19 +1123,24 @@ function headerandtext(note)
return result; return result;
} }
function inserttodo() function inserttodo(text)
{
var todo = getorcreate("todo", "");
var split = headerandtext(todo);
todo.content = split.header + text + "\n" + split.text;
if (todo == currentnote)
{
seteditorcontent(todo.content, true);
}
return datachanged();
}
function promptinserttodo()
{ {
var text = prompt("Text:"); var text = prompt("Text:");
if (text) if (text)
{ {
var todo = getorcreate("todo", ""); inserttodo(text);
var split = headerandtext(todo);
todo.content = split.header + text + "\n" + split.text;
if (todo == currentnote)
{
seteditorcontent(todo.content, true);
}
datachanged();
} }
} }
@ -1208,28 +1213,14 @@ function loadstorage()
if (clip) if (clip)
{ {
var bmnote = getorcreate("bookmarks"); settings.savedelay = 0;
var newbookmark = JSON.parse(clip);
var date = new Date(newbookmark.time).toDateString();
bmnote.content += "\n\n";
if (!bmnote.content.includes(date))
{
bmnote.content += date + "\n\n";
}
bmnote.content += newbookmark.title + "\n";
bmnote.content += newbookmark.url;
bmnote.pos = bmnote.content.length;
bindfile(bmnote);
colored.hidden = true; colored.hidden = true;
md.hidden = true; md.hidden = true;
var msg = document.createElement("div"); var msg = document.createElement("div");
msg.innerText = "Clipping..."; msg.innerText = "Clipping...";
notepage.appendChild(msg); notepage.appendChild(msg);
saved = false; inserttodo(clip)
return save()
.then(window.close); .then(window.close);
} }