improve player counter

This commit is contained in:
Thibault Duplessis 2013-06-10 20:31:51 +02:00
parent 1a744f1177
commit 8cee559d58
2 changed files with 9 additions and 4 deletions

View file

@ -7,7 +7,7 @@ import controllers.routes
trait AssetHelper {
val assetVersion = 62
val assetVersion = 63
def cssTag(name: String) = css("stylesheets/" + name)

View file

@ -272,10 +272,15 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
var $tag = $('#nb_connected_players > strong');
if ($tag.length && e) {
var prev = parseInt($tag.text()) || Math.max(0, (e - 10));
var interv = lichess.socket.pingInterval() / 4;
_.each([0, 1, 2, 3], function(it) {
var k = 6;
var interv = lichess.socket.pingInterval() / k;
_.each(_.range(k), function(it) {
setTimeout(function() {
$tag.text(Math.round(((prev * (3 - it)) + (e * (it + 1))) / 4));
var val = Math.round(((prev * (k - 1 - it)) + (e * (it + 1))) / k);
if(val != prev) {
$tag.text(val);
prev = val;
}
}, Math.round(it * interv));
});
}