polish lobby
This commit is contained in:
parent
06571d9325
commit
272d3ae9a2
|
@ -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));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue