Er, sorry Joe, I think that CmdUtils.getSelection() might actually be a
bit of an artifact from the very beginning of Ubiquity, back when the
concept of noun types and the natural language parser didn't exist.
That said, it's still certainly usable; and while
CmdUtils.getTextSelection() would certainly be a more appropriate name
for it, the function is actually called CmdUtils.getSelection(). Here's
a really trivial command that uses it:
function cmd_show_my_selection() {
displayMessage("your text selection is " + CmdUtils.getSelection());
}
But as Christian said, the more "canonical" way of doing this kind of
thing now is to use noun types, I think, since doing so will
automatically take care of retrieving the parameter from either the
user's selection or the command line.
- Atul
On 1/7/09 10:27 AM, Joe wrote:
> Ok, I will keep looking. Unitl then, can anyone tell me how i can make
> text that the user has highlight and turn it into a variable? Is
> CmdUtils.getTextSelection() the right function to use? and if so how
> would be the best method?
>
> Thanks so much,
>
> Joe
>
> On Jan 7, 1:18 pm, "Fernando Takai"<[email protected]> wrote:
>
>> Ummm... I think we're working on docs.. but i don't know - i'm a little away
>> of irc.. Maybe Atul/cers can answer better this.
>>
>>
>>
>> On Wed, Jan 7, 2009 at 4:15 PM, Joe<[email protected]> wrote:
>>
>>
>>> I see that now, thank you all, its working quite nicely now. Is there
>>> a convent place on the web that list all of the functions? With
>>> examples of each? i am now trying to implement
>>> CmdUtils.getTextSelection and having a bit of trouble, it would make
>>> this easier if I could see an example.
>>>
>>> Thanks again
>>>
>>> Joe
>>>
>>> On Jan 7, 12:14 pm, "Fernando Takai"<[email protected]> wrote:
>>>
>>>> Look at cers' reply.
>>>>
>>>> On Wed, Jan 7, 2009 at 3:11 PM, Joe<[email protected]> wrote:
>>>>
>>>>> Thanks a lot Fernando! That worked great! However, is there a better
>>>>> way to open a new window or tab? The process that I am using alerts
>>>>> FireFox's popup blocker. See code below:
>>>>>
>>>>> CmdUtils.CreateCommand({
>>>>> name: "submit-digg",
>>>>> execute: function() {
>>>>> var document = CmdUtils.getDocument();
>>>>> var window = CmdUtils.getWindow();
>>>>> var
>>>>> url='http://digg.com/submit?phase=2&url='+<http://digg.com/submit?phase=2&url=%27+>window.location
>>>>> +
>>>>> '&title=' + document.title;
>>>>> window.open(url, 'test')
>>>>> }
>>>>> })
>>>>>
>>>>> On Jan 7, 11:11 am, "Fernando Takai"<[email protected]> wrote:
>>>>>
>>>>>> There's no document/window object within our sandbox. You have to
>>>>>>
>>> access
>>>
>>>>>> them through CmdUtils.getDocument() and CmdUtils.getWindow().
>>>>>>
>>>>>> Cheers!
>>>>>>
>>>>>> On Wed, Jan 7, 2009 at 2:08 PM, Joe<[email protected]> wrote:
>>>>>>
>>>>>>> Hello everyone!
>>>>>>>
>>>>>>> i am kind of a n00b around here, so please bear with me! I am
>>>>>>> currently trying to develop my first ubiquity command. For this
>>>>>>> command, i am trying to submit things to Digg. I understand that
>>>>>>>
>>> there
>>>
>>>>>>> is already a digg command, but I am taking this on as part of my
>>>>>>> learning process in the hopes that I can do cooler things in the
>>>>>>> future.
>>>>>>>
>>>>>>> Below is my code. Can anyone tell me why it isn't working?
>>>>>>>
>>>>>>> CmdUtils.CreateCommand({
>>>>>>> name: "submit-digg",
>>>>>>> execute: function() {
>>>>>>> var
>>>>>>> url='http://digg.com/submit?phase=2&url='+<http://digg.com/submit?phase=2&url=%27+>
>>>>>>>
>>> <http://digg.com/submit?phase=2&url=%27+>window.location +
>>>
>>>>>>> '&title=' + document.title;
>>>>>>> window.open(url, 'test')
>>>>>>> }
>>>>>>> })
>>>>>>>
>>>>>>> Am I completely missing the point? If so whats the problem?
>>>>>>>
>>>>>> --
>>>>>> Fernando "Takai"
>>>>>>
>>>>> http://flickr.com/photos/supeertakaihttp://fernandotakai.jaiku.com
>>>>>
>>>>>> Get Ubiquity:https://ubiquity.mozilla.com
>>>>>>
>>>> --
>>>> Fernando "Takai"
>>>>
>>> http://flickr.com/photos/supeertakaihttp://fernandotakai.jaiku.com
>>>
>>>> Get Ubiquity:https://ubiquity.mozilla.com
>>>>
>> --
>> Fernando
>> "Takai"http://flickr.com/photos/supeertakaihttp://fernandotakai.jaiku.com
>>
>> Get Ubiquity:https://ubiquity.mozilla.com
>>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---