Monthly Archives: September 2008

Playing with Ubiquity

Mozilla’s Ubiquity seems like a fairly neat idea.  It has its rough edges and glitches, but the idea seems promising.  I decided to give it a shot, and make a command to lookup bus routes here in Seattle.

    name: "bus-schedule",
    takes: {"route": noun_arb_text},
    icon: "",
    homepage: "",
    author: {name: "Adam Sanderson", email: ""},
    license: "MPL",
    description: "Look up King County Metro bus route",
    help: "Select a bus route",

    _url: function(directObject){
      var url = "{QUERY}"
      var urlString = url.replace("{QUERY}", directObject.text);
      return urlString;

    execute: function(directObject){
        var urlString = this._url(directObject);

    preview: function(pblock, directObject){
        searchText = jQuery.trim(directObject.text);
        if(searchText.length <= 0) {
          pblock.innerHTML = "Look up King County Metro bus route";
        } else {
          jQuery.get( this._url(directObject), function(res) {
            var previewTemplate = "Look up route ${query} (${ok})";
            var ok = !res.match("No Schedule") ? "<em>Found</em>" : "<em> Not Found</em>";
            var previewData = {query: searchText, ok: ok};
            pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);

One thing I really like about Ubiquity is that you can get a fairly rich preview.  This command for instance lets you know if the bus route you’re looking for is listed, not rocket science, but handy all the same.  For a nicely formatted version of this command, or to install it, check out the gist.

One thing left me a little puzzled about Ubiquity, why another text interface?  We already have the url bar, couldn’t Ubiquity launch from there?

1 Comment

Filed under Uncategorized