@@ -78,23 +78,33 @@ function goAhead() {
78
78
scheduleLoader ( ) ;
79
79
} ) ;
80
80
}
81
+ function isEscapeButton ( event ) {
82
+ return event . key === "Escape" || event . key === "Esc"
83
+ }
84
+ function supportKey ( event ) {
85
+ return ! ( event . ctrlKey || event . metaKey || event . shiftKey ) && ( event . code . includes ( "Key" ) || isEscapeButton ( event ) ) ;
86
+ }
81
87
function handleKeyPress ( event ) {
82
- if ( event . code . includes ( "Key" ) && ! $ ( "#overlayPleaseWait" ) . is ( ":visible" ) && ! ( event . ctrlKey || event . metaKey || event . shiftKey ) ) {
83
- if ( $ ( "#home" ) . is ( ":visible" ) ) {
84
- if ( event . key . toLowerCase ( ) == String . fromCharCode ( $ ( ".links tbody tr" ) . filter ( function ( ) {
85
- return $ ( this ) . find ( ".linkName" ) . val ( ) !== "" ;
86
- } ) . length + 65 ) . toLowerCase ( ) ) {
87
- $ ( "#broadcast1button" ) . click ( ) ;
88
- } else {
89
- $ ( ".actions .buttonContainer button" ) . eq ( event . key . toLowerCase ( ) . charCodeAt ( 0 ) - 97 ) . click ( ) ;
90
- }
91
- } else if ( $ ( "#closeButton" ) . is ( ":visible" ) && event . key . toLowerCase ( ) == "x" ) {
92
- $ ( "#closeButton" ) . click ( ) ;
93
- } else if ( $ ( ".featuredVideos" ) . is ( ":visible" ) && ! $ ( "#closeButton" ) . is ( ":visible" ) ) {
94
- $ ( ".featuredVideos > div > div" ) . eq ( event . key . toLowerCase ( ) . charCodeAt ( 0 ) - 97 ) . click ( ) ;
95
- } else if ( $ ( ".streamingVideos" ) . is ( ":visible" ) && $ ( "#closeButton" ) . is ( ":not(:visible)" ) ) {
96
- $ ( ".streamingVideos > div > div" ) . eq ( event . key . toLowerCase ( ) . charCodeAt ( 0 ) - 97 ) . click ( ) ;
88
+ if ( ! supportKey ( event ) || $ ( "#overlayPleaseWait" ) . is ( ":visible" ) ) {
89
+ return ;
90
+ }
91
+
92
+ if ( $ ( "#home" ) . is ( ":visible" ) ) {
93
+ if ( event . key . toLowerCase ( ) == String . fromCharCode ( $ ( ".links tbody tr" ) . filter ( function ( ) {
94
+ return $ ( this ) . find ( ".linkName" ) . val ( ) !== "" ;
95
+ } ) . length + 65 ) . toLowerCase ( ) ) {
96
+ $ ( "#broadcast1button" ) . click ( ) ;
97
+ } else {
98
+ $ ( ".actions .buttonContainer button" ) . eq ( event . key . toLowerCase ( ) . charCodeAt ( 0 ) - 97 ) . click ( ) ;
97
99
}
100
+ } else if ( $ ( "#closeButton" ) . is ( ":visible" ) && ( event . key . toLowerCase ( ) == "x" || isEscapeButton ( event ) ) ) {
101
+ $ ( "#closeButton" ) . click ( ) ;
102
+ } else if ( $ ( ".go-home" ) . is ( ":visible" ) && isEscapeButton ( event ) ) {
103
+ $ ( "#btnGoHome" ) . click ( ) ;
104
+ } else if ( $ ( ".featuredVideos" ) . is ( ":visible" ) && ! $ ( "#closeButton" ) . is ( ":visible" ) ) {
105
+ $ ( ".featuredVideos > div > div" ) . eq ( event . key . toLowerCase ( ) . charCodeAt ( 0 ) - 97 ) . click ( ) ;
106
+ } else if ( $ ( ".streamingVideos" ) . is ( ":visible" ) && $ ( "#closeButton" ) . is ( ":not(:visible)" ) ) {
107
+ $ ( ".streamingVideos > div > div" ) . eq ( event . key . toLowerCase ( ) . charCodeAt ( 0 ) - 97 ) . click ( ) ;
98
108
}
99
109
}
100
110
function isReachable ( hostname , port ) {
0 commit comments