Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity 0.1 Author Tutorial

16 bytes added, 06:02, 1 December 2008
Replace: Commands With Multiple Arguments
name: "replace",
takes: {"what": noun_arb_text},
modifiers: {"with": noun_arb_text, "in": noun_arb_text},
preview: function( pblock, what, mods ) {
// args contains .with and .in, both of which are input objects.
var msg = 'Replaces "${whatText}" with ${withText} in ${inText}.';
var subs = {whatText: what.text, withText: mods.["with"].text, inText: mods.["in"].text};
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs );
execute: function( what, mods ) {
// If the scope text isn't specified, use the current selection.
var text = mods.["in"].text || CmdUtils.getSelection(); var newText = text.replace( what.text, mods.["with"].text, "i");
CmdUtils.setSelection( newText );
}
Confirm
587
edits

Navigation menu