Weborandom – Now With Snapshots

This mashup was just obvious. You’ve probably seen these snap.com website previews that hover over links on TechCrunch and various other sites. Can be useful and can be, well, a bit annoying, depending on the site in question. For Weborandom, though, there was no question. It just made eternal sense and I kept imagining it was there, so it was high time I added it in. Admittedly, Weborandom already provides a preview, so this is a kind of preview for a preview. Works for me anyway. With thanks to snap.com for providing their easy-to-integrate API, it’s now live.

Go visit the new, new, Snapshots (TM)-enabled, Weborandom.com!!!

The main challenge was to make the previews refresh dynamically, which was achieved with a little On-Demand Javascript magic:

javascript

  1. function refreshSnapshots() {
  2.   var head = document.getElementsByTagName("head")[0];
  3.   var script = $("snapshotScript");
  4.   if (script) { head.removeChild(script); }
  5.   script = document.createElement("script");
  6.   script.id = 'snapshotScript';
  7.   script.type = 'text/javascript';
  8.   script.src = "http://shots.snap.com/snap_shots.js?ap=1&key=d2e3ec72c47f90dc1ccf4c25de818ed2&sb=0&th=silver&cl=0&si=0&po=0&df=0&oi=0&link_icon=on&shots_trigger=icon&size=large&lang=en-us&domain=weborandom.com";
  9.   head.appendChild(script)
  10. }

I daresay the next installment will be the big one: search. It was originally intended to do that, but mysql fulltext queries crawl with several million records. I’ll need to experiment with ferret and friends.