APIFinder
   The essential directory of application programming interfaces
Submit an API
DevX
Function
Language/OS
Contribute
About
Browse DevX
advertisement
Log In | Register
Will Your Next Web Application Be a Google Gadget?
Learn how to leverage the Google Gadget API to make your web applications more reachable. As an example, you'll see how to build a real-world gadget that fetches and displays the DevX feeds. 
April 8, 2008

advertisement
Since AJAX first appeared, developer interest in JavaScript has increased exponentially—and toolsets for building functionality in JavaScript have burgeoned as well. One of the latest tools for JavaScript-related development is Google Gadgets. Many web sites already provide gadgets built with the Google tools, and you can, too. This article shows you how to develop a Google Gadget that fetches DevX RSS feeds and displays them to the user.

Anatomy of a Google Gadget
Developing a Google Gadget (simply gadget from now on) is really an easy task. After all, a gadget is made of XML, HTML, JavaScript, and optionally, CSS, used as follows:

  • XML describes the gadget's structure.
  • HTML and CSS provide the presentation layer.
  • JavaScript supplies the gadget's logic.
The XML below shows the basic gadget structure:

 <?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="A title" />
<Content type="html">
<![CDATA[
<!-- Here the CSS, JavaScript and HTML code -->
]]>
</Content>
</Module>
Here's a breakdown of the XML elements. The root element is Module. The ModulePrefs element holds information about the gadget (title, height, and so on) and its author—more on this later. The Content element is apt to contain the "real" content—the CSS, HTML, and JavaScript code. As you'll see later on, there are other elements to consider, but these are the basic elements you'll use in each and every gadget you develop.

A Simple "Hello, World" Gadget
The easiest way to start learning a new programming language or technology is to dive right in with a simple example. Here's the code for a gadget that just prints out the traditional "Hello, World" message in a box:

 <?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Hello world example" />
<Content type="html">
<![CDATA[
<div id="content" style="color: red;">
hello, world!
</div>
]]>
</Content>
</Module>
Save the preceding XML file using the name hello-world.xml. You won't use this right away—I'll show you how to deploy it in the next section.

Continue reading article on DevX.com...

Alessandro Lacava is a software engineer and technical writer based in Italy. During his career he's been involved in designing and developing applications using many different programming languages and technologies, such as: Object-Oriented Programming, Design Patterns, UML, Java (ME - SE - EE), .NET, PHP, C, JavaScript, Ajax, HTML, CSS, Oracle, PL/SQL, MySQL, XML, XSL, JSON. Alessandro holds a degree in Telecommunications Engineering. You can reach him via his Web site at http://www.alessandrolacava.com


Google Gadgets API
This API is designed specifically to let individuals enhance Google "personalized homepages." The personalized homepage feature lets you add various types of content widgets (gadgets) to the Google home page when you go to it (e.g. local weather, sports info, stock quotes, etc.) Once you've created a gadget you can share it with anyone you like by getting them to add your gadget or you can submit it to Google for inclusion in the gadget directory. (No download is necessary. Link goes to a developer guide for the XML specification language.)
Provider: Google   Cost: 0



The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers