Thread: Program
View Single Post
Old 2009-07-16, 20:02   #4
Mini-Geek
Account Deleted
 
Mini-Geek's Avatar
 
"Tim Sorbera"
Aug 2006
San Antonio, TX USA

17×251 Posts
Default

Quote:
Originally Posted by Primeinator View Post
I know no coding. How would it be done on Ubiquity? I looked at the app briefly.
Here's the command you'd use: (modified to have the sites he wants, of course, the ones there aren't going to do anyone much good!)
Code:
CmdUtils.CreateCommand({
  name: "ISBN",
  arguments: [{role: 'object', nountype: noun_arb_text}],
  locale: "en-US",
  description: "Lookup availability and pricing for the given ISBN number.",
  preview: function(pblock, args) {
    var html = _("Lookup ISBN number.");
    if (args.object.text) {
      html = _("Lookup ISBN number " + isbn);
    }
    pblock.innerHTML = html;
  },
  execute: function(args) {
    var isbn = args.object.text
    Utils.openUrlInBrowser("http://example.com/lookup?isbn=" + isbn);
    Utils.openUrlInBrowser("http://example2.com/lookup?isbn=" + isbn);
    //etc
  }
});
Or more minimalist, but still just as functional:
Code:
CmdUtils.CreateCommand({
  name: "ISBN",
  arguments: [{role: 'object', nountype: noun_arb_text}],
  execute: function(args) {
    var isbn = args.object.text
    Utils.openUrlInBrowser("http://example.com/lookup?isbn=" + isbn);
    Utils.openUrlInBrowser("http://example2.com/lookup?isbn=" + isbn);
    //etc
  }
});
Note that both of these commands were written for Ubiquity 0.5, (consider it a stable beta release, it's not what you'll get if you just use the link on the main Ubiquity page) which requires Firefox 3.5. This shouldn't be a problem, but if you want to use the 0.1 line for some reason, the command can be converted fairly easily, just reverse this tutorial.
Only problem is that any sites where the ISBN number doesn't appear in the URL (sent as POST instead of GET) will be trickier. I don't know exactly how to do that and make it work. Here's a tip, if any of the sites do use POST instead of GET: Google. It's just JS code, so a JS solution to bringing up a page with POST parameters ought to work. Probably not too hard, but I've never done it.

Last fiddled with by Mini-Geek on 2009-07-16 at 20:18
Mini-Geek is offline   Reply With Quote