Hi, I'm coming over from the Drigg project and in particular the external voting button support ticket (http://drupal.org/node/199190).
It has been suggested that your project might help in implementing the vote button however, after looking at what you are working on, I am no longer so sure. Perhaps you could shed some light on these issues:
- the use-case at drigg is to be able to place a vote button on the original blog article. When a user clicks on the contents of the IFRAME, he gets the same experience as when he clicks the vote button on the Drigg site : the contents update. See http://pressecrackimmo.canalblog.com/ for a hacked up version I made
- do you defer loading of the contents of the IFRAME to when it becomes visible if the widget is deployed multiple times in a page. If you don't then you will hit the server with many many concurrent requests (probably limited by the browser but maybe not. In any event, it really slows it down)
Thanks
Comments
Comment #1
jtsnow commentedThis is an interesting use case for Embed Widgets. I'm not familiar with techniques used to load the contents of an IFrame only when becomes visible. I have heard of using JavaScript to force an IFrame to load after everything else on the page has loaded, but this would still create many concurrent requests to the server.
Can you share how this might be done?
Comment #2
PGiro commentedWell, I've played around with setTimeout() and things like that. The hard thing is to get each button to cooperate with the others when there can be any number on the page and no piece of script to make them work together. Since javascript is single-threaded, you're sure that each script will be executed one after the other and I was guessing a shared variable could do the trick.
I was not able to get it to work.
Also found this http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/35...
And finally, I believe jquery's ready() function can solve it but I haven't be able to get it to work yet : http://docs.jquery.com/Events/ready
Comment #3
PGiro commentedOk, I nailed it. Here it is jquery-free.
The following code is is a button.js script that can be included in a page. I defers the loading of each IFRAME by 1 seconde. so the first gets called after 1 s of the script being run, the second 2s, etc... Helps to alleviate the load on the server, espacially when the number of concurrent connections to the database is limited.
Works on FF2 & IE6 on windows and Safari on a mac at least
Hope you find it useful. Will cross-post to Drigg.
Comment #4
aaron commentedthat still hits a server several times, although as you said it does spread out requests from a single client. i can see that being slightly annoying. you could probably get away with reducing the timer, maybe halving it repeatedly until you find the sweet spot.
another option might be to have external widgets "register" themselves, perhaps to a global object, and then the script could consolidate all the requests into one single request, and parcel out the displays appropriately.
obviously, these probably wouldn't be suitable as iframes, unless there's a way to send content to an iframe from javascript.
Comment #5
PGiro commentedAbout sending content to an IFRAME : that would be quite possible, that's already exactly what my javascript does.
Your idea would require adding some javascript to the "top" of the page but then it's harder to "sell" to users since it's not just a "widget" you install where you need it!
Comment #6
vlooivlerke commentedHi
I am embedding google maps and single drupal 5 pages, into a drupal 6 page.
What i am looking for is a simple widget that shows the progress of the load of the
page. It can start when the rest of the page loads, as I have noticed that drupal loads the main page site first then starts with the page. Most of the time I use only the page heading and the rest is the code, making my drupal site look like a bunch of empty pages but they are not, until the loads. Please help with this one. I don't have any JS knowledge nor Ajax but I can help with the graphic side of the widget if there is not a free one available to use. Thanks