Commit d18ba015 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Compiler: simplify loaded state

parent 6305c6da
...@@ -63,7 +63,13 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -63,7 +63,13 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
editor.setAnnotations(sourceAnnotations); editor.setAnnotations(sourceAnnotations);
}; };
function onCompilerLoaded (setVersionText) { function onCompilerLoaded (setVersionText, version) {
setVersionText(version);
previousInput = '';
onChange();
}
function onInternalCompilerLoaded (setVersionText) {
if (worker === null) { if (worker === null) {
var compile; var compile;
var missingInputs = []; var missingInputs = [];
...@@ -92,11 +98,9 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -92,11 +98,9 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
} }
compilationFinished(result, missingInputs); compilationFinished(result, missingInputs);
}; };
setVersionText(Module.cwrap('version', 'string', [])()); onCompilerLoaded(setVersionText, Module.cwrap('version', 'string', [])());
} }
previousInput = ''; }
onChange();
};
function compilationFinished (result, missingInputs) { function compilationFinished (result, missingInputs) {
var data; var data;
...@@ -153,7 +157,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -153,7 +157,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
return; return;
} }
window.clearInterval(check); window.clearInterval(check);
onCompilerLoaded(setVersionText); onInternalCompilerLoaded(setVersionText);
}, 200); }, 200);
} }
...@@ -166,9 +170,8 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -166,9 +170,8 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
var data = msg.data; var data = msg.data;
switch (data.cmd) { switch (data.cmd) {
case 'versionLoaded': case 'versionLoaded':
setVersionText(data.data);
compilerAcceptsMultipleFiles = !!data.acceptsMultipleFiles; compilerAcceptsMultipleFiles = !!data.acceptsMultipleFiles;
onCompilerLoaded(setVersionText); onCompilerLoaded(setVersionText, data.data);
break; break;
case 'compiled': case 'compiled':
compilationFinished(data.data, data.missingInputs); compilationFinished(data.data, data.missingInputs);
......
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