Rob,

This is an acceptable method to restore service to my broken gadget, and
thanks to your team for being proactive to find a solution.

Regards,
-G

Gavin McDonald
EVI Logistic Enterprises
604-313-3845 - VE7HXR


On Wed, Apr 21, 2010 at 7:02 PM, Rob Russell <[email protected]> wrote:

> I spent some time today, with the help of other developers on the iGoogle
> team, coming up with a way to adapt an arbitrary gadget that relies on the
> way user prefs used to be supplied with the url in type="url" gadgets. A
> gadget ideally only needs the gadget API, and shouldn't rely on the way
> iGoogle sends (or doesn't send) parameters in the URL query string.
>
> Keep in mind that what I'm suggesting is just one way to adapt such a
> gadget, it's up to individual gadget developers to detemine what works for
> them. I have used this to adapt one of the reported gadgets and it seems to
> work fine.
>
> The crux of the idea is that instead of supplying an external page to wrap,
> we use a type=html gadget and request the page that we want wrapped after
> the gadget loads. The wrapping gadget will be cached by iGoogle. You can
> consider this code a template and adapt it if you'd like to include a
> loading animation or message for the user in case your server takes some
> time to respond.
>
> I've tested this with sample data in IE6 on Windows and on Firefox. It is
> just an example though and I encourage anyone that sees room for improvement
> to chime in.
>
> The UserPrefs elements are the same as for the existing Content type=url
> section, as are the Module and ModulePrefs elements.
>
> In the Javascript, the wrappeduserprefs variable is an array of the values
> of name attributes from the UserPref elements. So for this pretend gadget,
> it has prefs myname and mycolor. The type of the UserPref doesn't matter.
> The wrappedpage variable is the url of the page that your Content type=url
> gadget pointed at - that is the value of the href attribute on the Content
> element.
>
> If your server code doesn't need the "up_" prefix on the parameter name
> then change (most will but it could be a chance to clean up some server side
> cruft)
>       params["up_"+userprefs[key]] = prefs.getArray(userprefs[key]);
> to
>       params[userprefs[key]] = prefs.getArray(userprefs[key]);
>
> Here's the code
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
> <ModulePrefs title="example url iframed" />
> <UserPref name="myname" display_name="Name" default_value=""/>
> <UserPref name="mycolor" display_name="Color" default_value="Red"
> datatype="enum" >
>   <EnumValue value="Red" />
>   <EnumValue value="Blue" />
> </UserPref>
> <Content type="html">
>   <![CDATA[
>   <script type="text/javascript">
>   var wrappedpage = "http://example.com/mygadget.php";;
>   var wrappeduserprefs = ["myname","mycolor"];
>
>   var prefs = new gadgets.Prefs();
>   var params = {};
>
>   function init() {
>     for (key in wrappeduserprefs) {
>       params["up_"+wrappeduserprefs[key]] =
> prefs.getArray(wrappeduserprefs[key]);
>     }
>
>     document.getElementById("wrapped").src = wrappedpage + "?" +
> gadgets.io.encodeValues(params);
>   }
>
>   gadgets.util.registerOnLoadHandler(init);
>   </script>
> <style>
>   body {
>   margin: 0;
>   padding: 0;
>   overflow: hidden;
>   }
> </style>
>   <iframe src="" name="wrapped" id="wrapped" width="100%" height="200px"
> style="border:none; margin:0; overflow:hidden; padding:0;" scrolling="no"
> frameborder=0 >
>   </iframe>
> ]]>
> </Content>
> </Module>
>
>
> Rob Russell
> Google Developer Relations
>
> --
> You received this message because you are subscribed to the Google Groups
> "iGoogle Developer Forum" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-gadgets-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/Google-Gadgets-API?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"iGoogle Developer Forum" 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/Google-Gadgets-API?hl=en.

Reply via email to