JS newbie

12 views
Skip to first unread message

Dovi

unread,
Oct 21, 2009, 11:09:39 AM10/21/09
to ubiquity-firefox
Hi all.
I have no real knowledge of JS, and no real motivation to learn,
except for ubiquity...
I would like to take that simple command below, and make it throw the
result in the preview window, in addition to the execution. I have a
feeling it is pathetically simple for those who know.
Many thanks in advance.

CmdUtils.makeSearchCommand({
name: "Julian day calc",
url: "http://aa.usno.navy.mil/cgi-bin/aa_jdconv.pl",
postData: "FFX=2&ID=AA&jd={QUERY}&ZZZ=END",
});


Christian Sonne

unread,
Oct 21, 2009, 12:31:15 PM10/21/09
to ubiquity...@googlegroups.com
Hi Dovi!

You're in luck, I just finished the first draft of a full reference to makeSearchCommand: https://wiki.mozilla.org/Labs/Ubiquity/Writing_A_Search_Command

It is important to note that some features require the latest development version of Ubiquity, but most of it applies to the current stable version too.

You need to know a bit about jQuery and it's oddities to do what you want, so I've done it for you this time :-)


CmdUtils.makeSearchCommand({
  name: "Julian day calc",
  url: "http://aa.usno.navy.mil/cgi-bin/aa_jdconv.pl",
  postData: "FFX=2&ID=AA&jd={QUERY}&ZZZ=END",
  preview: function(pblock, args) {
    $.post(this.url,
           this.postData.replace("{QUERY}",args.object.text),
           function(d) {$(pblock).html($("<div>"+d+"</div>").find("pre"));});
  }
});

Best regards
-- cers / Christian Sonne

Dovi

unread,
Oct 21, 2009, 3:48:57 PM10/21/09
to ubiquity-firefox
Extraordinary!
Thanks a lot.
Dovi


On Oct 21, 9:31 am, Christian Sonne <freakc...@gmail.com> wrote:
> Hi Dovi!
>
> You're in luck, I just finished the first draft of a full reference to
> makeSearchCommand:https://wiki.mozilla.org/Labs/Ubiquity/Writing_A_Search_Command
>
> It is important to note that some features require the latest development
> version of Ubiquity, but most of it applies to the current stable version
> too.
>
> You need to know a bit about jQuery and it's oddities to do what you want,
> so I've done it for you this time :-)
>
> CmdUtils.makeSearchCommand({
>   name: "Julian day calc",
>   url: "http://aa.usno.navy.mil/cgi-bin/aa_jdconv.pl",
>   postData: "FFX=2&ID=AA&jd={QUERY}&ZZZ=END",
>   preview: function(pblock, args) {
>     $.post(this.url,
>            this.postData.replace("{QUERY}",args.object.text),
>            function(d)
> {$(pblock).html($("<div>"+d+"</div>").find("pre"));});
>   }
>
> });
>
> Best regards
> -- cers / Christian Sonne
>
Reply all
Reply to author
Forward
0 new messages