2017-07-04 08:26:14 -06:00
|
|
|
import { h } from 'snabbdom';
|
|
|
|
import LobbyController from '../ctrl';
|
|
|
|
import { bind, spinner } from './util';
|
|
|
|
|
2017-07-14 03:04:34 -06:00
|
|
|
function renderRange(range: string) {
|
2017-07-04 08:26:14 -06:00
|
|
|
return h('div.range', range.replace('-', ' - '));
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function(ctrl: LobbyController) {
|
|
|
|
const member = ctrl.poolMember;
|
2017-07-27 03:43:26 -06:00
|
|
|
return ctrl.pools.map(function(pool) {
|
2017-07-26 05:03:17 -06:00
|
|
|
const active = !!member && member.id === pool.id,
|
|
|
|
transp = !!member && !active;
|
2017-07-04 08:26:14 -06:00
|
|
|
return h('div.pool', {
|
|
|
|
class: {
|
|
|
|
active,
|
|
|
|
transp: !active && transp
|
|
|
|
},
|
|
|
|
hook: bind('click', _ => ctrl.clickPool(pool.id), ctrl.redraw)
|
|
|
|
}, [
|
2017-07-14 03:04:34 -06:00
|
|
|
h('div.clock', pool.lim + '+' + pool.inc),
|
2017-07-26 05:03:17 -06:00
|
|
|
(active && member!.range) ? renderRange(member!.range!) : h('div.perf', pool.perf),
|
2017-07-04 08:26:14 -06:00
|
|
|
active ? spinner() : null
|
|
|
|
]);
|
|
|
|
}).concat(
|
|
|
|
h('div.custom', {
|
2017-07-26 05:03:17 -06:00
|
|
|
class: { transp: !!member },
|
2017-07-04 08:26:14 -06:00
|
|
|
hook: bind('click', _ => $('#start_buttons .config_hook').mousedown())
|
2017-07-14 03:04:34 -06:00
|
|
|
}, ctrl.trans.noarg('custom'))
|
2017-07-04 08:26:14 -06:00
|
|
|
);
|
|
|
|
}
|