First Netvibes Plugin
Just finished my first Netvibes plugin. Hopefully it’ll be the first of many to come as I’ve now got the hang of the Universal Widget API (UWA) now.
My first widget is mainly for UK users who take a lot of flights. Its a Lastminute.com flight checker widget so you can find the latest pricing info for a given date.
You can view it and install it here.
How the UWA Widgets Work
They’re dead simple in principle. So simple a widget is nothing more than a specifically formatted HTML document. You have to make sure you’ve got a few things in there like a UTF-8 encoding attribute at the top and a few other bits but the skeleton document helps a lot. Other than that you can use Javascript and style it with CSS all like a regular HTML document. More about UWA.
Forms
This was a serious pain in the arse. The form documentation for Netvibes is rubbish and the forum had little of use – although I was helped by Xavier and managed to get round my problem.
Basically in Netvibes – don’t use a form. Or at least don’t submit a form in the traditional sense. It won’t work, and even if you manage to get it working it’ll die on Mac. You need to emulate the behviour of the form by packaging the variables up and executing the widget.openURL() function. Thats for GET forms. POST forms will need to use the Ajax API Netvibes includes.
Packaging Up Your Form to Get
Someone else may find this useful…
var formElements = document.lmfForm.elements;
var qString = '?';
for (el in formElements) {
if(formElements[el].name != undefined && formElements[el].value != undefined){
qString += formElements[el].name + '=' + formElements[el].value + '&';
}
}
widget.openURL('http://www.example.com/script.php' + qString);
Related posts:

