From cbb75404f30cfe2925a7b961a03d80aba8b7d535 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 7 Sep 2016 19:36:50 +0100 Subject: [PATCH 1/4] Make buttons in settingsView look the same as in publishView --- assets/css/browser-solidity.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; From 3cea49f6f6783f489b9164f136a93d3ef2dd1bc8 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 7 Sep 2016 19:36:59 +0100 Subject: [PATCH 2/4] Introduce compile button --- index.html | 1 + src/app.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/index.html b/index.html index ed660a6058..038bada604 100644 --- a/index.html +++ b/index.html @@ -91,6 +91,7 @@
+
diff --git a/src/app.js b/src/app.js index 1bd505602e..82d124c9f1 100644 --- a/src/app.js +++ b/src/app.js @@ -436,6 +436,10 @@ var run = function () { var renderer = new Renderer(editor, executionContext.web3(), updateFiles, udapp, executionContext, formalVerification.event, compiler.event); // eslint-disable-line + $('#compile').click(function () { + compiler.compile(); + }); + executionContext.event.register('contextChanged', this, function (context) { compiler.compile(); }); From c3e716889146e947a351d40fccd34743e70ec4f9 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 7 Sep 2016 19:50:19 +0100 Subject: [PATCH 3/4] Move editor.onChange from compiler to app --- src/app.js | 22 ++++++++++++++++++++++ src/app/compiler.js | 23 ----------------------- 2 files changed, 22 insertions(+), 23 deletions(-) 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]); } From f3864763931ef8105729281738dc7a85f7fe2cda Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 7 Sep 2016 19:52:31 +0100 Subject: [PATCH 4/4] Support disabling automatic code compilation --- index.html | 1 + src/app.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/index.html b/index.html index 038bada604..92182f0dc4 100644 --- a/index.html +++ b/index.html @@ -91,6 +91,7 @@
+
diff --git a/src/app.js b/src/app.js index f9cae3c84b..fab4062997 100644 --- a/src/app.js +++ b/src/app.js @@ -436,6 +436,12 @@ 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; @@ -449,6 +455,11 @@ var run = function () { return; } previousInput = input; + + if (!autoCompile) { + return; + } + if (compileTimeout) { window.clearTimeout(compileTimeout); }