Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity 0.5 Author Tutorial

32 bytes added, 02:27, 29 July 2010
Echo: arguments -> args
nountype: noun_arb_text,
label: "your shout"}],
preview: functionpreviewEcho( pblock, arguments args) { pblock.innerHTML = _("Will echo: ") + argumentsargs.object.text; }, execute: function executeEcho(args) { var msg = args.object.text + "... " + args.object.text + "......"; displayMessage(msg);
},
execute: function( arguments ) {
var msg = arguments.object.text + "... " + arguments.object.text + "......";
displayMessage( msg );
}
});
</pre>
When your preview method is called, it is passed this object, too.
The object has one attribute corresponding to each role. In our example above, the command accepts only an object-role argument, so the preview and execute methods get passed an argument with an "arguments<code>args.object" </code> attribute.
If we made a command, like email, that takes an object-role argument and a goal-role argument, its preview and execute methods would get passed an argument with "arguments<code>args.object" </code> and "arguments<code>args.goal"</code>.
arguments<code>args.object </code> (or arguments<code>args.goal</code>) has several attributes of its own:
<pre>
argumentsargs.object.text // a string of the input in plain text, without formatting argumentsargs.object.html // a string of the input in formatted htmlHTML, including tags argumentsargs.object.data // for non-text input types, an arbitrary data object argumentsargs.object.summary // for very long inputsthe HTML string displayed in the suggestion list, an abbreviated display stringif long
</pre>
73
edits

Navigation menu