Created
June 2, 2018 21:45
-
-
Save wolivera/6cea94f1b036f56584aecd881f099ca4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var STORE_KEY = 'jsoneditor-text'; | |
var editor = null; | |
function loadEditor() { | |
var container = document.getElementById('jsoneditor'); | |
var options = { mode: 'code', onChange: onChange }; | |
editor = new JSONEditor(container, options); | |
editor.setText(localStorage.getItem(STORE_KEY) || JSON.stringify({})); | |
} | |
function onChange() { | |
localStorage.setItem(STORE_KEY, editor.getText()); | |
} | |
document.addEventListener('DOMContentLoaded', loadEditor, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment