简体   繁体   English

如何在Apple制作实时广告牌?

[英]How is the real-time billboard made at Apple?

Right now, Apple shows "The App Store is about to hit 10 billion downloads". 目前,苹果公司表示“App Store即将达到100亿次下载”。

The index page contains a kind of real-time billboard, displaying a constantly increasing number of downloads. 索引页面包含一种实时广告牌,显示不断增加的下载次数。

They're using pure HTML+JS. 他们使用纯HTML + JS。

What is about real-time updating ? 什么是实时更新? What do you think ? 你怎么看 ?

It appears to fetch this document via AJAX: http://www.apple.com/autopush/us/itunes/includes/countdown.inc?r=0.7329968574922532 它似乎通过AJAX获取此文档: http//www.apple.com/autopush/us/itunes/includes/countdown.inc? r = 0.7329968574922532

Containing: 含:

20-JAN-2011 06:00:00|9944770635|1176919

It would appear this is in the format: 它看起来是这样的格式:

<timestamp>|<total as of timestamp>|<rate as of timestamp>

The javascript then increments the total by multiplying the rate by the difference between now and the timestamp. 然后,javascript通过将速率乘以now和时间戳之间的差值来增加总数。 Then it simply increments it by the rate every certain interval and animates the display. 然后它只是按每个特定间隔的速率递增它并动画显示。

It is possible that when the page loads they give a count and then they give the JavaScript a rate of increase perhaps base on recent activity. 当页面加载时,它们可能会给出计数,然后它们可能会根据最近的活动给JavaScript一个增加的速度。 If so then it is not real time updating and is also not entirely accurate if you leave it open. 如果是这样,那么它不是实时更新,如果你保持开放也不完全准确。 Only when it first loads. 仅在首次加载时。

I have not seen the timer. 我没见过计时器。 Is there a link to it available? 有链接吗?

It fetches the current count via an XHR request like http://www.apple.com/autopush/us/itunes/includes/countdown.inc?r=0.1472943772081361 它通过XHR请求获取当前计数,例如http://www.apple.com/autopush/us/itunes/includes/countdown.inc?r=0.1472943772081361

which contains a response like: 其中包含如下响应:

20-JAN-2011 06:00:00|9944770635|1176919 

That has the count (9944770635) as of 06:00 today (I guess that's UTC). 截至今天06:00有计数(9944770635)(我猜那是UTC)。 Then it uses some math to approximate the number of downloads between then and now. 然后它使用一些数学来估计当时和现在之间的下载次数。

First, it only gets the current count once via ajax (you can inspect the element and see the xhr request in firebug's HTML and NET panels), and then it animates the 'top' and 'left' position of each time container element. 首先,它只通过ajax获取当前计数(您可以检查元素并在firebug的 HTML和NET面板中查看xhr请求),然后它会动画每个时间容器元素的“顶部”和“左侧”位置。

See screenshot 见截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM