Skip to content

Instantly share code, notes, and snippets.

@stuff
Created February 19, 2010 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuff/308630 to your computer and use it in GitHub Desktop.
Save stuff/308630 to your computer and use it in GitHub Desktop.
UWA skeleton, english version
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:widget="http://www.netvibes.com/ns/" >
<head>
<title>Widget title</title>
<link rel="icon" type="image/png" href="http://www.netvibes.com/favicon.ico" />
<meta name="author" content="John Doe" />
<meta name="website" content="http://exemple.org" />
<meta name="description" content="a Description" />
<meta name="keywords" content="here, are, key words" />
<meta name="screenshot" content="http://exemple.org/widget-full.png" />
<meta name="thumbnail" content="http://exemple.org/widget-logo.png" />
<meta name="version" content="1.0" />
<meta name="apiVersion" content="1.2-ginger" />
<meta name="autoRefresh" content="20" />
<meta name="debugMode" content="true" />
<link rel="stylesheet" type="text/css" href="http://www.netvibes.com/themes/uwa/style.css" />
<script type="text/javascript" src="http://www.netvibes.com/js/UWA/load.js.php?env=Standalone"></script>
<style type="text/css">
/*
declare here your css rules, prefixed with your widget name
*/
.MyWidget h1 {
color:green;
}
</style>
<widget:preferences>
<preference name="url" type="text" label="URL" defaultValue="http://feeds.feedburner.com/NetvibesDevBlog" />
<preference name="password" type="password" label="Password" />
<preference name="displayImages" type="boolean" label="Display images?" defaultValue="true" />
<preference name="limit" type="range" label="Number of items to display" defaultValue="10" step="1" min="1" max="25" />
<preference name="category" type="list" label="Category" defaultValue="1st" onchange="onCategoryPrefChange">
<option value="all" label="all" />
<option value="1st" label="First category" />
<option value="2nd" label="Second category" />
<option value="3rd" label="Third category" />
</preference>
<preference name="search" type="hidden" defaultValue="" />
</widget:preferences>
<script type="text/javascript">
var MyWidget = {
// var used to cache some data
data: null,
// var used to cache widget dom elements
elements: {},
// this method is called by widget.onLoad
load: function(){
// create base skeleton
MyWidget.buildSkeleton();
// load a rss feed using Ajax, MyWidget.parse is used as a callback
UWA.Data.getFeed(widget.getValue('url'), MyWidget.parse);
},
// method to build widget skeleton
buildSkeleton: function(){
// clear widget body content
widget.body.empty();
// create a DIV used as a main container, then inject it in our widget body
MyWidget.elements['container'] = widget.createElement('div', {
'class' : 'MyWidget'
}).inject(widget.body);
// display a message while loading
MyWidget.elements['container'].setText('Loading...');
},
// Called once the feed is loaded
// 'data' will contains the feed as an Object
parse: function(data){
// fill our variable 'MyWidget.data' with info we need
MyWidget.data = {
'feedTitle': data.title,
'firstArticleTitle': data.items[0].title
}
// start widget display
MyWidget.display();
},
// method to display the result of our ajax call
display: function(){
var html = '<h1>' + MyWidget.data.feedTitle + '</h1>';
html += '<h2>' + MyWidget.data.firstArticleTitle + '</h2>';
MyWidget.elements['container'].setHTML(html);
}
};
// widget.onLoad is the first method called by the UWA Framework to start your widget
widget.onLoad = MyWidget.load;
// widget onRefresh is called when the user click on the widget refesh button
// here we link the refresh to widget.onLoad
widget.onRefresh = widget.onLoad;
// this method is called each time the "category" preference changes
widget.onCategoryPrefChange = widget.onLoad;
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment