mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
29 lines
739 B
HTML
29 lines
739 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>
|