All right, you’ve got me wondering too. So I launch Firefox with
Firebug, and the first thing that happens is that Prototype.js loads
countdown.txt from apple.com. And that contains the current time and
date, a pipe symbol (|), and the starting number. I’ll leave it
running to see what else happens.
downloadcounter.js seems to be the guts of it, and it’s a very terse
bit of JavaScript that’s mostly made up of single-character function
and variable names. Not very readable. I can sort of follow its logic,
but it’s nothing I’d want to edit. It works off-line, and calls home
at an interval defined by what time of day it is to reset its counter.
Perhaps there’s times of day when the number of downloads per hour
varies wildly.
One thing I find interesting is that this code is written to support
an image of any dimension, with any number of frames. The code is
extremely abstract and configurable, and derives many of its variables
from its environment. Where I would be tempted to say “step this many
pixels and wait this many milliseconds before repeating”, this code
calculates what rate to move and how far based on the height of an
individual frame and the total height of the sprite. Very thoughtful
work.
Calling it appears to be fairly simple:
var downloadCounter = new DownloadCounter("/autopush/us/itunes/
includes/countdown.txt"),
setup = function() {
downloadCounter.setElement($("counter"));
};
downloadCounter.setDigitImageAnimationCount(6);
downloadCounter.setDigitImageHeight(103);
Event.onDOMReady(setup);
if(AC.Detector.isiPhone()) {
document.write('<style type="text/css" media="screen"> #main a.mac
{ display:none; } </style>')
} else {
document.write('<style type="text/css" media="screen"> #main a.iphone
{ display:none; } </style>')
}
And you can see that they are using the exact same page for iPhone and
regular computer, so any difference in count will be down to the
internal implementation of the flipper logic, or possibly a different
seed date. The latest iPhone has a vastly faster JavaScript engine
than the Safari 3 on the desktop, maybe there’s a timing issue there.
Well, I’ve stared at this thing for about 15 minutes, time to go back
to work. It still hasn’t phoned home.
Walter
On Apr 15, 2009, at 2:55 PM, email@hidden wrote:
I’ve used timers like this in the past (albeit using images rather
than sprites)
as a countdown to launch events (a product launch, or the start of a
trade show
Regards,
Tim.
Quoting Steve Ballinger email@hidden:
Still like to know how to do it though, but don’t know what I would
use it for.
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options