List of usage examples for com.google.gwt.dom.client ScriptElement setAttribute
@Override public void setAttribute(String name, String value)
From source file:es.deusto.weblab.client.WebLabClient.java
License:Open Source License
private void loadGoogleAnalytics(String trackingCode) { final ScriptElement gaqScript = Document.get().createScriptElement("var _gaq = _gaq || [];" + "_gaq.push(['_setAccount', '" + trackingCode + "']);" + "_gaq.push(['_trackPageview']);"); final Element s = Document.get().getElementsByTagName("script").getItem(0); s.getParentNode().insertBefore(gaqScript, s); final ScriptElement ga = Document.get().createScriptElement(); ga.setSrc(("https:".equals(Window.Location.getProtocol()) ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js"); ga.setType("text/javascript"); ga.setAttribute("async", "true"); s.getParentNode().insertBefore(ga, s); }
From source file:fr.putnami.pwt.plugin.ga.client.GoogleAnalyticsImpl.java
License:Open Source License
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); }
From source file:org.cruxframework.crux.plugin.google.gtm.client.GoogleTagManager.java
License:Apache License
/** * This method must be called once in your application, to initialize the google tag manager api script. * @param userAccount/*from w w w .j a v a2 s. co m*/ */ public static void init(String containerID) { assert (!initialized) : "Google Tag Manager API was already initialized."; assert (!StringUtils.isEmpty( containerID)) : "containerID can not be null. Please initialize Google Tag Manager API using a valid containerID."; Element firstScript = Document.get().getElementsByTagName("script").getItem(0); ScriptElement config = Document.get().createScriptElement( "var dataLayer = dataLayer || [];dataLayer.push({'gtm.start':new Date().getTime(),event:'gtm.js'});"); firstScript.getParentNode().insertBefore(config, firstScript); ScriptElement script = Document.get().createScriptElement(); script.setSrc("//www.googletagmanager.com/gtm.js?id=" + containerID); script.setType("text/javascript"); script.setAttribute("async", "true"); firstScript.getParentNode().insertBefore(script, firstScript); initialized = true; }
From source file:org.geosdi.geoplatform.gui.configuration.resources.GoogleAnalyticsInjector.java
License:Open Source License
@Override public void buildAnalytics() { ScriptElement analyticsElement = createScriptElement(); analyticsElement.setText("var _gaq = _gaq || " + "[];_gaq.push(['_setAccount', '" + userAccount + "']);_gaq.push(['_trackPageview']);"); Element firstScript = getHead().getElementsByTagName("script").getItem(0); firstScript.getParentNode().insertBefore(analyticsElement, firstScript); ScriptElement script = createScriptElement(); 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); }
From source file:org.geosdi.geoplatform.gui.configuration.resources.GPAbstractInjector.java
License:Open Source License
protected static ScriptElement createScriptElement() { ScriptElement script = Document.get().createScriptElement(); script.setAttribute(ScriptKeywordEnum.SCRIPT_LANGUAGE.getValue().getKey(), ScriptKeywordEnum.SCRIPT_LANGUAGE.getValue().getValue()); script.setAttribute(ScriptKeywordEnum.SCRIPT_TYPE.getValue().getKey(), ScriptKeywordEnum.SCRIPT_TYPE.getValue().getValue()); script.setAttribute(ScriptKeywordEnum.SCRIPT_CHARSET.getValue().getKey(), ScriptKeywordEnum.SCRIPT_CHARSET.getValue().getValue()); return script; }
From source file:org.rstudio.studio.client.common.mathjax.MathJaxLoader.java
License:Open Source License
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;/*w w w . ja v a2s . c o m*/ }
From source file:org.wso2.developerstudio.codenvy.ext.esb.client.inject.ESBJavaScriptInjector.java
License:Open Source License
private static ScriptElement createScriptElement() { ScriptElement script = Document.get().createScriptElement(); script.setAttribute("language", "javascript"); return script; }