Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity 0.5 Author Tutorial

21 bytes added, 19:05, 2 July 2009
Made the sample code modern (and actually work).
<pre>
var noun_type_freebase_topic = {
_namename: "Freebase topic", label: "topic", suggest: function suggestfreebase_topic_suggest( text, html, callback ) { jQueryreturn [ CmdUtils.makeSugg(text), $.ajax( { url: "http://www.freebase.com/api/service/search", dataType: "json", data: { prefix: text, limit: 5 }, success: function suggestTopics( response ) { var i, results, result; results = if (response.result; for ( i status === 0; i < results.length; i++ "200 OK") { result = results[ i ]; callback( [CmdUtils.makeSugg( result.name, result.name, result ) for each (result in response.result)]); }, } } ); return [CmdUtils.makeSugg(text)];
}
}; CmdUtils.CreateCommand( {
names: ["lookup on freebase"],
arguments: [{ role: "object", nountype: noun_type_freebase_topic, label: "topic" }, preview: function preview( pblock, arguments args) { var text = arguments.object.text || _("any topic"); pblock.innerHTML = _(("Go to the Freebase topic page for " + "{if text}${text}{else}any topic{/if}."), {text: text}args.object);
},
execute: function goToFreebase( arguments ) { if ( arguments.object.: {text , data}}) { Utils.openUrlInBrowser( text ? (data ? "http://www.freebase.com/view" + argumentsdata.id : ("http://www.freebase.objectcom/search?query=" + encodeURIComponent(text))) : "http://www.datafreebase.id com/"); }
}
} );
</pre>
73
edits

Navigation menu