Testing JSON

Last ten from delicious, via the JSON api (thanks to Jason)

function showImage(img) {
return (function() {img.style.display = ‘inline’});
}
var ul = document.createElement(‘ul’);
for (var i = 0, post; post = Delicious.posts[i]; i++) {
var li = document.createElement(‘li’);
var a = document.createElement(‘a’);
var img = document.createElement(‘img’);
img.style.position = ‘absolute’;
img.style.display = ‘none’;
img.height = img.width = 16;
img.src = post.u.split(‘/’).splice(0,3).join(‘/’)+’/favicon.ico’;
img.onload = showImage(img);
a.setAttribute(‘href’, post.u);
a.style.marginLeft = ’20px’;
a.appendChild(document.createTextNode(post.d));
li.appendChild(img);
li.appendChild(a);
li.appendChild(document.createTextNode(‘ /’));
for (var k = 0, tag; tag = post.t[k]; k++) {
var t = document.createElement(‘a’);
t.setAttribute(‘href’, ‘http://del.icio.us/mathowie/’ + tag);
t.style.fontSize = ‘smaller’;
t.appendChild(document.createTextNode(tag));
li.appendChild(document.createTextNode(‘ ‘));
li.appendChild(t);
}
ul.appendChild(li);
}
document.getElementById(‘delicious-posts’).appendChild(ul);