36. JavaScript // Create minimessage factory var msg = new gadgets.MiniMessage(); // Show a small loading message to the user var loadMessage = msg.createStaticMessage( "loading..." ); // Get configured user prefs var prefs = new gadgets.Prefs(); var showDate = prefs.getBool( "show_date" ); var showSummary = prefs.getBool( "show_summ" ); var numEntries = prefs.getInt( "num_entries" ); // Fetch issues when the gadget loads gadgets.util.registerOnLoadHandler(fetchIssues);
• Designed & built for sharing content between heterogenous apps • This is exactly what it’s used for in iGoogle, and exactly what it’s used for in OpenSocial
• Open standard • Based on other emerging standards • Portable Contacts • OAuth • Basic web technology like HTML, CSS, & JavaScript • Substantial industry support • Social networks • Increasingly, among business and enterprise-oriented vendors • These are the better-known companies, but the list keeps growing • Also support from the open source world
• OpenSocial Gadgets spec defines three main parts • <click> XML spec file: description of everything that makes up your gadget • Metadata, such as the title & directory information • Content that fills the gadget iframe • Can be hosted on any web server • Gadget containers can be configured with a list of gadget spec URLs • Fetch the gadget spec XML to render or display in the directory • To avoid too much HTTP traffic, containers cache specs • Spec file needs to be more or less static • If it changes on each request, users won’t see those changes • To make the gadget do something interesting, use JavaScript • Inline or with a link to an external script file • <click> JavaScript makes use of the core gadgets JavaScript API • Automatically made available to all gadgets • Access configurable preferences • Make requests to web services • <click> Features: gadgets can use them by declaring them in spec • Additional capabilities for gadgets • Often new APIs that the gadget can call in its JavaScript code • Can provide UI features: tabs or banners • Can provide container integration features: resizing or renaming • Some are defined in the spec, but may not be provided by all containers, others are container specific • We use a custom feature to let us know which directory categories a gadget should be included in • Gadgets can decide to require the feature • Won’t work in containers that don’t provide it • Or make it optional • Gadget must test for feature before using it