Hi Browler,
The word "this" is *already being handled for you by Ubiquity*.  When
the user has a selection, Ubiquity replaces the word "this" with the
user's selection *before* passing the input along to your command.
Individual commands don't need to, and should not try to, interpret
"this" on their own.

Instead, if your command takes a URL as input, you should declare it
to use noun_type_url as the type of the argument.  As in, instead of:

takes:  { argumentName: noun_arb_text }

you should say

takes: { argumentName: noun_type_url }

Noun_type_url has features built into it to suggest and autocomplete
urls.  If the user enters the word "page" or "url", it will replace
that with the current page URL.  The noun type handles that, so
there's no need for your command to do anything special.  (Plus, we
are continuing to add features to noun_type_url, such as having it
suggest urls you have been to before, like the awesomebar.  By using
the nountype in your command, you will get these features
automatically.)

--Jono, Mozilla Labs

On May 18, 5:40 pm, Christian Sonne <[email protected]> wrote:
> I would advise you not to use the word "this" for several reasons:
> 1) your command will only make sense to english speaking people, as you
> hardcode "this" into it.
> 2) it breaks compatibility, as people are used to having this refer to
> whatever they have selected
> 3) does it even work if you have something selected? - otherwise it would be
> inconsistent.
> 4) why not just use the current page if no input is given? - and if input is
> given, use that instead?
>
> Best regards,
> -- cers / Christian Sonne
>
> On Tue, May 19, 2009 at 1:56 AM, Browler <[email protected]> wrote:
>
> > nvm i found it works great :)
>
> > On May 18, 7:35 pm, Browler <[email protected]> wrote:
> > > I'm making my first project with ubiquity, I have no javascript
> > > experience, but I do have c++ and actionscript experience so I'm
> > > finding it pretty easy. This may seem as a newb question to most
> > > everyone here, but im trying to add a "this" command to my script
> > > (like in the email this command). inputing the string "this" should
> > > cause the program to use your current url in the code and the preview.
>
> > > so heres the basic idea (i wont give the full code as i don't want to
> > > give away my project lol)
>
> > > preview: function(pblock, input){
> > >   if(input.text=="this"){
> > >     pblock.innerHTML = "this is the url you selected: <b>" +
> > > location.href + "</b>";
> > >   } else {
> > >     pblock.innerHTML = "this is the url you selected: <b>" +
> > > input.text + "</b>";
> > >   }
>
> > > }
>
> > > location.href is where the problem is, it cant find the url the active
> > > tab is currently on and/or it cant display it in the string. Please
> > > help :(
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to