<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs
		title="del.icio.us popular"
		title_url="http://del.icio.us/popular/"
		description="A simple module that displays the most popular links on del.icio.us."
		author="John Resig"
		author_affiliation="Juniper Bay"
		author_email="jeresig+igdel@gmail.com"
		author_location="Rochester, NY"
		screenshot="http://ejohn.org/apps/igdel/igdel.gif"/> 
  <Content type="html">
     <![CDATA[
		 	 <style>ul { padding: 0; margin: 0; font-family: Arial; font-size: 13px; line-height: 16px; }
			 li { margin: 3px 0; height: 16px; overflow: hidden; }
			 li.even { background: #F5F5F5; }</style>
			 <div id="container"></div>
			<script type="text/javascript">
			var url = "http://del.icio.us/rss/popular";
			function showImage(img){ return (function(){
				img.style.display='inline'
				img.nextSibling.style.marginLeft = '20px'
			}) }
			function show(Feed) {
				var b = document.getElementById('container');
				while ( b.firstChild )
					b.removeChild( b.firstChild );
				var ul = document.createElement('ul');
				for (var i=0, post; post = Feed.entries[i]; i++) {
					var li = document.createElement('li')
					if ( i % 2 == 0 ) li.className = "even";
					var a = document.createElement('a')
					a.setAttribute('href', post.link)
					a.appendChild(document.createTextNode(post.title))
					var img = document.createElement('img')
					img.style.position = 'absolute'
					img.style.display = 'none'
					img.height = img.width = 16
					img.src = post.link.split('/').splice(0,3).join('/')+'/favicon.ico'
					img.onload = showImage(img);
					li.appendChild(img)
					li.appendChild(a)
					ul.appendChild(li)
				}
				b.appendChild(ul)
			}
			function load(){
				var head = document.getElementsByTagName("head")[0];
				script = document.createElement('script');
				script.type = 'text/javascript';
				script.src = "http://ejohn.org/apps/rss2json/?url=" + 
					url + "&callback=show&t=" + (new Date()).getTime();
				head.appendChild(script)
			}
			window.onload = load;
			setInterval( load, 1000 * 60 * 60 );
			</script>
     ]]>
  </Content> 
</Module>
