|
The Gmail CounterRight now, Gmail gives you exactly 2000 MB of storage space. Have you ever wondered how the Gmail storage counter really works? I was bored one day and decided to investigate a bit. Turns out the counter doesn't really do much except get the current system time and compare it against several present time points. It then calculates what the max storage would be if it was indeed being increased at a constant rate. Kind of slick, but not entirely a surprise. And it's all done with Javascript (yuck!). ;-) Anyway, here's the code I pulled out of Google's page if anyone's interested. This first part goes inside the <head> tag:
This second part goes wherever you want the counter:
The "2000" is a default value in case the user has Javascript turned off. The other bit activates the update function, which re-activates itself on a timer each time it executes. Kinda cool, eh? Yeah, I know, not really... Also, since everything is hard-coded, this explanation will most likely be outdated as soon as Google changes their Gmail front page (for instance, to do a surprise one-time storage increase). The concept will probably remain similar, though, even if the exactly times and values change. Anyway, all of the above code is also in the source for this document. Yes, you can check. In FireFox, it's View->Page Source and in IE it's just View->Source. You might also learn a thing or two about how I coded this site. Not that it's a good model in any way. If you do investigate, please remember that PHP is processed server-side, so you're really not seeing my original source code, but only what the PHP processor feeds you. Mwa-ha-ha-ha!!! :-)
|