Skip to content

Commit a277691

Browse files
mpsijmmeisterT
authored andcommitted
Keyboard shortcuts: also remove box before redirect when pressing Enter, not only on cancel
1 parent 09a8126 commit a277691

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

webapp/public/js/domjudge.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -905,38 +905,40 @@ function initializeKeyboardShortcuts() {
905905
if (e.key >= '0' && e.key <= '9') {
906906
sequence += e.key;
907907
box.text(type + sequence);
908-
} else if (e.key === 'Enter') {
909-
ignore = false;
910-
switch (type) {
911-
case 's':
912-
type = 'submissions';
913-
break;
914-
case 't':
915-
type = 'teams';
916-
break;
917-
case 'p':
918-
type = 'problems';
919-
break;
920-
case 'c':
921-
type = 'clarifications';
922-
break;
923-
case 'j':
924-
window.location = domjudge_base_url + '/jury/submissions/by-judging-id/' + sequence;
925-
return;
926-
}
927-
var redirect_to = domjudge_base_url + '/jury/' + type;
928-
if (sequence) {
929-
redirect_to += '/' + sequence;
930-
}
931-
window.location = redirect_to;
932908
} else {
933909
ignore = false;
934910
if (box) {
935911
box.remove();
936912
}
913+
// We want to reset the `sequence` variable before redirecting, but then we do need to save the value typed by the user
914+
var typedSequence = sequence;
937915
sequence = '';
938916
$body.off('keydown');
939917
$body.on('keydown', oldFunc);
918+
if (e.key === 'Enter') {
919+
switch (type) {
920+
case 's':
921+
type = 'submissions';
922+
break;
923+
case 't':
924+
type = 'teams';
925+
break;
926+
case 'p':
927+
type = 'problems';
928+
break;
929+
case 'c':
930+
type = 'clarifications';
931+
break;
932+
case 'j':
933+
type = 'submissions/by-judging-id';
934+
break;
935+
}
936+
var redirect_to = domjudge_base_url + '/jury/' + type;
937+
if (typedSequence) {
938+
redirect_to += '/' + typedSequence;
939+
}
940+
window.location = redirect_to;
941+
}
940942
}
941943
});
942944
}

0 commit comments

Comments
 (0)