Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Javascript: My first Mozilla Ubiquity Command

with one comment

I learned about Mozilla Ubiquity yesterday through my colleague Arnab Deka and I read the article about on the bus on my way back home on Instapaper iPhone application and I installed it a little over an hour ago and I am already loving it.

It already comes a lot of command built in but when I looked for a dictionary look-up command I didn’t find it. The closed was the define command which takes you to

I thought this was a good way to add my favorite look up command and familiarize myself with how to add a new ubiquity command.

Here is what I came up with in less than 15 minutes using the template and tutorial:

/* This is Ali Rizvi's ubiquity first command */
  name: "dictionary",
  // icon: "",
  homepage: "",
  author: { name: "Ali Rizvi", email: ""},
  license: "Ruby License",
  description: "Command to lookup a work on",
  help: "dictionary <word-to-lookup>",
  takes: {"input": noun_arb_text},
  preview: function( pblock, input ) {
    searchText = jQuery.trim(input.text);
    if(searchText.length < 1) {
      pblock.innerHTML = "Searches for word on";
    var previewTemplate = "Searches for <b>${query}</b>";
    var previewData = {query: searchText};
    pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
  execute: function(input) {
    var url = "{QUERY}";
    var query = input.text ;
    var urlString = url.replace("{QUERY}", query);

When I hit the save button ubiquity command editor posted this gist. Anybody know how to add js syntax highlighting on github gists?


Written by imsaar

January 28, 2009 at 8:56 pm

Posted in javascript

One Response

Subscribe to comments with RSS.

  1. Hey, looks good.


    February 1, 2009 at 5:14 pm

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: