Example usage for com.google.gwt.dom.client ScriptElement getSrc

List of usage examples for com.google.gwt.dom.client ScriptElement getSrc

Introduction

In this page you can find the example usage for com.google.gwt.dom.client ScriptElement getSrc.

Prototype

public String getSrc() 

Source Link

Document

URI designating an external script.

Usage

From source file:com.vaadin.client.ResourceLoader.java

License:Apache License

/**
 * Creates a new resource loader. You should generally not create you own
 * resource loader, but instead use {@link ResourceLoader#get()} to get an
 * instance./*from ww w.ja  va 2 s  .c  om*/
 */
protected ResourceLoader() {
    Document document = Document.get();
    head = document.getElementsByTagName("head").getItem(0);

    // detect already loaded scripts and stylesheets
    NodeList<Element> scripts = document.getElementsByTagName("script");
    for (int i = 0; i < scripts.getLength(); i++) {
        ScriptElement element = ScriptElement.as(scripts.getItem(i));
        String src = element.getSrc();
        if (src != null && src.length() != 0) {
            loadedResources.add(src);
        }
    }

    NodeList<Element> links = document.getElementsByTagName("link");
    for (int i = 0; i < links.getLength(); i++) {
        LinkElement linkElement = LinkElement.as(links.getItem(i));
        String rel = linkElement.getRel();
        String href = linkElement.getHref();
        if ("stylesheet".equalsIgnoreCase(rel) && href != null && href.length() != 0) {
            loadedResources.add(href);
        }
    }
}

From source file:nz.co.doltech.gwt.sdm.SuperDevCompiler.java

License:Apache License

public Element getDevModeOnScriptElement() {
    HeadElement head = Document.get().getHead();
    NodeList<Node> childNodes = head.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node childNode = childNodes.getItem(i);
        if (Element.is(childNode)) {
            Element child = childNode.cast();
            if (ScriptElement.is(child)) {
                ScriptElement scriptElement = ScriptElement.as(child);
                String scriptSrc = scriptElement.getSrc();
                if (scriptSrc != null && scriptSrc.contains("dev_mode_on.js")) {
                    return child;
                }//from  www  . ja  v  a2  s .  c  om
            }
        }
    }
    return null;
}

From source file:org.cruxframework.crux.core.client.utils.ScriptTagHandler.java

License:Apache License

private static void processScriptTag(final ScriptElement script, final ScriptElement cloneScript,
        final ScriptLoadCallback callback) {
    handleDocWriteFunction();/*  w ww.  jav  a 2  s . c  om*/
    String src = script.getSrc();
    ScriptLoadCallback tagCallback = new ScriptLoadCallback() {
        @Override
        public void onLoaded() {
            String content = getDocWrittenContent();
            restoreDocWriteFunction();
            processNextScript(callback);
            final DivElement wrapperElement = Document.get().createDivElement();
            wrapperElement.setInnerHTML(content);
            cloneScript.getParentElement().insertAfter(wrapperElement, cloneScript);
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override
                public void execute() {
                    evaluateScripts(wrapperElement, null);
                }
            });
        }
    };

    // If it is a cross domain script, the content loading is assynchronous
    boolean xDomain = isXDomain(src);
    if (xDomain) {
        handleXDomainScriptLoad(cloneScript, tagCallback);
    }

    script.getParentElement().replaceChild(cloneScript, script);

    if (!xDomain) {
        tagCallback.onLoaded();
    }
}

From source file:org.cruxframework.crux.core.client.utils.ScriptTagHandler.java

License:Apache License

private static ScriptElement cloneScript(ScriptElement script) {
    Document doc = Document.get();
    ScriptElement cloneScript = doc.createScriptElement();
    cloneScript.setType("text/javascript");
    cloneScript.setLang("javascript");
    if (script.hasAttribute("src")) {
        cloneScript.setSrc(script.getSrc());
    } else {/*  w w w . ja  va  2  s  .  c  om*/
        getScriptInjector().copyScriptContent(script, cloneScript);
    }

    return cloneScript;
}