Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity Source Tip Author Tutorial

175 bytes added, 01:45, 22 June 2009
Setting the Selection
<pre>
CmdUtils.CreateCommand({
namenames: ["insert date"],
execute: function() {
var date = new Date();
<pre>
CmdUtils.CreateCommand({
namenames: ["insert date"],
_date: function(){
<pre>
CmdUtils.CreateCommand({
namenames: ["insert date"],
homepage: "http://azarask.in/",
author: { name: "Aza Raskin", email: "aza@mozilla.com"},
<pre>
CmdUtils.CreateCommand({
namenames: ["insert date"],
homepage: "http://azarask.in/",
author: { name: "Aza Raskin", email: "aza@mozilla.com"},
</pre>
The <code>.description</code> and <code>.help</code> attributes are both automatically displayed alongside your command's name on the command-list page. (The user can get to this page at any time by issuing the "command-listubiquity commands" command.) HTML tags can be used in both of these strings.
Description is a one-line summary of what the command does, while Help is a longer description that can include examples, caveats, and so on. If your command is simple enough that all you have to say about it fits in one line, it's OK to use a description alone and leave out the help.
In this command, we use the Google [http://code.google.com/apis/maps/documentation/staticmaps/ static map API] and the Ubiquity function <code>CmdUtils.getGeoLocation()</code> to insert a map of your current location. Ubiquity currently uses the [http://www.maxmind.com/app/api MaxMind] API for trying to guess your location from your IP. That will probably change in the future.
 
We'll call this command <code>"map me"</code> so that it won't be confused with the standard <code>"map"</code> command.
<pre>
CmdUtils.CreateCommand({
namenames: ["map-me"],
_getMapUrl: function() {
1,007
edits

Navigation menu