From e852d3b3e51b2ea5aa87c3aa958625b1597e1f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Sat, 31 Oct 2015 08:13:16 +0100 Subject: [PATCH] draft autosave finished --- resources/public/js/publishing.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/public/js/publishing.js b/resources/public/js/publishing.js index 5977440..c1377e6 100644 --- a/resources/public/js/publishing.js +++ b/resources/public/js/publishing.js @@ -15,7 +15,8 @@ function md2html(input) { } function saveDraft() { - localStorage.setItem("draft", $note.value); + console.log("draft autosave..."); + localStorage.setItem("draft", $note.value); } function onLoad() { @@ -38,15 +39,17 @@ function onLoad() { }; if ($action == "UPDATE") updatePreview(); else { + $note.value = ""; var draft = localStorage.getItem("draft"); if (draft) { $note.value = draft; updatePreview(); } } - else $note.value = ""; $note.onkeyup = updatePreview; $("publish-button").onclick = function(e) { + localStorage.removeItem("draft"); + self.onbeforeunload = null;; if ($plain_password.value != "") $("password").value = md5($plain_password.value); $plain_password.value = null; $("signature").value = md5($("session").value +