DHTML:Gmail 配额计数器脚本?

发布于 2024-10-11 05:43:20 字数 182 浏览 3 评论 0原文

我正在寻找一个 DHTML(最好是 AJAX),它可以提供与 Gmail 起始页上的配额计数器相同的效果。如果我提供一个初始值,我希望它以可信的方式向上计数,即它应该在重新访问时始终增加。当用户观察计数器时,该更新应该是动态的。

关于如何解决这个问题有什么想法吗?

编辑:我在这里不计算 MB,而是计算一组文档的数量。

I am looking for a DHTML (preferably AJAX) that sorta gives the same effect as the quota counter on Gmail's start page. If I provide an initial value, I would like it to count upwards in a believeable fashion, i.e. it should always increase on revisit. This update should be dynamically as the user watches the counter.

Any ideas on how to approach this?

EDIT: I am not counting MB here, rather, number of documents in a set.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人如玉 2024-10-18 05:43:20

谷歌的计数器主要用于展示,我希望你的也是如此。没有任何在后台运行的脚本会每秒增加每个用户的报价。

话虽这么说,您可以定义页面加载的默认值和递增计时器的时间间隔,然后您可以执行以下操作: http://jsfiddle.net/PD7wC/1/

编辑:
如果您实际上在服务器端统计您拥有的文档数量,并希望反映这个真实数字,那么您可以编辑我提供的 JS,每 1000ms 执行一次 AJAX 请求,例如,得到新的值。

如果您想变得更有趣,您可以在每次执行请求时创建一个新的间隔,将计数从旧值动画化到新值。例如,如果在最后一秒添加了 10 个新文档,并且您不想从 100 跳转到 110,您可以设置一个间隔,每 增加 1 >1000 毫秒 / (110 - 100) = 100 毫秒

Google's counter is mainly for show and I would expect yours is as well. There's isn't some script running in the background that increases the quote for every user each second.

That being said, you can define a default value on page load and an interval for incrementing that timer and then you can do something like: http://jsfiddle.net/PD7wC/1/

Edit:
If you actually keep a count on the server side of the number of documents you have and want this real number to be reflected then you can edit the JS I provided to do an AJAX request every 1000ms, for example, to get the new value.

If you want to get fancier you can create a new interval each time you're doing a request that animates a count up from the old value to the new. If for instance in the last second 10 new documents were added and you don't wanna just jump from 100 to 110 you can set an interval to increment by 1 every 1000ms / (110 - 100) = 100ms

蹲墙角沉默 2024-10-18 05:43:20

我不知道你具体会调用什么 javascript/ajax,但如果你访问服务器时间,你应该能够使用某种形式的算法。

如果没有,那么您可能需要考虑将数据存储在一端或另一端的某种形式的存储中,然后随着时间/循环进行计数,但这对于效果来说似乎很密集。

I don't know what specifically you'd call for javascript/ajax, but if you access to server time you should be able to use some form of algorithm with that.

If not, then you'll probably have to look at storing the data in some form of storage on one end or the other and just count up over time/loops, but this seems intensive for the effect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文