73
edits
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, | preview: function previewEcho(pblock, args) { | ||
pblock.innerHTML = _("Will echo: ") + | pblock.innerHTML = _("Will echo: ") + args.object.text; | ||
}, | |||
execute: function executeEcho(args) { | |||
var msg = args.object.text + "... " + args.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 | 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 | 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>. | ||
<code>args.object</code> (or <code>args.goal</code>) has several attributes of its own: | |||
<pre> | <pre> | ||
args.object.text // a string of the input in plain text, without formatting | |||
args.object.html // a string of the input in formatted HTML, including tags | |||
args.object.data // for non-text input types, an arbitrary data object | |||
args.object.summary // the HTML string displayed in the suggestion list, abbreviated if long | |||
</pre> | </pre> | ||
edits