diff --git a/src/app.js b/src/app.js index 82d124c9f1..f9cae3c84b 100644 --- a/src/app.js +++ b/src/app.js @@ -436,6 +436,27 @@ var run = function () { var renderer = new Renderer(editor, executionContext.web3(), updateFiles, udapp, executionContext, formalVerification.event, compiler.event); // eslint-disable-line + var previousInput = ''; + var compileTimeout = null; + + function editorOnChange () { + var input = editor.getValue(); + if (input === '') { + editor.setCacheFileContent(''); + return; + } + if (input === previousInput) { + return; + } + previousInput = input; + if (compileTimeout) { + window.clearTimeout(compileTimeout); + } + compileTimeout = window.setTimeout(compiler.compile, 300); + } + + editor.onChangeSetup(editorOnChange); + $('#compile').click(function () { compiler.compile(); }); @@ -453,6 +474,7 @@ var run = function () { }); compiler.event.register('compilerLoaded', this, function (version) { + previousInput = ''; setVersionText(version); compiler.compile(); initWithQueryParams(); diff --git a/src/app/compiler.js b/src/app/compiler.js index e182717835..338f0ce324 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -17,31 +17,9 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) { var compileJSON; var compilerAcceptsMultipleFiles; - var previousInput = ''; - var cachedRemoteFiles = {}; var worker = null; - var compileTimeout = null; - - function onChange () { - var input = editor.getValue(); - if (input === '') { - editor.setCacheFileContent(''); - return; - } - if (input === previousInput) { - return; - } - previousInput = input; - if (compileTimeout) { - window.clearTimeout(compileTimeout); - } - compileTimeout = window.setTimeout(compile, 300); - } - - editor.onChangeSetup(onChange); - var compile = function (missingInputs) { editor.clearAnnotations(); self.event.trigger('compilationStarted', []); @@ -67,7 +45,6 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) { this.setCompileJSON = setCompileJSON; // this is exposed for testing function onCompilerLoaded (version) { - previousInput = ''; self.event.trigger('compilerLoaded', [version]); }