From 833f2e5adecd78547fbe526d80118a0062f02436 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Sat, 3 Oct 2015 09:39:14 +0000 Subject: [PATCH] save changes even on error --- index.html | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 590a905c86..d15e49300e 100644 --- a/index.html +++ b/index.html @@ -286,15 +286,19 @@ THE SOFTWARE. var previousInput = ''; var sourceAnnotations = []; var compile = function() { + editor.getSession().clearAnnotations(); sourceAnnotations = []; editor.getSession().removeMarker(errMarkerId); - $('#output').empty(); - var input = editor.getValue(); - var inputIncludingImports = includeLocalImports( input ); - var optimize = document.querySelector('#optimize').checked; - try { - var data = $.parseJSON(compileJSON(inputIncludingImports, optimize ? 1 : 0)); + $('#output').empty(); + var input = editor.getValue(); + window.localStorage.setItem( SOL_CACHE_FILE, input ); + + var inputIncludingImports = includeLocalImports( input ); + var optimize = document.querySelector('#optimize').checked; + + try { + var data = $.parseJSON(compileJSON(inputIncludingImports, optimize ? 1 : 0)); } catch (exception) { renderError("Uncaught JavaScript Exception:\n" + exception); return; @@ -309,11 +313,12 @@ THE SOFTWARE. renderContracts(data, input); } + var compileTimeout = null; var onChange = function() { var input = editor.getValue(); if (input === "") { - window.localStorage.setItem( SOL_CACHE_FILE, '' ) + window.localStorage.setItem( SOL_CACHE_FILE, '' ) return; } if (input === previousInput) @@ -411,8 +416,6 @@ THE SOFTWARE. }; var renderContracts = function(data, source) { - window.localStorage.setItem( SOL_CACHE_FILE, source ); - $('#output').empty(); for (var contractName in data.contracts) { var contract = data.contracts[contractName];