diff --git a/assets/css/browser-solidity.css b/assets/css/browser-solidity.css index 03a196f7eb..3379007d20 100644 --- a/assets/css/browser-solidity.css +++ b/assets/css/browser-solidity.css @@ -257,6 +257,19 @@ body { padding-left: 6em; } +#settingsView button { + background-color: #C6CFF7; + font-size: 12px; + padding: 0.25em; + margin-bottom: .5em; + color: black; + border:0 none; + border-radius: 3px; + width: 8em; + margin-right: 1em; + cursor: pointer; +} + #publishView button { background-color: #C6CFF7; font-size: 12px; diff --git a/index.html b/index.html index d874250be6..04e2d46a11 100644 --- a/index.html +++ b/index.html @@ -90,6 +90,8 @@
+ +
diff --git a/src/app.js b/src/app.js index 2e09d2b067..73339bf781 100644 --- a/src/app.js +++ b/src/app.js @@ -436,6 +436,42 @@ var run = function () { var renderer = new Renderer(editor, executionContext.web3(), updateFiles, udapp, executionContext, formalVerification.event, compiler.event); // eslint-disable-line + var autoCompile = document.querySelector('#autoCompile').checked; + + document.querySelector('#autoCompile').addEventListener('change', function () { + autoCompile = document.querySelector('#autoCompile').checked; + }); + + var previousInput = ''; + var compileTimeout = null; + + function editorOnChange () { + var input = editor.getValue(); + if (input === '') { + editor.setCacheFileContent(''); + return; + } + if (input === previousInput) { + return; + } + previousInput = input; + + if (!autoCompile) { + return; + } + + if (compileTimeout) { + window.clearTimeout(compileTimeout); + } + compileTimeout = window.setTimeout(compiler.compile, 300); + } + + editor.onChangeSetup(editorOnChange); + + $('#compile').click(function () { + compiler.compile(); + }); + executionContext.event.register('contextChanged', this, function (context) { compiler.compile(); }); @@ -449,6 +485,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]); }