From d18ba0156a3d0f9aea685224bc6e6a1afbaac7fd Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 3 Jun 2016 21:22:18 +0100 Subject: [PATCH] Compiler: simplify loaded state --- src/app/compiler.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/compiler.js b/src/app/compiler.js index 29ef1efc30..1b1e48fffb 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -63,7 +63,13 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles editor.setAnnotations(sourceAnnotations); }; - function onCompilerLoaded (setVersionText) { + function onCompilerLoaded (setVersionText, version) { + setVersionText(version); + previousInput = ''; + onChange(); + } + + function onInternalCompilerLoaded (setVersionText) { if (worker === null) { var compile; var missingInputs = []; @@ -92,11 +98,9 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles } compilationFinished(result, missingInputs); }; - setVersionText(Module.cwrap('version', 'string', [])()); + onCompilerLoaded(setVersionText, Module.cwrap('version', 'string', [])()); } - previousInput = ''; - onChange(); - }; + } function compilationFinished (result, missingInputs) { var data; @@ -153,7 +157,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles return; } window.clearInterval(check); - onCompilerLoaded(setVersionText); + onInternalCompilerLoaded(setVersionText); }, 200); } @@ -166,9 +170,8 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles var data = msg.data; switch (data.cmd) { case 'versionLoaded': - setVersionText(data.data); compilerAcceptsMultipleFiles = !!data.acceptsMultipleFiles; - onCompilerLoaded(setVersionText); + onCompilerLoaded(setVersionText, data.data); break; case 'compiled': compilationFinished(data.data, data.missingInputs);