From 626dfc523c3d005ab8097be142c55d4b962ac0d4 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 4 Mar 2020 23:02:37 -0800 Subject: [PATCH] Add ctrl+s instant update --- amanuensis/resources/editor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/amanuensis/resources/editor.js b/amanuensis/resources/editor.js index fa75aeb..64eb3f7 100644 --- a/amanuensis/resources/editor.js +++ b/amanuensis/resources/editor.js @@ -2,14 +2,14 @@ // before updating in response to a change. var nonce = 0; -function ifNoFurtherChanges(callback) { +function ifNoFurtherChanges(callback, timeout=2000) { var nonce_local = Math.random(); nonce = nonce_local; setTimeout(() => { if (nonce == nonce_local) { callback() } - }, 2500); + }, timeout); } // Initialize editor @@ -72,7 +72,10 @@ window.addEventListener("keydown", function(event) { if (String.fromCharCode(event.which).toLowerCase() == 's') { event.preventDefault(); - onContentChange(); + ifNoFurtherChanges(() => { + var article = getArticleObj(); + update(article); + }, 0); } } }); \ No newline at end of file