From af33a30ad8979a9fe12850fa2cd3573eaa7e5026 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 4 Sep 2017 16:03:07 -0400 Subject: [PATCH] handling of beforeunload - we save the note before unloading the page --- static/js/init.js | 5 +++++ static/js/note.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/static/js/init.js b/static/js/init.js index 812c0d943..d9821b90b 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -231,4 +231,9 @@ $("#jumpToNoteForm").submit(function() { } return false; +}); + +$(window).on('beforeunload', function(){ + // asynchronously send the request and don't wait for result + saveNoteIfChanged(); }); \ No newline at end of file diff --git a/static/js/note.js b/static/js/note.js index 19052f2c5..70562d393 100644 --- a/static/js/note.js +++ b/static/js/note.js @@ -212,5 +212,5 @@ function encryptNote() { // To print or store the binary data, you may convert it to hex let encryptedHex = aesjs.utils.hex.fromBytes(encryptedBytes); - console.log("encrypted: " + encryptedBytes); + console.log("encrypted: " + encryptedHex); } \ No newline at end of file