File tree Expand file tree Collapse file tree 3 files changed +45
-10
lines changed Expand file tree Collapse file tree 3 files changed +45
-10
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,22 @@ function disableNotifications()
55
55
return true ;
56
56
}
57
57
58
+ function enableKeys ( )
59
+ {
60
+ setCookie ( 'domjudge_keys' , 1 ) ;
61
+ $ ( "#keys_disable" ) . removeClass ( 'd-none' ) ;
62
+ $ ( "#keys_disable" ) . show ( ) ;
63
+ $ ( "#keys_enable" ) . hide ( ) ;
64
+ }
65
+
66
+ function disableKeys ( )
67
+ {
68
+ setCookie ( 'domjudge_keys' , 0 ) ;
69
+ $ ( "#keys_enable" ) . removeClass ( 'd-none' ) ;
70
+ $ ( "#keys_enable" ) . show ( ) ;
71
+ $ ( "#keys_disable" ) . hide ( ) ;
72
+ }
73
+
58
74
// Send a notification if notifications have been enabled.
59
75
// The options argument is passed to the Notification constructor,
60
76
// except that the following tags (if found) are interpreted and
@@ -814,6 +830,10 @@ function initializeKeyboardShortcuts() {
814
830
var $body = $ ( 'body' ) ;
815
831
var ignore = false ;
816
832
$body . on ( 'keydown' , function ( e ) {
833
+ var keysCookie = getCookie ( 'domjudge_keys' ) ;
834
+ if ( keysCookie != 1 && keysCookie != "" ) {
835
+ return ;
836
+ }
817
837
// Check if the user is not typing in an input field.
818
838
if ( e . target . tagName === 'INPUT' || e . target . tagName === 'TEXTAREA' ) {
819
839
return ;
Original file line number Diff line number Diff line change 34
34
}
35
35
}
36
36
37
+ $ (' #keys_disable' ).click (disableKeys);
38
+ $ (' #keys_enable' ).click (enableKeys);
39
+ var keysCookie = getCookie (' domjudge_keys' );
40
+ if (keysCookie != 1 && keysCookie != " " ) {
41
+ $ (' #keys_enable' ).removeClass (' d-none' );
42
+ } else {
43
+ $ (' #keys_disable' ).removeClass (' d-none' );
44
+ }
45
+
37
46
updateMenuAlerts ();
38
47
setInterval (updateMenuAlerts, 20000 );
39
48
Original file line number Diff line number Diff line change 116
116
117
117
{% if refresh is defined and refresh %}
118
118
<a class =" dropdown-item" href =" #" id =" refresh-navitem" >
119
- <i class =" fas fa-sync-alt fa-fw" ></i > <span id =" refresh-toggle" >
120
- {% if refresh_flag %}
121
- Disable Refresh
122
- {% else %}
123
- Enable Refresh
124
- {% endif %}
125
- </span >
126
- {% if refresh %}
127
- <span class =" small text-muted" >({{ refresh .after }}s)</span >
128
- {% endif %}
119
+ <i class =" fas fa-sync-alt fa-fw" ></i >
120
+ <span id =" refresh-toggle" >
121
+ {% if refresh_flag %}
122
+ Disable Refresh
123
+ {% else %}
124
+ Enable Refresh
125
+ {% endif %}
126
+ </span >
127
+ <span class =" small text-muted" >({{ refresh .after }}s)</span >
129
128
</a >
130
129
{% endif %}
131
130
131
+ <a class =" dropdown-item d-none" href =" #" id =" keys_disable" >
132
+ <i class =" fas fa-keyboard fa-fw" ></i > Disable keyboard shortcuts
133
+ </a >
134
+ <a class =" dropdown-item d-none" href =" #" id =" keys_enable" >
135
+ <i class =" fas fa-keyboard fa-fw" ></i > Enable keyboard shortcuts
136
+ </a >
137
+
132
138
<a class =" dropdown-item" href =" {{ path(' logout' ) }}" ><i class =" fas fa-sign-out-alt fa-fw" ></i >Logout </a >
133
139
</div >
134
140
</li >
You can’t perform that action at this time.
0 commit comments