Skip to content

Instantly share code, notes, and snippets.

@wolivera
Created June 2, 2018 21:45
Show Gist options
  • Save wolivera/6cea94f1b036f56584aecd881f099ca4 to your computer and use it in GitHub Desktop.
Save wolivera/6cea94f1b036f56584aecd881f099ca4 to your computer and use it in GitHub Desktop.
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