Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mumoshu
Created January 1, 2009 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mumoshu/42293 to your computer and use it in GitHub Desktop.
Save mumoshu/42293 to your computer and use it in GitHub Desktop.
mhp2g-item.ubiquity.js
// mhp2g-item.ubiquity.js
// 「MHP2:このアイテムが手に入るクエを教えて+何に使うか教えて」ツール
// http://www.first-priority.yi.org/~mezos/tool/
CmdUtils.CreateCommand({
name: "mhp2g-item",
takes: {query: noun_arb_text},
url: "http://www.first-priority.yi.org/~mezos/tool/itemlist.php?itemname=${itemname}",
preview: function(pBlock, directObject) {
var query = directObject.text;
var log = CmdUtils.log;
var items = new Array();
Utils.parseRemoteDocument(
CmdUtils.renderTemplate(this.url, {itemname: query}),
null,
function(doc) {
jQuery('#itemlist a',doc).each(function() {
var item = {};
item.id = this.href.match("[1234567890]+")[0];
item.name = this.innerHTML;
items.push(item);
});
var item_template = "<a href=\"http://www.first-priority.yi.org/~mezos/tool/item.php?id=${itemid}&disp=Q,D,QP,S,C,L,E,M&wdisp=S,T,B,K,H,W,R,G,LB,HB,A&adisp=H,B,A,W,L&gdisp=G\">${itemname}</a>";
html = jQuery.map(items,function(item,i) {
return CmdUtils.renderTemplate(item_template, {itemid: item.id, itemname: item.name});
}).join("<br>");
pBlock.innerHTML = html;
}
);
},
execute: function(directObject) {
var query = directObject.text;
Utils.openUrlInBrowser(CmdUtils.renderTemplate(this.url, {itemname: query}));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment