Created
April 29, 2009 11:10
-
-
Save iandexter/103718 to your computer and use it in GitHub Desktop.
Delicious link roller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2 class="sidebar-title">latest del.icio.us postings</h2> | |
<div id="delicious-posts"></div> | |
<script type="text/javascript" src="http://del.icio.us/feeds/json/iandexter?count=15"></script> | |
<script type="text/javascript"> | |
/** | |
* Delicious linkroll - Modified code from del.icio.us link roller. | |
* Ian Dexter R. Marquez, 2006 - http://delicious.com/iandexter | |
* Revision: Added HTML escaping and URI encoding; sorted recent bookmarks alphabetically | |
*/ | |
document.write('<style type="text/css">#delicious-posts ul{list-style-type:none} #delicious-posts span{font-size:smaller;margin:0;}</style>'); | |
function showImage(img) { return (function(){ img.style.display='inline'; }) } | |
String.prototype.escapeHTML = function () { return(this.replace(/&/g,'&') . replace(/>/g,'>') . replace(/</g,'<') . replace(/"/g,'"')); }; | |
var ul = document.createElement('ul'); | |
var p = Delicious.posts; | |
p.sort(function(a,b) { | |
var ad = (''+a.d).toLowerCase(); | |
var bd = (''+b.d).toLowerCase(); | |
return ( (ad > bd) ? 1 : ( (ad < bd) ? -1 : 0) ); | |
}); | |
for(var i=0; i<p.length; i++) { | |
var post = p[i]; | |
var li = document.createElement('li'); | |
var url = document.createElement('a'); | |
var tags = document.createElement('span'); | |
var note = document.createElement('span'); | |
var img = document.createElement('img'); | |
img.style.display = 'none'; | |
img.style.padding = '0 2px 0 0'; | |
img.height = img.width = 16; | |
img.src = post.u.split('/').splice(0,3).join('/')+'/favicon.ico'; | |
img.onload = showImage(img); | |
url.setAttribute('href', encodeURI(post.u)); | |
url.appendChild(document.createTextNode(post.d.escapeHTML())); | |
if(post.t) { | |
tags.appendChild(document.createTextNode(' / ')); | |
for(var j=0; j<post.t.length; j++) { | |
var tag = document.createElement('a'); | |
var tagu = 'http://del.icio.us/iandexter/' + encodeURI(post.t[j]); | |
tag.setAttribute('href', tagu); | |
tag.appendChild(document.createTextNode(post.t[j].escapeHTML())); | |
tags.appendChild(tag); | |
tags.appendChild(document.createTextNode(' ')); | |
} | |
} | |
if(post.n) { | |
var post_note = post.n ? post.n : ''; | |
url.setAttribute('title', post_note.escapeHTML()); | |
note.appendChild(document.createElement('br')); | |
note.appendChild(document.createTextNode(post_note.escapeHTML())); | |
} | |
li.appendChild(img); | |
li.appendChild(url); | |
li.appendChild(tags); | |
li.appendChild(note); | |
ul.appendChild(li); | |
} | |
document.getElementById('delicious-posts').appendChild(ul); | |
</script> | |
<noscript><h2 class="sidebar-title"><a href="http://delicious.com/iandexter">latest del.icio.us postings</a></h2></noscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment