use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.
the class DiffMatchPatch method injectJavascript.
private static void injectJavascript(String source) {
Document doc = Document.get();
HeadElement head = (HeadElement) doc.getElementsByTagName("head").getItem(0);
if (head == null) {
head = doc.createHeadElement();
doc.insertBefore(head, doc.getBody());
}
ScriptElement script = doc.createScriptElement(source);
script.setType("text/javascript");
head.appendChild(script);
}
use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.
the class ExternalJavaScriptLoader method startLoading.
private void startLoading() {
assert state_ == State.Start;
ScriptElement script = document_.createScriptElement();
script.setType("text/javascript");
script.setSrc(url_);
registerCallback(script);
Element head = document_.getElementsByTagName("head").getItem(0);
head.appendChild(script);
}
use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.
the class MathJaxLoader method createMathJaxScriptElement.
private static ScriptElement createMathJaxScriptElement() {
ScriptElement el = Document.get().createScriptElement();
el.setAttribute("type", "text/javascript");
el.setSrc("mathjax/MathJax.js?config=TeX-MML-AM_CHTML");
el.setAttribute("async", "true");
return el;
}
use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.
the class MathJaxLoader method ensureMathJaxLoaded.
public static void ensureMathJaxLoaded() {
if (MATHJAX_LOADED)
return;
initializeMathJaxConfig();
ScriptElement mathJaxEl = createMathJaxScriptElement();
HeadElement headEl = Document.get().getHead();
headEl.appendChild(mathJaxEl);
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
if (isMathJaxReady()) {
MATHJAX_LOADED = true;
for (Callback callback : MATHJAX_CALLBACKS) callback.onLoaded(false);
onMathJaxLoaded();
return false;
}
RETRY_COUNT++;
return RETRY_COUNT < 50;
}
}, 500);
}
Aggregations