Navigate in a wave by code

2 views
Skip to first unread message

vincent donzé

unread,
Feb 15, 2010, 9:23:13 AM2/15/10
to Google Wave API
Hello everybody,

I'm making a task manager robot for Google Wave but I encounter a
difficulty. I would like to navigate into the wave with java code. I
mean, I want to focus the view on a special blip. If the blip is at
the bottom of the page, I want the wave to scrol down until it reach
the blip. Is it possible ?

Thank you

Chris

unread,
Feb 16, 2010, 10:11:37 AM2/16/10
to google-...@googlegroups.com
You'll probably have to insert some JavaScript into the page and run it, as I doubt Google's API offers anything to do this directly.  See these pages:
http://javascript.wikia.com/wiki/Window#scroll
http://www.quirksmode.org/js/findpos.html

So you use the script at the second link to find the element's position and the function at the first link to send the browser there.  If you want the wave to scroll smoothly, you can scrollBy a certain increment until you reach the element.  That increment could simply be a fraction of the distance to the element, or a constant speed.  For example, if the element is 280 pixels down the screen you could scrollBy 50 pixels every half a second, three times, and then 30 pixels (the modulus - 280 % 50).  The function to separate the calls to scrollBy would be window.setInterval: http://javascript.wikia.com/wiki/Window#setInterval

In ALL things, strive for ><>,
Chris



--
You received this message because you are subscribed to the Google Groups "Google Wave API" group.
To post to this group, send email to google-...@googlegroups.com.
To unsubscribe from this group, send email to google-wave-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en.


Chris

unread,
Feb 16, 2010, 10:13:53 AM2/16/10
to google-...@googlegroups.com
Oops, that would be 50 pixels five times.  *blush*


In ALL things, strive for ><>,
Chris


pamela (Google Employee)

unread,
Feb 17, 2010, 7:14:17 PM2/17/10
to google-...@googlegroups.com
I'm not sure that it'd be easy to do that, given there's no explicit access to the Wave client's DOM. There would presumably have to be a gadget inside the page that was able to reach into the parent frame, find the wave div, and scroll that down. I don't think that an iframe can manipulate that much of the outside.

Alternatively, a wave could me embedded, and that might make it easier to manipulate the embedded wave.

Either way, its hacky. 

I would recommend making sure the blip-to-be-focused is unread, as then atleast people can easily spacebar to it. (And maybe one day the client will notify them of it).

- pamela

Chris

unread,
Feb 18, 2010, 9:24:14 PM2/18/10
to google-...@googlegroups.com
@Pamela: I recall someone reporting that their bot could inject JavaScript into the page to communicate across a gadget's iframe.  Would the same injection technique not work in this case?


In ALL things, strive for ><>,
Chris


pamela (Google Employee)

unread,
Feb 20, 2010, 2:53:48 AM2/20/10
to google-...@googlegroups.com
I haven't seen that injection technique, so I can't comment on its feasability. If you find the particular piece of code, I'll take a look. Thanks!

- pamela

Chris

unread,
Feb 21, 2010, 6:53:18 PM2/21/10
to google-...@googlegroups.com
Pamela: Here is the thread: http://groups.google.com/group/google-wave-api/browse_thread/thread/b7c1af7defd410d4/dd749040fde0bc0d?hl=en&lnk=gst

I asked Ravinder for the source to that and got an overview of his approach:
   By following steps mentioned in my previuos reply i was able to store participant id and participant profile name only.I couldn`t get profile image.To show the profile images I had to use different workaround.
Through bot I created a wave which has all the participants whose profile inforamtion was required and stored waveId in database for later use . In that wave there is a gadget which uses which retrieves profile information by using 

var participant = wave.getParticipantById(userId);

imgUrl = participant.getThumbnailUrl();

dispName = participant.getDisplayName();

Now the whole scenario is like this

1. User creates a new wave and adds bot into the wave.(Let us name this wave as A)

2. bot checks whether waveid of wave which has all the participant whose profile information is required is present in the database.If it is not yet created it creates the wave and add all the userids as participant in it.Then it stores its id to get that wave later. (Let us name this wave as B).

3. then bot embeds a gadget in wave B (Let us call this gadget G1).In this gadget i had to show profile pictures.

4. then bot adds new gadget into wave A.(Let us call this gadget G2). Gadget G2 has html to embed wave B in it.

In this way i was able to show profile information of users. In other way we can say that i used one wave which has all the participants whose profile information i needed

 
In ALL things, strive for ><>,
Chris


Reply all
Reply to author
Forward
0 new messages