Ubiquity is a Firefox plugin that let you perform a great variety of operations, simply by typing a command. You can , for example, search on the most famous search engines, send a mail or translate a word.You simply have to activate it with it's hot-key (ctrl-space) and type what you need.
This alone would make of Ubiquity an handy tool, if you do not like put your hands off the keyboard to search what you need in menus and bookmarks using the mouse, what makes of Ubiquity a really enjoyable toy is how easily you can write your own commands.
Just type "command-editor" to get a simple but effective web based editor where you can write your Ubiquity commands with Javascript. No compiling or deploy is needed you can run your command in Ubiquity as soon as you have written it.
Here is my own ubiquity command to reverse a stringselected or passed as parameter. It's only a step beyond a 'hello world' program but it shows quite well how Ubiquity works.
/* This is a template command */ CmdUtils.CreateCommand({ name: "reverse", icon: "http://example.com/example.png", homepage: "http://example.com/", author: { name: "MM", email: "MM@mm.com"}, license: "LGPL", description: "reverse example", help: "just reverse a string", takes: {"input": noun_arb_text}, preview: function( pblock, input ) { var template = "result will be: ${result}"; pblock.innerHTML = CmdUtils.renderTemplate(template, {"result": reverse(input)}); }, execute: function(input) { CmdUtils.setSelection("You selected: " + input.html); } function reverse(in){ var res = ""; for(var i=in.length;i>0;i++){ res = res + in(i); } return res; } }); |
No comments :
Post a Comment