Skip to content

Instantly share code, notes, and snippets.

@sivagao
Created March 2, 2013 15:21
Show Gist options
  • Save sivagao/5071507 to your computer and use it in GitHub Desktop.
Save sivagao/5071507 to your computer and use it in GitHub Desktop.
one line with data:text/html,<html></html>
data:text/html,<html lang="en"><head><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> </head><body><h1>Notepad (type below, notes persist)</h1> <p id="note" contenteditable=""></p> </body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment