Skip to content

Instantly share code, notes, and snippets.

@sealence sealence/irecite.js
Created Jan 20, 2009

Embed
What would you like to do?
Ubiquity: irecite
/* command "irecite" */
CmdUtils.CreateCommand({
names: ["irecite"],
icon: "http://res.iciba.com/dict/favicon.ico",
homepage: "http://scb.iciba.com/day/",
author: { name: "Sealence", email: "sealence@gmail.com"},
license: "GPL",
description: "Recite word everyday",
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'input'} ],
baseurl: "http://scb.iciba.com/day",
execute:function(args){
var input = args.object.text;
var url = this.baseurl;
if ( input.length > 0 )
url += '_' + input + '.shtml';
Utils.openUrlInBrowser(url);
},
preview: function( pblock, args ) {
var input = args.object.text;
var url = this.baseurl;
if ( input.length > 0 )
url += '_' + input + '.shtml';
Utils.parseRemoteDocument(
url, // URL
null, // post data
function(doc) { // success callback
var max = 5;
var top = null, bottom = null, data = '';
for (var i=0;i<max;i++){
top = jQuery('#top' + i, doc).html();
bottom = jQuery('#bottom' + i + ' div', doc).html();
data += '<b>' + top + '</b>' + bottom + '<p/>';
}
pblock.innerHTML = data ;
},
function() { // error callback
pblock.innerHTML = "Error!";
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.