1 week ago
Observations about the universe, life, Lausanne and me
Thursday, June 12, 2008
Good Coding Practice
I have been playing around with the Google desktop gadgets lately.
I love the sidebar, but it has always bugged me that the weather gadget only shows the forecast for the current day when docked to the sidebar like in the picture on the right. To see the forecast for the next three days you have to either undock it, then it floats around and clutters up your workspace, or click on it, then a stupid little window pops up - cluttering up your workspace. But there is no way to just expand it right there in the sidebar.
Well, I thought, I'll just have a quick look at the source code then. All gadgets are really just a bit of xml and javascript - it shouldn't be too difficult to figure out how to re-write it to do what I want it to do.
Well, without further ado, here is what professional javascript code looks like. Written either by Google's Best or a horde of drunken and angry, angry monkeys - I can't really tell:
Don't you just admire the clear structure? Not one character is wasted on comments or - heaven forfend! - whitespace. Or linebreaks. Because that's for whimps, really.
But I persevered, and finally found the bit of code I needed to change. It was in the eight of eight javascript files, naturally, 8_main.xml.compiled.js to be precise. You have to replace the instance of Function Ha() highlighted above with the function Ia(). And I know what you are thinking: "Obvious. Any idiot could have figured that out!" Well, so I did.
And here is the fruit of my labours: The expanded Google weather gadget, docked. Telling me that the weather will be crap the next three days, which is no big surprise, because it has been crap for the last two weeks. But still, it is nice to be confirmed in one's misery.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment