Speedometer – A Quick iPhone WebKit App

I rather threw together a speedometer app using the original iPhone SDK: Safari.

Screenshot

An Early Screenshot

An Early Screenshot (note to self: replace with updated screenshot)

It’s all JavaScript, CSS3 and HTML5. The gauges are all built and controlled with a JavaScript library that I developed, and are rendered with CSS3. The only images are the footer bar texture and the logo1 (I know, looking at that screenshot, it’s hard to believe).

I built this for two reasons. The first being that I wanted a rotary gauge JavaScript library (for use in another unrelated project), and the second being that I wanted to demonstrate (mostly to myself) how feasible these WebKit apps really are.

Installation

When you go to the app’s URL, you’ll be given instructions on how to install it (it’s as simple as bookmarking it to your homescreen). Then, when you launch it, it will download and cache all the assets2, and each subsequent launch after that will check for updates if your device has network access.

How it works

Basically, the app calculates how fast you’re going by getting the distance between your current position and your last position and dividing that by how long it took to get there. There are other things going on, like soft rejecting3 positions that would seem to indicate an acceleration of anything above 2g4.

This could be further optimized, of course, and when I do that, I can push those changes and everyone (with a network connection) will have access to the new version as soon as they launch.

Features

  • A speedometer
  • A bearing indicator (it tells you what direction you’re heading)
  • An analog clock

The clock was really just an exercise for myself. It’s basically a rotary gauge with 3 custom indicators with their own values.

If you have an idea for what should be there instead of the analog clock (or any other feedback, really), feel free to let me know. I’m also on twitter.

Sidenote(s)

Debugging and testing this isn’t easy. While iPhone can hit .local domains on a local network, I couldn’t exactly do use a local network to test this app. I had to be in motion. I spent time while commuting to do my testing and debugging. I also needed full access to the internet to update the remote servers so the iPhone could access the app. I don’t think I could have done this without tethering5.

I might have been able to create a WiFi network with my MacBook to get access to the .local domain, but even in that case, I’d have to configure my development environment to serve this app from my .local address, and that’s also not ideal. Meh, I’ll figure out the best solution eventually.

Forgive my rambling, I had to be up early this morning (like, so early it was still Saturday for another 30 minutes).

  1. With the exception of the startup graphic and app icon. 

  2. In this case, an HTML file, a couple JavaScript files, a stylesheet, and a couple images. 

  3. Is that a thing? Basically, what I mean by this is that if it the location doesn’t fit the criteria, I’ll ignore it, but keep it around. If it starts looking like the location was correct, I’ll switch to the rejected set. 

  4. If you happen to be able to accelerate at 2g, let me know once you’ve returned to Earth. 

  5. Which I technically shouldn’t be able to do until tomorrow (Monday, June 7th). 

iPad and onMouseOver

I’ve been putting the iPad simulator through its paces and I’ve run across one interesting feature in the new MobileSafari: onmouseover!

Many people, myself included1, assumed that onmouseover was dead2 with the arrival of touch based web browsers, and up until iPhone OS 3.2 that seemed to be the case. However, in my testing, I’ve found that the first tap on an element with an onmouseover “attribute” will trigger the onmouseover event, stop the click event from propagating to any children until a second tap after the onmouseover has fired.

Setting focus elsewhere (via tapping other onmouseover watching elements or form fields) will trigger the onmouseout event and, again, tapping on the element a second time while the onmouseover is active sends the click down to its child elements. You can see this in action with Twitter’s “hovercards”.

Sadly, adding those behaviors using jQuery doesn’t seem to give it the same magic. Perhaps we’ll see it in the next version of MobileSafari, and hopefully on iPhone as well. These are preliminary findings, of course, and in order to do more testing I’ll require an iPad (with 3G, please).

Anyone?

  1. I even went so far as to start replacing my onmouseovers with click events on lib.rario.us but I couldn’t go through with it. 

  2. By “dead”, I mean “functionally useless.” 

This is why…

… we’re married.

Dave
http://www.flashmobileblog.com/2010/02/23/redmond-pie-and-the-farmville-test/ oh man.
Nicole
heh
Nicole
i can barely run flash on my computer.. i don’t want it on my phone..
Nicole
ew
Dave
rofl
Dave
all the ipad haters say ‘my wife doesn’t care about how cool the ipad is, she just wants to play farvmille THIS IS WHY THE IPAD SUCKS’
Dave
apparently the ipad haters married idiots. :D