Rails, Simile Timeline and Pocket IE

Following on from earlier, I ran into another problem with my little test application but, thankfully, it ended up being easy to fix.

In the application I make use of Timeline. Including it in the application is simple enough. I just include this:

"http://simile.mit.edu/timeline/api/timeline-api.js" )
in the html.erb file and the Timeline is available for use (I'll probably go with a local version at some point soon, I've just not got around to sorting that out yet).

The problem I ran into is that Pocket IE on my Pocket PC (a Dell Axim X50) doesn't seem to like this and throws an "Object Error". This was easy enough to solve in the end. I simply added this:
# Test if the request came from Pocket IE.
def pocket_ie?( request )
request.env[ "HTTP_USER_AGENT" ][ /MSIE.*Windows CE/ ]
to my ApplicationHelper class and then, in the html.erb file, simply said:
unless pocket_ie?( request )
"http://simile.mit.edu/timeline/api/timeline-api.js" )
Combined with a handheld specific stylesheet to hide the div that contains the timeline I end up with a version of the page that works in Pocket IE with no problems.

Okay, I guess it's a little kludgy, but it works and solves the problem at hand.

No comments:

Post a Comment