com.google.gwt.dom.client.ScriptElement Java Examples

The following examples show how to use com.google.gwt.dom.client.ScriptElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomAnalyticsImpl.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void init(String userAccount) {
  Element firstScript = Document.get().getElementsByTagName("script").getItem(0);

  ScriptElement config = Document.get().createScriptElement(
      "var _gaq = _gaq || [];_gaq.push(['_setAccount', '" + userAccount
          + "']);_gaq.push (['_gat._anonymizeIp']);_gaq.push(['_trackPageview']);");

  firstScript.getParentNode().insertBefore(config, firstScript);

  ScriptElement script = Document.get().createScriptElement();

  // Add the google analytics script.
  script.setSrc(("https:".equals(Window.Location.getProtocol())
      ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js");
  script.setType("text/javascript");
  script.setAttribute("async", "true");

  firstScript.getParentNode().insertBefore(script, firstScript);
}
 
Example #2
Source File: GadgetWidget.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Loads Gadget RPC library script.
 */
private static void loadGadgetRpcScript() {
  ScriptElement script = Document.get().createScriptElement();
  script.setType("text/javascript");
  script.setSrc(GADGET_RPC_PATH);
  Document.get().getBody().appendChild(script);
}
 
Example #3
Source File: ChartJs.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Method injecting native chart.js code into the browser<br/>
 * In case code already been injected do nothing
 */
public static void ensureInjected(){ //TODO: do real injection (lazy loading)
	if(injected)
		return;
	Resources res = GWT.create(Resources.class);
	String source = res.chartJsSource().getText();
       ScriptElement scriptElement = Document.get().createScriptElement();
       scriptElement.setId("_chartjs");
       scriptElement.setInnerText(source);
       Document.get().getBody().appendChild(scriptElement);
	injected = true;
}
 
Example #4
Source File: GoogleAnalyticsImpl.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void loadAnalyticsScript() {
	ScriptElement script = Document.get().createScriptElement();
	script.setSrc(GoogleAnalyticsImpl.SCRIPT_URL);
	script.setType("text/javascript");
	script.setAttribute("async", "true");

	Element firstScript = Document.get().getElementsByTagName("script").getItem(0);
	firstScript.getParentNode().insertBefore(script, firstScript);
}
 
Example #5
Source File: PlaceHandler.java    From lumongo with Apache License 2.0 5 votes vote down vote up
private void initGA() {
	Document doc = Document.get();
	ScriptElement script = doc.createScriptElement();
	script.setSrc("https://ssl.google-analytics.com/ga.js");
	script.setType("text/javascript");
	script.setLang("javascript");
	doc.getBody().appendChild(script);
}
 
Example #6
Source File: GadgetWidget.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Loads Gadget RPC library script.
 */
private static void loadGadgetRpcScript() {
  ScriptElement script = Document.get().createScriptElement();
  script.setType("text/javascript");
  script.setSrc(GADGET_RPC_PATH);
  Document.get().getBody().appendChild(script);
}