Perhaps this can help?
http://mytechieself.blogspot.com/2008/09/yelling-with-ubiquity.html
- Mayuresh
On Tue, Nov 25, 2008 at 9:25 PM, Fernando Takai <[EMAIL PROTECTED]>wrote:
>
> tlob,
>
> to make your command easier to use, you can try the inputs like this:
>
> takes: { "departure": noun_arb_text }
>
> and the modifiers:
>
> modifiers: {"to" : noun_arb_text }
>
> Then, the users can type
>
> sbb chicago to toronto (ok, it will be swiss cities, but you got the point)
>
> as for the url, you can use:
>
> var url =
> "http://fahrplan.sbb.ch/bin/query.exe/d?S=${dept}!&Z=${dest}!&start=1"
> and them:
>
> var finalUrl = CmdUtils.renderTemplate(url, {dept: fromStation.text,
> dest: modifiers.to.text })
>
> CmdUtils.renderTemplate is used to render html templates, but i think it
> can be used to easily replace parts of the code using ${}.
>
> On 11/25/08 7:19 PM, tlob wrote:
> > Here is my code:
> > CmdUtils.CreateCommand({
> > name: "sbb",
> > license: "CC",
> > icon: "http://www.sbb.ch/favicon.ico",
> > description: "Time table for Swiss Railways",
> > license: "CC",
> >
> > takes: { "Departure":noun_arb_text },
> > modifiers: {"Destination": noun_arb_text},
> >
> > execute: function( fromStation, modifiers ) {
> >
> > var departure = fromStation.text;
> > /* How to set default when not giving snd input? */
> > var destination = modifiers.Destination.text;
> >
> > /* How to set local vars? if DE(german) then localVar=d, if FR
> > (french) then localVar=f */
> > /*var url = "http://fahrplan.sbb.ch/bin/query.exe/{localVar}?S=
> > {DEP}!&Z={DEST}!&start=1";*/
> > var url = "http://fahrplan.sbb.ch/bin/query.exe/d?S={DEP}!&Z=
> > {DEST}!&start=1";
> > url = url.replace( /{DEST}/g, destination);
> > url = url.replace( /{DEP}/g, departure);
> >
> > Utils.openUrlInBrowser( url );
> > },
> > });
> >
> >
> > On Nov 25, 10:09 pm, Fernando Takai<[EMAIL PROTECTED]> wrote:
> >> Can you send us the hole code?
> >>
> >> Without knowing anything else, i say that with modifiers you should code
> >> something like this:
> >>
> >> //..
> >> modifiers: { input1: noun_arb_text, input2, noun_arb_text }
> >>
> >> and them on the preview/execute:
> >>
> >> preview: function (input, pblock, mods){
> >> if(mods.input1&& mods.input2){
> >> pblock.innerHTML = "http://example.com?query=" +
> mods.input1.text
> >> + "&query2=" + mods.input2.text
> >> }
> >> },
> >> execute: function (input, mods){
> >> if(mods.input1&& mods.input2){
> >> var url = "http://example.com?query=" + mods.input1.text + "&query2=" +
> >> mods.input2.text
> >> displayMessage(url);
> >> }
> >> }
> >>
> >> //...
> >>
> >> Cheers!
> >>
> >> On 11/25/08 6:25 PM, tlob wrote:
> >>
> >>> Hi, I try to replace 2 nouns (inputs) in an URL. Like:
> >>> example.com/?query={Input1}&other-part-of-the-url={Input2}&and-
> >>> another.html
> >>> it has something to do with the modifiers, cant get it to work.....
> >>> Sorry, beginner question!
> >>> Thx anyway!
> >>> tom
> >> --
> >> Fernando "Takai"
> http://flickr.com/photos/supeertakaihttp://fernandotakai.jaiku.com
> >>
> >> Get Ubiquity:https://wiki.mozilla.org/Labs/Ubiquity/
> > >
>
> --
> Fernando "Takai"
> http://flickr.com/photos/supeertakai
> http://fernandotakai.jaiku.com
>
> Get Ubiquity: https://wiki.mozilla.org/Labs/Ubiquity/
>
>
> >
>
--
Mayuresh
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---