How to make Google’s AJAX Slide Show randomize your photos

I added a handy Google Slide Show widget to my site, which pulls images from an RSS feed from my photo site. Radical like Zinka, but there was no photo randomization. With a little 1337 h4x0ring I was able to do it. You, too, can get the chicks. The magic happens by adding feedProcessedCallback to the options hash. After the feed is loaded, we run a shuffle function on the feed entries. And that’s about it. Random images. Here’s my code:

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script src="http://www.google.com/uds/solutions/slideshow/gfslideshow.js"
type="text/javascript"></script>

<script type="text/javascript">

// This does the shuffle magic
function shuffle(a) {
   var i = a.length;
   if ( i == 0 ) return false;
   while ( --i ) {
      var j = Math.floor( Math.random() * ( i + 1 ) );
      var tempi = a[i];
      var tempj = a[j];
      a[i] = tempj;
      a[j] = tempi;
   }
}

google.load("feeds", "1");

function OnLoad() {
  var feed1  = "YOUR_FEED_URL";

  var options = {
     displayTime:2000,
     transistionTime:600,
     linkTarget : google.feeds.LINK_TARGET_BLANK,
     //When the feed gets processed, shuffle the entries
     feedProcessedCallback: function() {
       var e = ss.entries; shuffle(e); ss.entries = e;
     }
  };

  var ss = new GFslideShow(feed1, "slideshow", options);
}

google.setOnLoadCallback(OnLoad);
</script>