Note deletion feature added

This commit is contained in:
Christian Müller
2016-03-21 11:16:35 +01:00
parent d78cb0412b
commit 8ccf7d5a71
6 changed files with 177 additions and 161 deletions
+2 -1
View File
@@ -22,7 +22,8 @@
<textarea id="note" name="note">%CONTENT%</textarea>
<fieldset id="input-elems">
<input class="ui-elem" id="plain-password" name="plain-password" placeholder="Password for editing" type="text">&nbsp;
<input class="button ui-elem" id="publish-button" type="submit" value="Publish">
<input class="button ui-elem" id="publish-button" name="button" type="submit" value="Publish">
<input class="button ui-elem" id="delete-button" name="button" type="submit" value="Delete">
<span id="tableau">
0 words
</span>
+1
View File
@@ -18,6 +18,7 @@
<article class="bottom-space">
<h2>Changelog</h2>
<ul>
<li><strong>2016-03</strong>: Note deletion feature added.</li>
<li><strong>2015-10</strong>: NoteHub rewritten in Node.js.</li>
<li><strong>2015-10</strong>: NoteHub API and note styling discontinued due to low adoption by the user base.</li>
<li><strong>2014-09</strong>: text size setting added</li>
+7 -8
View File
@@ -4,8 +4,7 @@ var $ = function(id) {
var iosDetected = navigator.userAgent.match("(iPad|iPod|iPhone)");
var timer = null;
var timerDelay = iosDetected ? 800 : 400;
var $note, $action, $preview, $plain_password,
updatePreview, $tableau;
var $note, $action, $preview, $plain_password, $tableau;
var backendTimer;
function md2html(input) {
@@ -25,7 +24,7 @@ function onLoad() {
$preview = $("draft");
$tableau = $("tableau");
$plain_password = $("plain-password");
updatePreview = function() {
var updatePreview = function() {
clearTimeout(timer);
var content = $note.value;
var delay = Math.min(timerDelay, timerDelay * (content.length / 400));
@@ -36,6 +35,7 @@ function onLoad() {
};
if ($action == "UPDATE") updatePreview();
else {
$("delete-button").style.display = "none";
$note.value = "";
var draft = localStorage.getItem("draft");
if (draft) {
@@ -44,14 +44,13 @@ function onLoad() {
}
}
$note.onkeyup = updatePreview;
$("publish-button").onclick = function(e) {
$("delete-button").onclick = $("publish-button").onclick = function(e) {
localStorage.removeItem("draft");
self.onbeforeunload = null;;
self.onbeforeunload = null;
if ($plain_password.value != "") $("password").value = md5($plain_password.value);
$plain_password.value = null;
$("signature").value = md5($("session").value +
$note.value.replace(/[\n\r]/g, ""));
}
$("signature").value = md5($("session").value + $note.value.replace(/[\n\r]/g, ""));
};
if (iosDetected) $note.className += " ui-border";
else $note.focus();
self.onbeforeunload = saveDraft;