Add helper runCompiler to app

pull/1/head
Alex Beregszaszi 8 years ago
parent 0a5dd05b6f
commit e6c5d7f7d6
  1. 28
      src/app.js

@ -483,6 +483,15 @@ var run = function () {
autoCompile = document.querySelector('#autoCompile').checked autoCompile = document.querySelector('#autoCompile').checked
}) })
function runCompiler () {
var files = {}
var target = utils.fileNameFromKey(editor.getCacheFile())
files[target] = editor.getValue()
compiler.compile(files, target)
}
var previousInput = '' var previousInput = ''
var compileTimeout = null var compileTimeout = null
var saveTimeout = null var saveTimeout = null
@ -518,28 +527,21 @@ var run = function () {
if (compileTimeout) { if (compileTimeout) {
window.clearTimeout(compileTimeout) window.clearTimeout(compileTimeout)
} }
compileTimeout = window.setTimeout(function () { compileTimeout = window.setTimeout(runCompiler, 300)
var files = {}
var target = utils.fileNameFromKey(editor.getCacheFile())
files[target] = editor.getValue()
compiler.compile(files, target)
}, 300)
} }
editor.onChangeSetup(editorOnChange) editor.onChangeSetup(editorOnChange)
$('#compile').click(function () { $('#compile').click(function () {
compiler.compile() runCompiler()
}) })
executionContext.event.register('contextChanged', this, function (context) { executionContext.event.register('contextChanged', this, function (context) {
compiler.compile() runCompiler()
}) })
executionContext.event.register('web3EndpointChanged', this, function (context) { executionContext.event.register('web3EndpointChanged', this, function (context) {
compiler.compile() runCompiler()
}) })
compiler.event.register('loadingCompiler', this, function (url, usingWorker) { compiler.event.register('loadingCompiler', this, function (url, usingWorker) {
@ -549,7 +551,7 @@ var run = function () {
compiler.event.register('compilerLoaded', this, function (version) { compiler.event.register('compilerLoaded', this, function (version) {
previousInput = '' previousInput = ''
setVersionText(version) setVersionText(version)
compiler.compile() runCompiler()
if (queryParams.get().endpointurl) { if (queryParams.get().endpointurl) {
executionContext.setEndPointUrl(queryParams.get().endpointurl) executionContext.setEndPointUrl(queryParams.get().endpointurl)
@ -611,7 +613,7 @@ var run = function () {
var optimize = document.querySelector('#optimize').checked var optimize = document.querySelector('#optimize').checked
queryParams.update({ optimize: optimize }) queryParams.update({ optimize: optimize })
compiler.setOptimize(optimize) compiler.setOptimize(optimize)
compiler.compile() runCompiler()
}) })
// ----------------- version selector------------- // ----------------- version selector-------------

Loading…
Cancel
Save