search rank in tournament without the # prefix - for #9551
parent
4f119be27f
commit
8c3cb49374
|
@ -64,6 +64,6 @@ export default function (opts: Opts): void {
|
||||||
},
|
},
|
||||||
populate: opts.populate || (r => r.name),
|
populate: opts.populate || (r => r.name),
|
||||||
onSelect: opts.onSelect,
|
onSelect: opts.onSelect,
|
||||||
regex: /^[a-z0-9][\w-]{2,29}$/i,
|
regex: /^[a-z][\w-]{2,29}$/i,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,6 @@ export default class TournamentController {
|
||||||
};
|
};
|
||||||
|
|
||||||
jumpToRank = (rank: number) => {
|
jumpToRank = (rank: number) => {
|
||||||
if (!Number.isInteger(rank) || rank < 1) return;
|
|
||||||
const page = 1 + Math.floor((rank - 1) / maxPerPage);
|
const page = 1 + Math.floor((rank - 1) / maxPerPage);
|
||||||
const row = (rank - 1) % maxPerPage;
|
const row = (rank - 1) % maxPerPage;
|
||||||
xhr.loadPage(this, page, () => {
|
xhr.loadPage(this, page, () => {
|
||||||
|
|
|
@ -32,8 +32,9 @@ export function input(ctrl: TournamentController): VNode {
|
||||||
el.focus();
|
el.focus();
|
||||||
});
|
});
|
||||||
$(el).on('keydown', e => {
|
$(el).on('keydown', e => {
|
||||||
if (e.code === 'Enter' && el.value.startsWith('#')) {
|
if (e.code === 'Enter') {
|
||||||
ctrl.jumpToRank(Number(el.value.slice(1)));
|
const rank = parseInt(e.target.value);
|
||||||
|
if (rank > 0) ctrl.jumpToRank(rank);
|
||||||
}
|
}
|
||||||
if (e.code === 'Escape') {
|
if (e.code === 'Escape') {
|
||||||
ctrl.toggleSearch();
|
ctrl.toggleSearch();
|
||||||
|
|
Loading…
Reference in New Issue