Labs/Ubiquity/Ubiquity 0.5 Author Tutorial: Difference between revisions

Jump to navigation Jump to search
→‎Echo: arguments -> args
m (→‎Persistent Storage: for -> for each)
(→‎Echo: arguments -> args)
Line 325: Line 325:
               nountype: noun_arb_text,
               nountype: noun_arb_text,
               label: "your shout"}],
               label: "your shout"}],
   preview: function( pblock, arguments ) {
   preview: function previewEcho(pblock, args) {
     pblock.innerHTML = _("Will echo: ") + arguments.object.text;
     pblock.innerHTML = _("Will echo: ") + args.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>
</pre>
Line 399: Line 399:
When your preview method is called, it is passed this object, too.
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.object" attribute.
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 <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.object" and "arguments.goal".
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 <code>args.object</code> and <code>args.goal</code>.


arguments.object (or arguments.goal) has several attributes of its own:
<code>args.object</code> (or <code>args.goal</code>) has several attributes of its own:


<pre>
<pre>
   arguments.object.text // a string of the input in plain text, without formatting
   args.object.text   // a string of the input in plain text, without formatting
   arguments.object.html // a string of the input in formatted html, including tags
   args.object.html   // a string of the input in formatted HTML, including tags
   arguments.object.data // for non-text input types, an arbitrary data object
   args.object.data   // for non-text input types, an arbitrary data object
   arguments.object.summary // for very long inputs, an abbreviated display string
   args.object.summary // the HTML string displayed in the suggestion list, abbreviated if long
</pre>
</pre>


73

edits

Navigation menu