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 committed Sep 25, 2024
1 parent 56329f0 commit d0a14d8
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 d0a14d8

Please sign in to comment.