2.25h Tonight I did more work on the mbta API web interface (for lack of a snazzy term) and it was a lot of fun. I was able to pull some hex colors in from the json response and color the list of lines accordingly. I pulled in the short names and the link to their individual line feed. I also started on a new component that will grab predictions for one line at one stop going one direction. This is the level of precision you need for it to be useful. I haven’t figured out how I want to ‘wire’ it (ie where to keep state) and how to display the info, but I’ll get there. It currently grabs predictions only for one specific stop, and is barely logging those. There is room for improvement to say the least.
One thing that I am currently struggling with is that I haven’t figured out how to join the hex value from the json file with the “#” that css expects directly in the style declaration. I’m doing it outside of that line in it’s own set of curly brackets and consequently it ends up being output to the screen. I have an idea of passing the json to a function that returns the full hex code, but I haven’t gotten that working right yet. Tonight has been a lot of moving code around and slowly figuring out things like “you don’t need curly braces outside of the return loop” and “For some crazy reason you sometimes need two sets of curly braces!”
It’s been a fun two nights of playing with this. I doubt I’m going to work on this forever, but it does help a bit to make book knowledge practical.