Commit 0824a6a0 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Provide one external API for loading the compiler: compiler.loadVersion

parent 671a90c0
......@@ -422,9 +422,9 @@ var run = function () {
// Workers cannot load js on "file:"-URLs and we get a
// "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,
// resort to non-worker version in that case.
compiler.initializeWorker(version, setVersionText);
compiler.loadVersion(true, version, setVersionText);
} else {
compiler.loadVersion(version, setVersionText);
compiler.loadVersion(false, version, setVersionText);
}
};
......
......@@ -132,7 +132,15 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
}
}
this.loadVersion = function (version, setVersionText) {
this.loadVersion = function (usingWorker, version, setVersionText) {
if (usingWorker) {
loadWorker(version, setVersionText);
} else {
loadInternal(version, setVersionText);
}
};
function loadInternal (version, setVersionText) {
Module = null;
// Set a safe fallback until the new one is loaded
compileJSON = function(source, optimize) { compilationFinished('{}'); };
......@@ -148,9 +156,9 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
window.clearInterval(check);
onCompilerLoaded(setVersionText);
}, 200);
};
}
this.initializeWorker = function (version, setVersionText) {
function loadWorker (version, setVersionText) {
if (worker !== null) {
worker.terminate();
}
......
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