Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity Source Tip Author Tutorial

121 bytes added, 03:27, 22 June 2009
Insert Email: Commands with Specific Argument Types
== Insert Email: Commands with Specific Argument Types ==
Let's take a look at one of the special these noun-types: <code>noun_type_contact</code>. This lets Ubiquity know to expect a person (either by name or email address). By using the noun-type, Ubiquity will also autocomplete to known people while the user is entering the command. This is what the built-in Ubiquity command "email" uses.
At the moment, Ubiquity figures out what people you know through reading your Gmail contacts. In this prototyped version, you'll need to use Gmail and be logged in for for Ubiquity to know who you know. Eventually, we'd like to be able to interface with all major web-mail sites, as well as desktop software like Thunderbird.
<pre>
CmdUtils.CreateCommand({
namenames: ["insert-email"], takesarguments: {"person"modifier: noun_type_contact},
preview: "Inserts someone's email address by name.",
execute: function( email arguments ) { CmdUtils.setSelection( emailarguments.modifier.text );
}
});
</pre>
 
To try this out, Ubiq "insert email for " and then the first few letters of someone you email often.
This one command sums up what I love about Ubiquity. In 8 lines of code, I can fundamentally enhance the browser's functionality. Doing the same thing using a normal Firefox extension methodology takes pages and pages of code&mdash;and the interface would take more thought still. Doing the same thing using a bookmarklet would require a server-side component (to get around cross-site Ajax request ban) as well as forcing the user to give up their email password.
1,007
edits

Navigation menu