Example usage for com.google.gwt.core.client ScriptInjector fromString

List of usage examples for com.google.gwt.core.client ScriptInjector fromString

Introduction

In this page you can find the example usage for com.google.gwt.core.client ScriptInjector fromString.

Prototype

public static FromString fromString(String scriptBody) 

Source Link

Document

Build an injection call for directly setting the script text in the DOM.

Usage

From source file:gwt.material.design.client.resources.ResourcesLoader.java

License:Apache License

private void injectJQuery(MaterialResources resources) {
    if (!isjQueryLoaded()) {
        ScriptInjector.fromString(resources.jQuery().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }//w  ww.  j a  v  a 2  s .  c  o  m
}

From source file:gwt.material.design.client.resources.ResourcesLoader.java

License:Apache License

private void injectMaterializeJs(MaterialResources resources) {
    ScriptInjector.fromString(resources.materializeJs().getText()).setWindow(ScriptInjector.TOP_WINDOW)
            .inject();
}

From source file:gwt.material.design.components.client.GwtMDC.java

License:Apache License

public static void injectJs(TextResource resource, boolean removeTag, boolean sourceUrl) {

    final String text = resource.getText() + (sourceUrl ? "//# sourceURL=" + resource.getName() + ".js" : "");

    // Inject the script resource
    ScriptInjector.fromString(text).setWindow(ScriptInjector.TOP_WINDOW).setRemoveTag(removeTag).inject();

}

From source file:io.reinert.requestor.auth.MD5.java

License:Apache License

private static void inject() {
    ScriptInjector.fromString("(function(){function n(f,d){var c=f[0],a=f[1],b=f[2],e=f[3],c=g(c,a,b,e,d[0],7,"
            + "-680876936),e=g(e,c,a,b,d[1],12,-389564586),b=g(b,e,c,a,d[2],17,606105819),a=g(a,b,e,c,d[3],22,"
            + "-1044525330),c=g(c,a,b,e,d[4],7,-176418897),e=g(e,c,a,b,d[5],12,1200080426),b=g(b,e,c,a,d[6],17,"
            + "-1473231341),a=g(a,b,e,c,d[7],22,-45705983),c=g(c,a,b,e,d[8],7,1770035416),e=g(e,c,a,b,d[9],12,"
            + "-1958414417),b=g(b,e,c,a,d[10],17,-42063),a=g(a,b,e,c,d[11],22,-1990404162),c=g(c,a,b,e,d[12],7,"
            + "1804603682),e=g(e,c,a,b,d[13],12,-40341101),\n"
            + "b=g(b,e,c,a,d[14],17,-1502002290),a=g(a,b,e,c,d[15],22,1236535329),c=k(c,a,b,e,d[1],5,-165796510),"
            + "e=k(e,c,a,b,d[6],9,-1069501632),b=k(b,e,c,a,d[11],14,643717713),a=k(a,b,e,c,d[0],20,-373897302),c=k"
            + "(c,a,b,e,d[5],5,-701558691),e=k(e,c,a,b,d[10],9,38016083),b=k(b,e,c,a,d[15],14,-660478335),a=k(a,b,"
            + "e,c,d[4],20,-405537848),c=k(c,a,b,e,d[9],5,568446438),e=k(e,c,a,b,d[14],9,-1019803690),b=k(b,e,c,a,"
            + "d[3],14,-187363961),a=k(a,b,e,c,d[8],20,1163531501),c=k(c,a,b,e,d[13],5,-1444681467),e=k(e,c,a,b,"
            + "d[2],9,-51403784),\n"
            + "b=k(b,e,c,a,d[7],14,1735328473),a=k(a,b,e,c,d[12],20,-1926607734),c=h(a^b^e,c,a,d[5],4,-378558),e=h"
            + "(c^a^b,e,c,d[8],11,-2022574463),b=h(e^c^a,b,e,d[11],16,1839030562),a=h(b^e^c,a,b,d[14],23,-35309556)"
            + ",c=h(a^b^e,c,a,d[1],4,-1530992060),e=h(c^a^b,e,c,d[4],11,1272893353),b=h(e^c^a,b,e,d[7],16,"
            + "-155497632),a=h(b^e^c,a,b,d[10],23,-1094730640),c=h(a^b^e,c,a,d[13],4,681279174),e=h(c^a^b,e,c,d[0],"
            + "11,-358537222),b=h(e^c^a,b,e,d[3],16,-722521979),a=h(b^e^c,a,b,d[6],23,76029189),c=h(a^b^e,c,a,d[9],"
            + "4,-640364487),\n"
            + "e=h(c^a^b,e,c,d[12],11,-421815835),b=h(e^c^a,b,e,d[15],16,530742520),a=h(b^e^c,a,b,d[2],23,"
            + "-995338651),c=l(c,a,b,e,d[0],6,-198630844),e=l(e,c,a,b,d[7],10,1126891415),b=l(b,e,c,a,d[14],15,"
            + "-1416354905),a=l(a,b,e,c,d[5],21,-57434055),c=l(c,a,b,e,d[12],6,1700485571),e=l(e,c,a,b,d[3],10,"
            + "-1894986606),b=l(b,e,c,a,d[10],15,-1051523),a=l(a,b,e,c,d[1],21,-2054922799),c=l(c,a,b,e,d[8],6,"
            + "1873313359),e=l(e,c,a,b,d[15],10,-30611744),b=l(b,e,c,a,d[6],15,-1560198380),a=l(a,b,e,c,d[13],21,"
            + "1309151649),c=l(c,a,b,e,\n"
            + "d[4],6,-145523070),e=l(e,c,a,b,d[11],10,-1120210379),b=l(b,e,c,a,d[2],15,718787259),a=l(a,b,e,c,"
            + "d[9],21,-343485551);f[0]=m(c,f[0]);f[1]=m(a,f[1]);f[2]=m(b,f[2]);f[3]=m(e,f[3])}function h(f,d,c,a,"
            + "b,e){d=m(m(d,f),m(a,e));return m(d<<b|d>>>32-b,c)}function g(f,d,c,a,b,e,g){return h(d&c|~d&a,f,d,b,"
            + "e,g)}function k(f,d,c,a,b,e,g){return h(d&a|c&~a,f,d,b,e,g)}function l(f,d,c,a,b,e,g){return h(c^"
            + "(d|~a),f,d,b,e,g)}function p(f){var d=f;txt=\"\";var c=d.length;f=[1732584193,-271733879,"
            + "-1732584194,271733878];\n"
            + "var a;for(a=64;a<=d.length;a+=64){for(var b=d.substring(a-64,a),e=[],g=void 0,g=0;64>g;g+=4)"
            + "e[g>>2]=b.charCodeAt(g)+(b.charCodeAt(g+1)<<8)+(b.charCodeAt(g+2)<<16)+(b.charCodeAt(g+3)<<24);n(f,"
            + "e)}d=d.substring(a-64);b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(a=0;a<d.length;a++)b[a>>2]|=d"
            + ".charCodeAt(a)<<(a%4<<3);b[a>>2]|=128<<(a%4<<3);if(55<a)for(n(f,b),a=0;16>a;a++)b[a]=0;b[14]=8*c;n"
            + "(f,b);for(d=0;d<f.length;d++){c=f[d];a=\"\";for(b=0;4>b;b++)a+=q[c>>8*b+4&15]+q[c>>8*b&15];"
            + "f[d]=a}return f.join(\"\")}function m(f,\n"
            + "d){return f+d&4294967295}var q=\"0123456789abcdef\".split(\"\");"
            + "\"5d41402abc4b2a76b9719d911017c592\"!=p(\"hello\")&&(m=function(f,d){var c=(f&65535)+(d&65535);"
            + "return(f>>16)+(d>>16)+(c>>16)<<16|c&65535});window.md5hash=p})()")
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:nz.co.doltech.gwtjui.demo.client.DemoEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    ScriptInjector.fromString(DemoClientBundle.INSTANCE.prettify().getText())
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.apache.hupa.client.Hupa.java

License:Apache License

@Override
public void onModuleLoad() {
    InstrumentationLoggerProvider.set(new gwtTestSelection.client.InstrumentationLogger());
    ScriptInjector.fromString(
            "var nameSuffix = ''; var record = false; var nodeIdCounter = 0; var bufferedNodeIdentifiers = {}; var testCaseName = window.top.location.search.substring(1); var loggingServer = new WebSocket('ws://localhost:8090/loggingServer'); loggingServer.onopen = function() {}; loggingServer.onmessage = function(evt) { if(evt.data=='0') {flushNodeIdentifiers(nameSuffix); record = false; } else if(evt.data=='1') {record = true; flushNodeIdentifiers(nameSuffix); nameSuffix = ''; } else if(evt.data!==undefined) {flushNodeIdentifiers(nameSuffix); nameSuffix = evt.data; record = true; } }; loggingServer.onclose = function() { flushNodeIdentifiers(nameSuffix) }; function flushNodeIdentifiers(nameSufx) { if(nodeIdCounter > 0) { if(loggingServer.readyState === 1) { loggingServer.send('testName='+testCaseName+'&nr='+JSON.stringify(bufferedNodeIdentifiers)+'&testSuffix='+nameSufx); bufferedNodeIdentifiers = {}; nodeIdCounter = 0; } else { setTimeout(function() { flushNodeIdentifiers(nameSuffix); },250); } } } function sendToLoggingServer(nodeIdentifier) { if(!record) {return;} bufferedNodeIdentifiers[nodeIdentifier]=nodeIdentifier; nodeIdCounter++; if(nodeIdCounter > 1200) { flushNodeIdentifiers(nameSuffix); } }")
            .setRemoveTag(false).setWindow(ScriptInjector.TOP_WINDOW).inject();
    InstrumentationLoggerProvider.get().instrument("org_apache_hupa_client_Hupa_java0x031c56b958af03dc2");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x0_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x2_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x1");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b950x1_____org_apache_hupa_client_Hupa_java0x031c56b95_____org_apache_hupa_client_Hupa_java0x031c56b950x0");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x00x0_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x0");
    handleExceptionsAsync();/*from   w ww . j  a v  a 2s .c  om*/
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x10x0_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x1");
    initApp();
}

From source file:org.bonitasoft.console.client.JsInjector.java

License:Open Source License

public void inject(String script) {
    ScriptInjector.fromString(script).setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.consoli.filesaver.client.Initializer.java

License:Apache License

@Override
public void onModuleLoad() {
    final String scriptTextFromResource = Resources.INSTANCE.fileSaverJavaScript().getText();
    final FromString inlinedScript = ScriptInjector.fromString(scriptTextFromResource);
    inlinedScript.setRemoveTag(false).setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.cruxframework.crux.core.client.html5.api.MutationObserver.java

License:Apache License

private static void injectPolyfill(ExternalTextResource resource,
        final ResourceCallback<TextResource> resourceCallback) {
    try {//from www.  j  a va2  s  .c o  m
        resource.getText(new ResourceCallback<TextResource>() {
            @Override
            public void onError(ResourceException e) {
                resourceCallback.onError(e);
            }

            @Override
            public void onSuccess(final TextResource resource) {
                ScriptInjector.fromString(resource.getText()).setWindow(ScriptInjector.TOP_WINDOW)
                        .setRemoveTag(true).inject();
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                    @Override
                    public void execute() {
                        resourceCallback.onSuccess(resource);
                    }
                });
            }
        });
    } catch (ResourceException e) {
        resourceCallback.onError(e);
    }
}

From source file:org.cruxframework.crux.plugin.bootstrap.client.ModuleLoader.java

License:Apache License

private void injectBoostrap3() {
    final CruxBootstrap3Resources resources = GWT.create(CruxBootstrap3Resources.class);

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override// w w  w .j ava  2 s. c om
        public boolean execute() {
            //Cascade Style Sheet
            String bootstrapCSS = resources.css().getText();
            String bootstrapModalCSS = resources.bootstrapModalCSS().getText();
            String bootstrapSelectCSS = resources.bootstrapSelectCSS().getText();
            String bootstrapThemeCSS = resources.themeCss().getText();
            String docsCSS = resources.docs().getText();

            StyleInjector.injectStylesheetAtStart(bootstrapCSS);
            StyleInjector.injectStylesheetAtStart(bootstrapThemeCSS);
            StyleInjector.injectStylesheetAtStart(bootstrapSelectCSS);
            StyleInjector.injectStylesheetAtStart(bootstrapModalCSS);
            StyleInjector.injectStylesheetAtStart(docsCSS);

            //JavaScript
            String bootstrapJS = resources.bootstrapJS().getText();
            String jquery = resources.jquery().getText();
            String modalJS = resources.bootstrapModal().getText();
            String modalManagerJS = resources.bootstrapModalManager().getText();
            String selectJS = resources.bootstrapSelect().getText();
            String html5shiv = resources.html5shiv().getText();

            ScriptInjector.fromString(jquery).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(bootstrapJS).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(modalManagerJS).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(modalJS).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(selectJS).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(html5shiv).setWindow(ScriptInjector.TOP_WINDOW).inject();

            resources.font().ensureInjected();

            return false;
        }
    }, 300);
}