From 024b0c50cdb23389b15b28fbac5cfd276bae4d33 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 3 Dec 2019 14:14:41 -0700 Subject: [PATCH] Fix #16 --- www/js/editor.js | 24 ++++++++++++++++++++++-- www/pages/editor.html | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/www/js/editor.js b/www/js/editor.js index b88e2a1..18992ae 100644 --- a/www/js/editor.js +++ b/www/js/editor.js @@ -228,16 +228,20 @@ function savenote(callback) { closeTimeout: 2 * 60 * 1000 // two whole minutes should be enough for *any* connection. }).open(); save_in_progress = true; - + var noteid = $("#note").data("noteid"); var note = new Note(); + var append = ""; if (noteid != "") { note = NOTES.get(noteid); if (note.getSyncStatus() != "LOCAL_ONLY") { note.setSyncStatus("LOCAL_EDITED"); } + } else { + var tempuuid = Math.random() * 100000000000000000; + append = " "; } - note.setText($("#note").val()); + note.setText($("#note").val() + append); note.setModified(); NOTES.set(note); NOTES.syncAll(function () { @@ -246,6 +250,14 @@ function savenote(callback) { closeTimeout: 3000 }).open(); $("#orignote").val(note.content); + if (append != "") { + for (n in NOTES.notes) { + if (NOTES.notes[n].getText().endsWith(append)) { + $("#note").data("noteid", NOTES.notes[n].noteid); + NOTES.notes[n].setText(NOTES.notes[n].getText().replace(append, "")); + } + } + } save_in_progress = false; if (typeof callback == "function") { callback(); @@ -256,6 +268,14 @@ function savenote(callback) { closeTimeout: 3000 }).open(); $("#orignote").val(note.content); + if (append != "") { + for (n in NOTES.notes) { + if (NOTES.notes[n].getText().endsWith(append)) { + $("#note").data("noteid", NOTES.notes[n].noteid); + NOTES.notes[n].setText(NOTES.notes[n].getText().replace(append, "")); + } + } + } save_in_progress = false; if (typeof callback == "function") { callback(); diff --git a/www/pages/editor.html b/www/pages/editor.html index da02a48..4cfa70f 100644 --- a/www/pages/editor.html +++ b/www/pages/editor.html @@ -34,7 +34,7 @@
- +