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.

4 thoughts on Weborandom – Now With Snapshots

  1. Believe it or not, it stemmed from thinking it of the name. Sometimes websites happen like that. Once I decided to do a random web page website, it was clear Ajax would be involved, so …

  2. Hi,

    I checked your snapshots enabled site and came to the following conclusion: the snapshots function works the first time the page is loaded. Once the randomize button is hit, the snapshots function doesnt work anymore. Tested it in FireFox, IE and Chrome. With my own site i’m trying to achieve what i think u tried to…. to have the script also activate snapshots functionality after the randomize button is hit. Do u have any idea why this doesnt work?

    Kind regards, Roger Peters

  3. Hi Roger,

    I’m not too surprised about this bug. I’d have to look into the code in more detail, but I’m actually planning to retire Weborandom anyway as I never had the time to set up an auto-update for its database.

Leave a Reply