samhuri.net/public/f/note.html

29 lines
736 B
HTML

<!doctype html>
<html lang="en">
<style>
html,body { height: 100% }
#note { width: 100%; height: 100% }
</style>
<script>
var note, html, timeout;
window.addEventListener('load', function() {
note = document.getElementById('note');
html = document.getElementsByTagName('html')[0];
html.addEventListener('keyup', function(ev) {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(saveNote, 100);
});
restoreNote();
note.focus();
});
function saveNote() {
localStorage.note = note.innerText;
timeout = null;
}
function restoreNote() {
note.innerText = localStorage.note || '';
}
</script>
<h1>Notepad (type below, notes persist)</h1>
<p id="note" contenteditable></p>
</html>