Following my recent success with putting a Flickr feed on my website’s front page is the conversion of this to an all-purpose feed reporter, where RSS/Atom flavour and feed specifics are dealt with by Javascript associative arrays of functions, keyed on both variables respectively.
If you’re lucky then the feed should wait a bit while it loads the XML via Javscript’s XMLHTTPResponse()
code (querying proxies all on my website for foreign feeds like del.icio.us). Then it will report the first feed it finds, while still loading other feeds in the background. Every 15s or so it swaps to a new feed.
After writing it easily in Firefox, I found that a number of drastic changes were required for IE, as follows:
- IE doesn’t seem to have great support for the IMG element’s width or height properties, at least before the image is rendered on the page. For the Flickr feed, if
imgElem.width == 0
, I’ve had to employ some horrible regular expressions on imgElem.outerHTML (which isn’t supported by non-IE browsers, so it’s all a bit of a hack). - IE doesn’t support assigning arbitrary properties to elements. I was using these to smuggle a collection of titles and descriptions (keyed by date) into a function and that of course failed. You can use
setAttribute()
for string-like properties, but not objects, which I’ve had to pass as parameters or in some reserved scopes. - IE is very unforgiving about character encodings, behaviour which I haven’t been able to work around yet. Some of the programs that create my feeds (specifically Blosxom) aren’t very Unicode-wise and hence will happily produce invalid content. Firefox is very forgiving of this (which may or may not be the right XML way to do it, but is certainly a very patient way of dealing with web content generally). I’m currently working on my proxies to sort this out somehow, even if I have to filter everything down to the ASCII character set.
The Javascript is a single, monolithic file which relies on a beta-release version of Mochikit, and is available at http://www.jpstacey.info/index/javascript/index.js. Feel free to scrape it and re-use anything you find interesting there.