Preserve previous contents.

pull/1/head
chriseth 9 years ago
parent 9e7fe56e59
commit 1a9525c722
  1. 19
      index.html

@ -86,16 +86,27 @@ THE SOFTWARE.
var SOL_CACHE_FILES_KEY = "sol-cache-files"; var SOL_CACHE_FILES_KEY = "sol-cache-files";
var editor = ace.edit("input"); var editor = ace.edit("input");
var session = editor.getSession(); var session = editor.getSession();
var Range = ace.require('ace/range').Range; var Range = ace.require('ace/range').Range;
var errMarkerId = null; var errMarkerId = null;
var solFiles = JSON.parse( window.localStorage.getItem( SOL_CACHE_FILES_KEY ) ) || [SOL_CACHE_FILE]; var solFiles = JSON.parse( window.localStorage.getItem( SOL_CACHE_FILES_KEY ) ) || [SOL_CACHE_FILE];
if (solFiles.length === 0) solFiles = [SOL_CACHE_FILE]; if (solFiles.length === 0) solFiles = [SOL_CACHE_FILE];
window.localStorage.setItem( SOL_CACHE_FILES_KEY, JSON.stringify( solFiles ) );
var solCache = window.localStorage.getItem( SOL_CACHE_FILE ) || BALLOT_EXAMPLE; var solCache = window.localStorage.getItem( SOL_CACHE_FILE ) || BALLOT_EXAMPLE;
window.localStorage.setItem( SOL_CACHE_FILE, solCache ) window.localStorage.setItem( SOL_CACHE_FILE, solCache )
if (window.localStorage.getItem('sol-cache')) {
// Backwards-compatibility
var count = '';
while (window.localStorage.getItem('Untitled' + count))
count = (count - 0) + 1;
window.localStorage.setItem('Untitled' + count, window.localStorage.getItem('sol-cache'));
window.localStorage.removeItem('sol-cache');
solFiles.push('Untitled' + count);
}
window.localStorage.setItem( SOL_CACHE_FILES_KEY, JSON.stringify( solFiles ) );
editor.setValue( solCache, 1 ); editor.setValue( solCache, 1 );

Loading…
Cancel
Save