Commit e6c5d7f7 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Add helper runCompiler to app

parent 0a5dd05b
...@@ -483,6 +483,15 @@ var run = function () { ...@@ -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 () { ...@@ -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 () { ...@@ -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 () { ...@@ -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-------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment