Skip to content

Instantly share code, notes, and snippets.

@oscarotero
Created August 4, 2018 18:28
Show Gist options
  • Save oscarotero/36b1c7f06e94bcd4656f42b7fab6567b to your computer and use it in GitHub Desktop.
Save oscarotero/36b1c7f06e94bcd4656f42b7fab6567b to your computer and use it in GitHub Desktop.
Local storage notes
<!DOCTYPE html>
<html manifest="offline.manifest">
<head>
<meta charset="UTF-8">
<title>Notes - Save notes in your browser</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<meta name="author" content="Oscar Otero - http://oscarotero.com">
<meta name="title" content="Notes">
<meta name="description" content="Save notes in the local storage of your browser">
<meta name="keywords" content="notepad, localstorage, html5">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
textarea {
width: 100%;
height: 90%;
border: none;
resize: none;
padding: 20px;
outline: 0;
font-family: Arial;
font-size: 1em;
line-height: 1.3em;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
</style>
</head>
<body>
<textarea id="text" placeholder="Write here your notes" autofocus></textarea>
<script type="text/javascript">
var textarea = document.getElementById('text');
var note = document.location.hash.slice(1) || 'note';
if (note !== 'note') {
document.title = '"' + note + '" notes';
}
textarea.value = localStorage.getItem(note);
textarea.addEventListener('keyup', function () {
localStorage.setItem(note, this.value);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment