ui/round util.dataIcon

pull/2719/merge
Thibault Duplessis 2017-05-23 10:34:28 +02:00
parent ad5845a7cd
commit 707b0fa33b
5 changed files with 21 additions and 14 deletions

View File

@ -1,5 +1,5 @@
import * as button from '../view/button';
import { bind } from '../util';
import { bind, dataIcon } from '../util';
import { game } from 'game';
import { h } from 'snabbdom'
@ -92,7 +92,7 @@ function showBerserk(ctrl, color) {
function renderBerserk(ctrl, color, position) {
return showBerserk(ctrl, color) ? h('div.berserk_alert.' + position, {
attrs: {'data-icon': '`'}
attrs: dataIcon('`')
}) : null;
}
@ -103,13 +103,13 @@ function goBerserk(ctrl) {
attrs: { 'data-hint': "GO BERSERK! Half the time, bonus point" },
hook: bind('click', ctrl.goBerserk)
}, [
h('span', { attrs: {'data-icon': '`'} })
h('span', { attrs: dataIcon('`') })
]);
}
function tourRank(ctrl, color, position) {
var d = ctrl.data;
return (d.tournament && d.tournament.ranks && !showBerserk(ctrl, color)) ?
return (d.tournament && d.tournament.ranks && !showBerserk(ctrl, color)) ?
h('div.tournament_rank.' + position, {
attrs: {title: 'Current tournament rank'}
}, '#' + d.tournament.ranks[color]) : null;

View File

@ -13,6 +13,12 @@ const pieceScores = {
king: 0
};
export function dataIcon(icon: string) {
return {
'data-icon': icon
};
}
export function uci2move(uci: string): cg.Key[] | undefined {
if (!uci) return undefined;
if (uci[1] === '@') return [uci.slice(2, 4) as cg.Key];

View File

@ -70,7 +70,7 @@ export function standard(ctrl, condition, icon, hint, socketMsg, onclick): VNode
}
}
}, [
h('span', { attrs: {'data-icon': icon} })
h('span', { attrs: util.dataIcon(icon) })
]);
};
export function forceResign(ctrl) {
@ -89,11 +89,11 @@ export function resignConfirm(ctrl): VNode {
h('button.fbt.no.hint--bottom', {
attrs: { 'data-hint': ctrl.trans.noarg('cancel') },
hook: util.bind('click', () => ctrl.resign(false))
}, [h('span', { attrs: {'data-icon': 'L'} })]),
}, [h('span', { attrs: util.dataIcon('L') })]),
h('button.fbt.yes.active.hint--bottom', {
attrs: {'data-hint': ctrl.trans.noarg('resign') },
hook: util.bind('click', () => ctrl.resign(true))
}, [h('span', { attrs: { 'data-icon': 'b'} })])
}, [h('span', { attrs: util.dataIcon('b') })])
]);
};
export function threefoldClaimDraw(ctrl) {
@ -190,7 +190,7 @@ export function backToTournament(ctrl): VNode | undefined {
action: '/tournament/' + d.tournament.id + '/withdraw'
}
}, [
h('button.text.button.weak', { attrs: {'data-icon': 'Z'} }, 'Pause')
h('button.text.button.weak', { attrs: util.dataIcon('Z') }, 'Pause')
]),
analysisButton(ctrl)
]) : undefined;
@ -200,7 +200,7 @@ export function moretime(ctrl) {
attrs: { 'data-hint': ctrl.trans('giveNbSeconds', ctrl.data.clock.moretime) },
hook: util.bind('click', ctrl.socket.moreTime)
}, [
h('span', { attrs: {'data-icon': 'O'}})
h('span', { attrs: util.dataIcon('O')})
]) : null;
};
export function followUp(ctrl): VNode {

View File

@ -121,13 +121,13 @@ function analyseButton(ctrl) {
return [
h('a.fbt.analysis', data, [
h('span', {
attrs: {'data-icon': 'A'},
attrs: util.dataIcon('A'),
class: {text: ctrl.data.forecastCount}
}),
ctrl.data.forecastCount
]),
showInfo ? h('div.forecast-info.info.none', [
h('strong.title.text', { attrs: {'data-icon': ''} }, 'Speed up your game!'),
h('strong.title.text', { attrs: util.dataIcon('') }, 'Speed up your game!'),
h('span.content', 'Use the analysis board to create conditional premoves.')
]) : null
];
@ -159,7 +159,7 @@ function renderButtons(ctrl) {
'data-act': 'flip'
}
}, [
h('span', {attrs: {'data-icon': 'B'}})
h('span', {attrs: util.dataIcon('B')})
]),
h('nav', [
['W', firstPly],
@ -185,7 +185,7 @@ function racingKingsInit(d) {
if (d.game.variant.key === 'racingKings' && d.game.turns === 0 && !d.player.spectator) {
const yourTurn = d.player.color === 'white' ? [h('br'), h('strong', "it's your turn!")] : [];
return h('div.message', {
attrs: {'data-icon': ''},
attrs: util.dataIcon(''),
}, [
h('span', "You have the " + d.player.color + " pieces"),
...yourTurn

View File

@ -1,6 +1,7 @@
import { game } from 'game';
import { h } from 'snabbdom'
import { dataIcon } from '../util'
function ratingDiff(player) {
if (player.ratingDiff === 0) return h('span.rp.null', '±0');
@ -11,7 +12,7 @@ function ratingDiff(player) {
function relayUser(player) {
return h('span.text', {
attrs: {'data-icon': '8'}
attrs: dataIcon('8')
},
(player.title ? player.title + ' ' : '') + player.name + ' ' +
(player.rating ? ' (' + player.rating + ')' : '')