Delicious bookmarks counter in JavaScript

This is a script I use on a few sites to automatically count the number of
delicious links to various urls. There are a few of these that I’ve found, but
I quite like writing JavaScript like this. Also, mine will combine as many
urls as possible into a single request to the delicious API, because it’s
faster that way.

<!-- jquery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<!-- this is md5 implemented in javascript -->
<script src="http://pajhome.org.uk/crypt/md5/md5.js" type="text/javascript"></script>

<script type="text/javascript">
$(function() {

  // This function gets called per link, this depends on the template.
  // In my case, I'm walking up to the surrounding 'post' object, then
  // down to a pre-prepared p tag I want to populate with link data.
  // You will want to change this if you use this code.
  //
  // Markup is approximately:
  //
  //   <div class="post">
  //     <a href="..." class="delicious">..</a>
  //     <p class="deliciousinfo"></p>
  //   </div>
  function markup_delicious_link( element, data ) {
    var html = "<a href='http://delicious.com/url/" + data.hash + "'>";
    html += data.total_posts + " delicious link(s)";
    html += "</a>";
    element.parents(".post").find(".deliciousinfo").html(html);
  }

  // Find all links with class 'delicious'
  var hashes = [];
  var elements = {}
  $('a.delicious').each(function(index, link) {
    if ($(link).attr("href")) { // sanity check
      var hash = hex_md5( $(link).attr("href") );
      elements[ hash ] = $(link);
      hashes.push( "hash=" + hash );
    }
  });

  // Make calls to the delicious feed API to get details
  while (hashes.length) {
    // delicious permit a maximum of 15 hashes per request
    var subsection = hashes.splice(0, 15);
    var url = "http://badges.del.icio.us/feeds/json/url/data?";
    url += subsection.join("&") + "&callback=?";
    $.getJSON( url, function(data) {
      for (var i=0; i<data.length; i++) {
        var $link = elements[ data[i].hash ];
        markup_delicious_link( $link, data[i] );
      }
    });
  }

});
</script>