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:
parent
b66b1f914d
commit
48e37e1c85
1 changed files with 14 additions and 6 deletions
|
|
@ -61,16 +61,24 @@ function inject() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call the inject function to load the ace files.
|
||||||
inject();
|
inject();
|
||||||
|
|
||||||
var textAce;
|
var textAce;
|
||||||
|
function initAce() {
|
||||||
setTimeout(function() {
|
|
||||||
var t = document.querySelector("textarea");
|
|
||||||
var ace = window.__ace_shadowed__;
|
var ace = window.__ace_shadowed__;
|
||||||
textAce = ace.transformTextarea(t);
|
// Check if the ace.js file was loaded already, otherwise check back later.
|
||||||
textAce.setDisplaySettings(true);
|
if (ace && ace.transformTextarea) {
|
||||||
}, 300);
|
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() {
|
document.getElementById("buBuild").onclick = function() {
|
||||||
var injectSrc = inject.toString().split("\n").join("");
|
var injectSrc = inject.toString().split("\n").join("");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue