Skip to main content

One post tagged with "Ubiquity"

View All Tags

· One min read

把下面的 script copy 到 Ubiquity 的 command-editor 中。 每當看到不熟的生字,打開 Ubiquity,輸入「fy」,按下「Enter」鍵,即可連結到「Yahoo! 奇摩字典」看解釋。

> CmdUtils.CreateCommand({
> name: "fy",
> homepage: "zhpy.googlecode.com",
> author: { name: "Fred Lin", email: "[email protected]"},
> license: "MIT",
> description: "yahoo dict",
> help: "fy [keyword]",
>
> takes: {"keyword": noun_arb_text},
>
> preview: function( pblock, directObject ) {
> searchText = jQuery.trim(directObject.text)
> var previewTemplate = "輸入要搜尋的單字 ${query}";
> var previewData = {query: searchText};
> pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
> },
>
> execute: function( directObject ) {
> var url = "http://tw.dictionary.yahoo.com/dictionary?s={QUERY}"
> var urlString = url.replace("{QUERY}", directObject.text);
> Utils.openUrlInBrowser(urlString);
> }
> })