polish lobby

This commit is contained in:
Thibault Duplessis 2014-12-29 20:50:19 +01:00
parent 06571d9325
commit 272d3ae9a2
3 changed files with 5 additions and 17 deletions

View file

@ -1234,7 +1234,7 @@ var storage = {
function startLobby(element, cfg) {
var $newposts = $("div.new_posts");
var nbRoundsEl = document.querySelector('#site_baseline span');
var nbrEl = document.querySelector('#site_baseline span');
var lobby;
lichess.socket = new lichess.StrongSocket(
@ -1280,15 +1280,15 @@ var storage = {
}, Math.round(Math.random() * 5000));
},
nbr: function(e) {
if (nbRoundsEl && e) {
var prev = parseInt(nbRoundsEl.textContent, 10);
if (nbrEl && e) {
var prev = parseInt(nbrEl.textContent, 10);
var k = 4;
var interv = 2000 / k;
$.fp.range(k).forEach(function(it) {
setTimeout(function() {
var val = Math.round(((prev * (k - 1 - it)) + (e * (it + 1))) / k);
if (val != prev) {
nbRoundsEl.textContent = val;
if (val !== prev) {
nbrEl.textContent = val;
prev = val;
}
}, Math.round(it * interv));

View file

@ -6,14 +6,8 @@ function sort(ctrl) {
ctrl.data.hooks.sort(order);
}
function fixBC(hook) {
if (hook.mode === 'Casual') hook.mode = 0;
else if (hook.mode === 'Rated') hook.mode = 1;
}
function init(hook) {
hook.action = hook.uid === lichess.socket.settings.params.sri ? 'cancel' : 'join';
fixBC(hook);
}
function initAll(ctrl) {

View file

@ -6,15 +6,9 @@ function sort(ctrl) {
ctrl.data.seeks.sort(order);
}
function fixBC(seek) {
if (seek.mode === 'Casual') seek.mode = 0;
else if (seek.mode === 'Rated') seek.mode = 1;
}
function initAll(ctrl) {
ctrl.data.seeks.forEach(function(seek) {
seek.action = (ctrl.data.me && seek.username === ctrl.data.me.username) ? 'cancelSeek' : 'joinSeek';
fixBC(seek);
});
sort(ctrl);
}