@@ -965,6 +965,7 @@ $(function () {
965965function initializeKeyboardShortcuts ( ) {
966966 var $body = $ ( 'body' ) ;
967967 var ignore = false ;
968+ const validKeys = new Set ( [ 'c' , 'd' , 'j' , 'p' , 's' , 't' ] ) ;
968969 $body . on ( 'keydown' , function ( e ) {
969970 var keysCookie = getCookie ( 'domjudge_keys' ) ;
970971 if ( keysCookie != 1 && keysCookie != "" ) {
@@ -1010,7 +1011,7 @@ function initializeKeyboardShortcuts() {
10101011 parts [ parts . length - 1 ] += '?' + params [ 1 ] ;
10111012 }
10121013 window . location = parts . join ( '/' ) ;
1013- } else if ( ! ignore && ( key === 's' || key === 't' || key === 'p' || key === 'j' || key === 'c' ) ) {
1014+ } else if ( ! ignore && validKeys . has ( key ) ) {
10141015 if ( e . shiftKey && key === 's' ) {
10151016 window . location = domjudge_base_url + '/jury/scoreboard' ;
10161017 return ;
@@ -1053,6 +1054,27 @@ function initializeKeyboardShortcuts() {
10531054 $body . on ( 'keydown' , oldFunc ) ;
10541055 if ( e . key === 'Enter' ) {
10551056 switch ( type ) {
1057+ case 'd' :
1058+ if ( editors ) {
1059+ const editorId = Object . keys ( editors ) [ 0 ] ;
1060+ const diffEditor = editors [ editorId ] ;
1061+ const select = diffEditor . submissionSelect ;
1062+ if ( typedSequence . length === 0 ) {
1063+ // Reset to no-diff.
1064+ select . selectedIndex = 0 ;
1065+ select . dispatchEvent ( new Event ( 'change' ) ) ;
1066+ return ;
1067+ }
1068+ const url = domjudge_base_url + `/jury/submissions/${ typedSequence } ` ;
1069+ for ( let i = 0 ; i < select . options . length ; i ++ ) {
1070+ if ( select . options [ i ] . dataset . url === url ) {
1071+ select . selectedIndex = i ;
1072+ select . dispatchEvent ( new Event ( 'change' ) ) ;
1073+ return ;
1074+ }
1075+ }
1076+ }
1077+ return ;
10561078 case 's' :
10571079 type = 'submissions' ;
10581080 break ;
@@ -1308,7 +1330,7 @@ const disableButton = (btn) => {
13081330 btn . ariaDisabled = true ;
13091331}
13101332
1311- const editors = [ ] ;
1333+ const editors = { } ;
13121334function initDiffEditor ( editorId ) {
13131335 const wrapper = $ ( `#${ editorId } -wrapper` ) ;
13141336
@@ -1360,6 +1382,7 @@ function initDiffEditor(editorId) {
13601382 const diffLink = diffTitle . querySelector ( 'a.diff-link' ) ;
13611383
13621384 const editor = {
1385+ 'submissionSelect' : select [ 0 ] ,
13631386 'getDiffMode' : ( ) => {
13641387 for ( let radio of radios ) {
13651388 if ( radio . checked ) {
@@ -1399,7 +1422,7 @@ function initDiffEditor(editorId) {
13991422 } ) ;
14001423
14011424 const selected = select [ 0 ] . options [ select [ 0 ] . selectedIndex ] ;
1402- if ( selected && selected . dataset . tag ) {
1425+ if ( ! select [ 0 ] . disabled && selected && selected . dataset . tag ) {
14031426 setDiffTag ( selected . dataset . tag ) ;
14041427 }
14051428
0 commit comments