Merge branch 'master' of github.com:ornicar/lila into prettier

* 'master' of github.com:ornicar/lila:
  storm button hotkeys
pull/7944/head
Panayiotis Lipiridis 2021-01-27 11:37:41 +02:00
commit 63ddf105a1
2 changed files with 12 additions and 5 deletions

View File

@ -41,12 +41,14 @@ export default class StormCtrl {
};
this.promotion = makePromotion(this.withGround, this.makeCgOpts, redraw);
this.checkDupTab();
setTimeout(this.hotkeys, 1000);
}
clockMillis = (): number | undefined =>
this.vm.run.startAt && Math.max(0, this.vm.run.startAt + this.vm.clock - getNow());
end = (): void => {
if (!this.vm.puzzleStartAt) return;
this.vm.history.reverse();
this.vm.run.endAt = getNow();
this.ground(false);
@ -244,4 +246,11 @@ export default class StormCtrl {
}
});
}
private hotkeys = () => {
window.Mousetrap
.bind('space', () => location.reload())
.bind('return', this.end);
}
}

View File

@ -49,17 +49,15 @@ const renderControls = (ctrl: StormCtrl): VNode =>
attrs: {
href: '/storm',
'data-icon': 'B',
title: 'New run'
title: 'New run (hotkey: Space)'
}
}),
h('a.storm__control__end.button.button-empty', {
attrs: {
'data-icon': 'b',
title: 'End run',
title: 'End run (hotkey: Enter)',
},
hook: onInsert(el => el.addEventListener('click', () => {
if (ctrl.vm.puzzleStartAt) ctrl.end()
}))
hook: onInsert(el => el.addEventListener('click', ctrl.end))
})
]);