I’ve been wanting to make myself a Firefox extension that would display the next bus times at my home bus stop since forever. I don’t know how many times when I’m about to go out, but forget to check the buses until the last minute and then finding out that the bus just left. If only the bus schedule was in the status bar for me to see as I web surf!
I live in Metro Vancouver, and the local bus operator, Translink maintains a pretty good online system of bus times. Whether or not the bus drivers follow the schedule is another story, but lately it has been ok. I do remember times when buses were 30+ minutes late D:
Today I finally made some effort towards actually building the extension, and I actually made progress!
It makes use of Translink’s own NextBus feature, looks up a bus route at a particular stop and shows it in the Firefox status bar. Now I just need to add user preferences to set the refresh interval, and the GUI to input the bus stop and bus route numbers. And test it of course.
The most useful article I used so far was one from the Mozilla Development Center: Creating a Dynamic Status Bar Extension. It does something really similar, loading stocks quotes from yahoo stocks. It teaches how to use the XMLHttpRequest object to get data from an URL. However ir doesn’t tell you that you need to wait for the page to load though, and that caused me many hours of confusion *laugh* You need to wait for the XMLHttpRequest object’s readyState to change to 4 (completed), which I now know thanks to this ajax tutorial. So yes, if you want to make a similar extension that’s all you need. And if you live in Metro Vancouver, I might put my extension up for download when I’m done…
Oh, and this is pretty obvious but I’m not affiliated with Translink in anyway. And now the stop# shown above is not my home stop, and that is not the bus I take.
