======Netvibes mini API Step by Step====== This version of the API is not recommended anymore, it has been superseded by the UWA. While it might still work, we highly recommend to transition to the new Universal Widget API. Last update: 14/04/2006 Let's start learning building HTML API Modules. =====STEP 1: Hello world !===== For example, we can write a famous "hello world" example simply like this: Hello world

Hello world !

Test this module: http://www.netvibes.com/api/0.3/examples/example1.html Note that: * Netvibes Html Modules SHOULD be XHTML strict and well formed * Netvibes Html Modules SHOULD be utf-8 encoded How it works: * The title of the XHTML page appear in the module title bar * The content into the body of the XHTML page appear in the module content area. =====STEP 2: Emulate Netvibes Rendering===== To make module developement more easy, you can add CSS and Javascript to your module. It will help you see how it will be rendered into Netvibes. Add this two lines into your html HEAD section: This preview functionnality is very minimal for the moment and it may evolve in further versions. Test this module: http://www.netvibes.com/api/0.3/examples/example2.html =====STEP 3: Multiple Pages===== You can create and link multiple pages to build your netvibes module ! Simply make relative hyperlinks between the pages. Absolute links will be considered external and opened in a new window. Hello world

Hello world!

Here's the link pointing to page 2

Test this module: http://www.netvibes.com/api/0.3/examples/example3-page1.html =====STEP 4: Mark Up===== You can use all the markup available in XHTML strict. In theory, all must be rendered very gracefully with the "Netvibes Touch" (tm) thanx to our CSS. Let's try a combination of all we can do: Hello world

Testing Markup

This is a paragraph. You can add bold, strong, em, and i.

And just bellow one other.

Lists

Unordered lists

Ordered lists

Tables

Col 1 Col 2 Col 3
4 2 8

Forms

Test this module: http://www.netvibes.com/api/0.3/examples/example4.html =====STEP 5: Classic forms===== Like we just saw above, you can add forms to your module. This step explains how they are handled. Take the following example: Hello world



Test this module: http://www.netvibes.com/api/0.3/examples/example5.html If you submit this sample form, data will be posted (the method "attribute" is set to "post") to the "addBookmark.php" URL (defined in the "action" attribute). Note: * Data is posted using Ajax so the page is not refreshed * "addBookmark.php" must send back data (or redirect to) a Netvibes Mini API module. The module content sent back will be simply rendered =====STEP 6: Configuration forms===== Let's try this special kind of form. We declare a configuration form by adding an attributed class with the value "configuration" to the form. New configuration example

Module is not configured. Please edit it.

Name :

Surname :


* The form is appearing in the edit section of the module instead of the body. * When you submit this form, data is not send to a URL as in 'classic forms' but instead stored in the Netvibes database. * From the moment data is stored, we make it available via the javascript ''getValue()'' function and also as HTTP Cookies. Test this module: http://www.netvibes.com/api/0.3/examples/example6-configuration.php =====Step 7: Javascript, onload binding, and Periodical Executer===== In this example, we define an ''NV_ONLOAD'' function that will be automatically executed when the module load. Then, we define (with vanilla javascript or with prototype.js built-in function) that the refreshContent function will be executed each second. In the refreshContent function, we create a string with the current time, then we put in the module content using the ''NV_CONTENT'' binding and ''innerHTML''. Date and hour module

Loading ...

Test this module: http://www.netvibes.com/api/0.3/examples/date.html =====Step 8: Ajax, Proxy and RSS parsing===== In this example, when the module load, we're executing an Ajax Request using the Netvibes XML proxy and prototype.js built in function. When the Ajax call is finished, we're parsing the RSS sent back using DOM, then we change the title and the content of the module by using the NV_TITLE and NV_CONTENT bindings. FKDL

Loading ...

Test this module (not exactly the same code, note the parsing issue with Safari): http://www.netvibes.com/api/0.3/examples/fkdl.html