Show me the code! – By Davanum Srinivas

August 27, 2008

[Ubiquity] Load and use external javascript (Yahoo.js)

Filed under: Uncategorized — Davanum Srinivas @ 9:40 pm

Looks like we can use CmdUtils.injectJavascript to use an existing remote javascript such as the ones from Yahoo. following works like a charm!

CmdUtils.CreateCommand({
    name: "browser",
    homepage: "https://davanum.wordpress.com/",
    author: {
        name: "Davanum Srinivas",
        email: "davanum AT gmail.com"
    },
    description: "sniff browser",
    preview: function(pblock, statusText) {
        CmdUtils.injectJavascript("http://yui.yahooapis.com/2.5.1/build/yahoo/yahoo.js", 
        	Utils.safeWrapper(function() {
            	pblock.innerHTML = "Gecko engine revision number : " + 
            		CmdUtils.getWindowInsecure().YAHOO.env.ua.gecko;
        	})
        );
    },
    execute: function(statusText) {}
});

1 Comment »

  1. Hi,
    I’m trying to include the jqSOAPClient plugin by doing something like this, but I keep getting an error, saying SOAPObject is undefined…

    Any ideas?

    CmdUtils.CreateCommand({
    name: “fly-to”,
    description: “returns flights to a city from a city”,
    takes: {“to”: noun_arb_text},
    modifiers: {“from”: noun_arb_text},

    execute: function(to, modifiers) {
    CmdUtils.injectJavascript(“http://www.lorengo.com/scripts/jqSOAPClient.js”,
    Utils.safeWrapper(function(){

    var soapBody = new SOAPObject(“testObject”);

    })
    );
    }
    });

    Comment by Mike — September 4, 2008 @ 3:11 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: