Make the init process in editor_textarea.html more robust in cases where the ace.js isn't loaded in 300ms

This commit is contained in:
Julian Viereck 2011-02-15 20:20:09 +08:00 committed by Fabian Jakobs
commit 48e37e1c85

View file

@ -61,16 +61,24 @@ function inject() {
});
}
// Call the inject function to load the ace files.
inject();
var textAce;
setTimeout(function() {
var t = document.querySelector("textarea");
function initAce() {
var ace = window.__ace_shadowed__;
textAce = ace.transformTextarea(t);
textAce.setDisplaySettings(true);
}, 300);
// Check if the ace.js file was loaded already, otherwise check back later.
if (ace && ace.transformTextarea) {
var t = document.querySelector("textarea");
textAce = ace.transformTextarea(t);
textAce.setDisplaySettings(true);
} else {
setTimeout(initAce, 100);
}
}
// Transform the textarea on the page into an ace editor.
initAce();
document.getElementById("buBuild").onclick = function() {
var injectSrc = inject.toString().split("\n").join("");