Skip to content

Instantly share code, notes, and snippets.

@esquifit
Created July 21, 2009 12:23
Show Gist options
  • Save esquifit/151313 to your computer and use it in GitHub Desktop.
Save esquifit/151313 to your computer and use it in GitHub Desktop.
Hybrid Ubiquity command for parser 1 and 2
var noun_type_fooCommand = {
suggest: function( text, html ) {
var suggestions = [];
suggestions.push( CmdUtils.makeSugg('foo', 'foo', 'foo') );
suggestions.push( CmdUtils.makeSugg('bar', 'bar', 'bar') );
suggestions.push( CmdUtils.makeSugg('baz', 'baz', 'baz') );
return suggestions;
}
}
CmdUtils.CreateCommand({
name: "foobar",
names: ["foobar"],
author: (CmdUtils.parserVersion == 2) ? {name: "esquifit"} : "esquifit",
takes: {"Some foostring": noun_type_fooCommand },
arguments: [{role: "object",
label: "Some foostring",
nountype: noun_type_fooCommand}],
description: "Hybrid foo command",
execute: function( arg ) {
var data = (CmdUtils.parserVersion == 2) ? arg.object.data : arg.data;
displayMessage(data);
},
preview: function( pblock, {object} ) {
var text = (CmdUtils.parserVersion == 2) ? object.text : object;
pblock.innerHTML = "Text: " + text ;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment