Skip to content

Commit

Permalink
Keyboard shortcuts: also remove box before redirect when pressing Ent…
Browse files Browse the repository at this point in the history
…er, not only on cancel
  • Loading branch information
mpsijm authored and meisterT committed Sep 27, 2024
1 parent 09a8126 commit a277691
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions webapp/public/js/domjudge.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,38 +905,40 @@ function initializeKeyboardShortcuts() {
if (e.key >= '0' && e.key <= '9') {
sequence += e.key;
box.text(type + sequence);
} else if (e.key === 'Enter') {
ignore = false;
switch (type) {
case 's':
type = 'submissions';
break;
case 't':
type = 'teams';
break;
case 'p':
type = 'problems';
break;
case 'c':
type = 'clarifications';
break;
case 'j':
window.location = domjudge_base_url + '/jury/submissions/by-judging-id/' + sequence;
return;
}
var redirect_to = domjudge_base_url + '/jury/' + type;
if (sequence) {
redirect_to += '/' + sequence;
}
window.location = redirect_to;
} else {
ignore = false;
if (box) {
box.remove();
}
// We want to reset the `sequence` variable before redirecting, but then we do need to save the value typed by the user
var typedSequence = sequence;
sequence = '';
$body.off('keydown');
$body.on('keydown', oldFunc);
if (e.key === 'Enter') {
switch (type) {
case 's':
type = 'submissions';
break;
case 't':
type = 'teams';
break;
case 'p':
type = 'problems';
break;
case 'c':
type = 'clarifications';
break;
case 'j':
type = 'submissions/by-judging-id';
break;
}
var redirect_to = domjudge_base_url + '/jury/' + type;
if (typedSequence) {
redirect_to += '/' + typedSequence;
}
window.location = redirect_to;
}
}
});
}
Expand Down

0 comments on commit a277691

Please sign in to comment.