From 5811ac8f16b21f6ace46c91be7a5bea517c84cdc Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 3 Jun 2016 20:29:38 +0100 Subject: [PATCH] Move all compiler primitives to compiler.js from app.js --- src/app.js | 12 +----------- src/app/compiler.js | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/app.js b/src/app.js index e0991efe5f..9f6cbd81ce 100644 --- a/src/app.js +++ b/src/app.js @@ -424,17 +424,7 @@ var run = function () { // resort to non-worker version in that case. compiler.initializeWorker(version, setVersionText); } else { - Module = null; - compiler.setCompileJSON() - var newScript = document.createElement('script'); - newScript.type = 'text/javascript'; - newScript.src = 'https://ethereum.github.io/solc-bin/bin/' + version; - document.getElementsByTagName('head')[0].appendChild(newScript); - var check = window.setInterval(function () { - if (!Module) return; - window.clearInterval(check); - compiler.onCompilerLoaded(setVersionText); - }, 200); + compiler.loadVersion(version, setVersionText); } }; diff --git a/src/app/compiler.js b/src/app/compiler.js index 21cb9cd9e4..048a4f93e4 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -63,9 +63,10 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles editor.setAnnotations(sourceAnnotations); }; - this.setCompileJSON = function () { - compileJSON = function (source, optimize) { compilationFinished('{}'); }; + function setCompileJSON () { + compileJSON = function(source, optimize) { compilationFinished('{}'); }; }; + this.setCompileJSON = setCompileJSON; function onCompilerLoaded (setVersionText) { if (worker === null) { @@ -136,6 +137,22 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles } } + this.loadVersion = function (version, setVersionText) { + Module = null; + setCompileJSON(); + var newScript = document.createElement('script'); + newScript.type = 'text/javascript'; + newScript.src = url; + document.getElementsByTagName('head')[0].appendChild(newScript); + var check = window.setInterval(function () { + if (!Module) { + return; + } + window.clearInterval(check); + onCompilerLoaded(setVersionText); + }, 200); + }; + this.initializeWorker = function (version, setVersionText) { if (worker !== null) { worker.terminate();