Move editor.onChange from compiler to app

pull/1/head
Alex Beregszaszi 8 years ago
parent 3cea49f6f6
commit c3e7168891
  1. 22
      src/app.js
  2. 23
      src/app/compiler.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();

@ -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]);
}

Loading…
Cancel
Save