From cfc781721b6a64df05b9bd950ceac13bb3e2dfcb Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Wed, 17 Jan 2024 09:09:25 +0100 Subject: [PATCH] changed: clip in todo instead of bookmarks --- clipper/clipper.js | 7 +------ main.js | 43 +++++++++++++++++-------------------------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/clipper/clipper.js b/clipper/clipper.js index 70ecb03..da5bc81 100644 --- a/clipper/clipper.js +++ b/clipper/clipper.js @@ -1,10 +1,5 @@ javascript: (function() { var notesurl = ""; - var bm = { - 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"); + window.open("https://" + notesurl + "?c=" + encodeURIComponent(document.location.href), "_blank", "popup,width=100,height=100"); })(); diff --git a/main.js b/main.js index ec6eafc..856f82a 100644 --- a/main.js +++ b/main.js @@ -228,7 +228,7 @@ var commands = [ }, { hint: "Insert text in todo", - action: inserttodo + action: promptinserttodo }, { hint: "Edit pgp keys", @@ -1123,19 +1123,24 @@ function headerandtext(note) 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:"); if (text) { - var todo = getorcreate("todo", ""); - var split = headerandtext(todo); - todo.content = split.header + text + "\n" + split.text; - if (todo == currentnote) - { - seteditorcontent(todo.content, true); - } - datachanged(); + inserttodo(text); } } @@ -1208,28 +1213,14 @@ function loadstorage() if (clip) { - var bmnote = getorcreate("bookmarks"); - 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); - + settings.savedelay = 0; colored.hidden = true; md.hidden = true; var msg = document.createElement("div"); msg.innerText = "Clipping..."; notepage.appendChild(msg); - saved = false; - return save() + inserttodo(clip) .then(window.close); }