List of usage examples for com.google.gwt.dom.client ScriptElement setAttribute
@Override public void setAttribute(String name, String value)
From source file:com.ait.toolkit.sencha.touch.client.core.JsInjector.java
License:Open Source License
private static ScriptElement createScriptElement() { ScriptElement script = Document.get().createScriptElement(); script.setAttribute("type", "text/javascript"); return script; }
From source file:com.akjava.gwt.hangout.apilist.client.APILists.java
License:Apache License
private static ScriptElement createScriptElement(String src, String content) { ScriptElement script = Document.get().createScriptElement(); script.setAttribute("type", "text/javascript"); if (src != null) { script.setAttribute("src", src); }/*w ww. j a v a 2s. c o m*/ if (content != null) { script.setText(content); } return script; }
From source file:com.data2semantics.yasgui.client.helpers.GoogleAnalytics.java
License:Open Source License
public static 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(['_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); }
From source file:com.denormans.googleanalyticsgwt.api.GoogleAnalytics.java
License:Apache License
private static boolean injectAnalytics(@Nullable final String defaultTrackerID) { if (defaultTrackerID != null) { setupDefaultTrackerID(defaultTrackerID); }/*from ww w.j a v a 2s.c o m*/ if (IsAlreadyInjected) { return true; } IsAlreadyInjected = true; boolean isAlreadyLoaded = get() != null; if (isAlreadyLoaded) { return true; } String src; if (isSSL()) { src = "https://ssl.google-analytics.com/ga.js"; } else { src = "http://www.google-analytics.com/ga.js"; } Document doc = Document.get(); ScriptElement script = doc.createScriptElement(); script.setSrc(src); script.setType("text/javascript"); script.setAttribute("async", "true"); doc.getBody().appendChild(script); return false; }
From source file:com.github.gwtbootstrap.client.ui.resources.JavaScriptInjector.java
License:Apache License
private static ScriptElement createScriptElement() { ScriptElement script = Document.get().createScriptElement(); script.setAttribute("type", "text/javascript"); script.setAttribute("charset", "UTF-8"); return script; }
From source file:com.googlecode.gflot.client.util.JavaScriptInjector.java
License:Open Source License
private static ScriptElement createScriptElement() { ScriptElement script = Document.get().createScriptElement(); script.setAttribute("language", "javascript"); return script; }
From source file:com.guit.client.ga.GoogleAnalyticsImpl.java
License:Apache License
@Override public void setAccount(String ua) { // Inject the configuration code ScriptElement config = Document.get().createScriptElement( "var _gaq = _gaq || [];_gaq.push(['_setAccount', '" + ua + "']);_gaq.push(['_trackPageview']);"); Element s = Document.get().getElementsByTagName("script").getItem(0); s.getParentNode().insertBefore(config, s); // Inject ga code ScriptElement script = Document.get().createScriptElement(); script.setSrc(("https:".equals(Window.Location.getProtocol()) ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js"); script.setType("text/javascript"); script.setAttribute("async", ""); s.getParentNode().insertBefore(script, s); }
From source file:com.gwtplatform.mvp.client.googleanalytics.GoogleAnalyticsImpl.java
License:Apache License
@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(['_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); }
From source file:com.nzv.gwt.ga.impl.GoogleAnalyticsImpl.java
License:Apache License
@Override public void init(final String userAccount) { final Element firstScript = Document.get().getElementsByTagName("script").getItem(0); final String source = "var _gaq = _gaq || [];_gaq.push(['_setAccount', '" + userAccount + "']);_gaq.push(['_trackPageview']);"; final ScriptElement config = Document.get().createScriptElement(source); firstScript.getParentNode().insertBefore(config, firstScript); final 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); }
From source file:com.pronoiahealth.olhie.resources.OlhieResourceInjector.java
License:Open Source License
/** * Creates a script element/*from w w w . j a v a2 s. c om*/ * * @return */ private static ScriptElement createScriptElement() { ScriptElement script = Document.get().createScriptElement(); script.setAttribute("type", "text/javascript"); script.setAttribute("charset", "UTF-8"); return script; }