iandexter (owner)

Revisions

gist: 103718 Download_button fork
public
Public Clone URL: git://gist.github.com/103718.git
Embed All Files: show embed
delicious.linkroller.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<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,'&amp;') . replace(/>/g,'&gt;') . replace(/</g,'&lt;') . replace(/"/g,'&quot;')); };
 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>