On Wed, Mar 25, 2009 at 4:13 AM, [email protected]
<[email protected]>wrote:
>
> makeSearchCommand({
> name: "Anime-Eden-Anime-Search",
> author: {name: "Cooper Click", email: "[email protected]"},
> description: "Looks up in Anime-Eden",
> icon: "http://www.anime-eden.com/favicon.ico",
>
> url:"http://www.anime-eden.com/anime/search.htm?kw={QUERY}<http://www.anime-eden.com/anime/search.htm?kw=%7BQUERY%7D>
> ",
> preview: function( pblock, thing ) {
> if (thing.text < 1) {pblock.innerHTML = "Search <b>Anime-Eden
> Anime</b>"; return;}
> jQuery.get(this.url.replace("{QUERY}", thing.text),
> function (doc)
> {
> }
> });
>
> So i'm making a search command, which works in so far as opening the
> page directly, but I'm trying to get a preview. I can't really find
> any good description of how to use JQuery or how to just load a page
> as a preview.
>
> However, I know how the page is constructed, the search results are
> within the 'Table class=Listing Clear' tag and if I could parse that,
> it would be all the results in a link form. How can I go about this?
>
> Also, after I get back this page, since I know a little javascript,
> how can I get the preview page context so I can use javascript like
> document.<tag>.<tag> etc?
>
Hello, and welcome to Ubiquity :-)
There are two basic ways you wan use makeSearchCommand, and with the path
you're taking now, this would be a realistic solution:
CmdUtils.makeSearchCommand({
name: "Anime-Eden-Anime-Search",
author: {name: "Cooper Click", email: "[email protected]"},
description: "Looks up in Anime-Eden",
url:"http://www.anime-eden.com/anime/search.htm?kw={QUERY}",
preview: function( pblock, thing ) {
if (thing.text < 1) {
pblock.innerHTML = "Search <b>Anime-Eden Anime</b>";
}
else {
jQuery.get(this.url.replace("{QUERY}", thing.text), function (doc) {
var result = jQuery("div#widemain > div.general >
table.listing.clear", doc).eq(0);
result.find("a").each(function correctPaths() {
jQuery(this).attr("href", "http://www.anime-eden.com
"+jQuery(this).attr("href"));
});
pblock.innerHTML = "<table>"+result.html()+"</table>";
});
}
}
});
You can also take advantage of the builtin parser, if you're willing to
limit the preview a bit (this won't be an issue in later versions of
ubiquity)
CmdUtils.makeSearchCommand({
name: "Anime-Eden-Anime-Search",
author: {name: "Cooper Click", email: "[email protected]"},
description: "Looks up in Anime-Eden",
url:"http://www.anime-eden.com/anime/search.htm?kw={QUERY}",
parser: {
title: "table.listing.clear > tbody > tr.all > td > a",
preview: "table.listing.clear > tbody > tr.all > td:nth-child(2)"
}
Best regards,
-- cers / Christian Sonne
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---