11function capitalizeFirstLetter ( str ) {
22 return str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 ) ;
3- }
3+ }
44
55let commands = {
66 title : "" ,
@@ -374,9 +374,13 @@ $("#commandInput textarea").keydown((e) => {
374374 }
375375 }
376376 } ) ;
377- firebase . analytics ( ) . logEvent ( 'usedCommandLine' , {
378- command : command
379- } ) ;
377+ try {
378+ firebase . analytics ( ) . logEvent ( 'usedCommandLine' , {
379+ command : command
380+ } ) ;
381+ } catch ( e ) {
382+ console . log ( "Analytics unavailable" ) ;
383+ }
380384 hideCommandLine ( ) ;
381385 }
382386 return ;
@@ -403,9 +407,13 @@ $("#commandLine input").keydown((e) => {
403407 }
404408 } ) ;
405409 if ( ! subgroup && ! input ) {
406- firebase . analytics ( ) . logEvent ( 'usedCommandLine' , {
407- command : command
408- } ) ;
410+ try {
411+ firebase . analytics ( ) . logEvent ( 'usedCommandLine' , {
412+ command : command
413+ } ) ;
414+ } catch ( e ) {
415+ console . log ( "Analytics unavailable" ) ;
416+ }
409417 hideCommandLine ( ) ;
410418 }
411419 return ;
@@ -445,7 +453,7 @@ $("#commandLine input").keydown((e) => {
445453 }
446454 } ) ;
447455 } catch ( e ) { }
448-
456+
449457 return false ;
450458 }
451459} ) ;
@@ -454,25 +462,25 @@ $("#commandLine input").keydown((e) => {
454462
455463function hideCommandLine ( ) {
456464 $ ( "#commandLineWrapper" )
457- . stop ( true , true )
458- . css ( "opacity" , 1 )
459- . animate (
460- {
461- opacity : 0
462- } ,
463- 100 ,
464- ( ) => {
465- $ ( "#commandLineWrapper" ) . addClass ( "hidden" ) ;
466- }
465+ . stop ( true , true )
466+ . css ( "opacity" , 1 )
467+ . animate (
468+ {
469+ opacity : 0
470+ } ,
471+ 100 ,
472+ ( ) => {
473+ $ ( "#commandLineWrapper" ) . addClass ( "hidden" ) ;
474+ }
467475 ) ;
468- focusWords ( ) ;
469- }
470-
471- function showCommandLine ( ) {
472- $ ( "#commandLine" ) . removeClass ( 'hidden' ) ;
473- $ ( "#commandInput" ) . addClass ( 'hidden' ) ;
474- if ( $ ( "#commandLineWrapper" ) . hasClass ( "hidden" ) ) {
475- $ ( "#commandLineWrapper" )
476+ focusWords ( ) ;
477+ }
478+
479+ function showCommandLine ( ) {
480+ $ ( "#commandLine" ) . removeClass ( 'hidden' ) ;
481+ $ ( "#commandInput" ) . addClass ( 'hidden' ) ;
482+ if ( $ ( "#commandLineWrapper" ) . hasClass ( "hidden" ) ) {
483+ $ ( "#commandLineWrapper" )
476484 . stop ( true , true )
477485 . css ( "opacity" , 0 )
478486 . removeClass ( "hidden" )
@@ -481,84 +489,85 @@ function showCommandLine() {
481489 opacity : 1
482490 } ,
483491 100
484- ) ;
485- }
486- $ ( "#commandLine input" ) . val ( "" ) ;
487- updateSuggestedCommands ( ) ;
488- $ ( "#commandLine input" ) . focus ( ) ;
489- }
490-
491- function showCommandInput ( command , placeholder ) {
492- $ ( "#commandLineWrapper" ) . removeClass ( 'hidden' ) ;
493- $ ( "#commandLine" ) . addClass ( 'hidden' ) ;
494- $ ( "#commandInput" ) . removeClass ( 'hidden' ) ;
495- $ ( "#commandInput textarea" ) . attr ( 'placeholder' , placeholder ) ;
496- $ ( "#commandInput textarea" ) . val ( '' ) ;
497- $ ( "#commandInput textarea" ) . focus ( ) ;
498- $ ( "#commandInput textarea" ) . attr ( 'command' , '' ) ;
499- $ ( "#commandInput textarea" ) . attr ( 'command' , command ) ;
500- }
501-
502- function updateSuggestedCommands ( ) {
503- let inputVal = $ ( "#commandLine input" ) . val ( ) . toLowerCase ( ) . split ( " " ) ;
504- if ( inputVal [ 0 ] == "" ) {
505- $ . each ( currentCommands . list , ( index , obj ) => {
506- obj . found = true ;
507- } ) ;
508- } else {
509- $ . each ( currentCommands . list , ( index , obj ) => {
510- let foundcount = 0 ;
511- $ . each ( inputVal , ( index2 , obj2 ) => {
512- if ( obj2 == "" ) return ;
513- let re = new RegExp ( "\\b" + obj2 , "g" ) ;
514- let res = obj . display . toLowerCase ( ) . match ( re ) ;
515- if ( res != null && res . length > 0 ) {
516- foundcount ++ ;
517- } else {
518- foundcount -- ;
519- }
520- } ) ;
521- if ( foundcount > 0 ) {
522- obj . found = true ;
492+ ) ;
493+ }
494+ $ ( "#commandLine input" ) . val ( "" ) ;
495+ updateSuggestedCommands ( ) ;
496+ $ ( "#commandLine input" ) . focus ( ) ;
497+ }
498+
499+ function showCommandInput ( command , placeholder ) {
500+ $ ( "#commandLineWrapper" ) . removeClass ( 'hidden' ) ;
501+ $ ( "#commandLine" ) . addClass ( 'hidden' ) ;
502+ $ ( "#commandInput" ) . removeClass ( 'hidden' ) ;
503+ $ ( "#commandInput textarea" ) . attr ( 'placeholder' , placeholder ) ;
504+ $ ( "#commandInput textarea" ) . val ( '' ) ;
505+ $ ( "#commandInput textarea" ) . focus ( ) ;
506+ $ ( "#commandInput textarea" ) . attr ( 'command' , '' ) ;
507+ $ ( "#commandInput textarea" ) . attr ( 'command' , command ) ;
508+ }
509+
510+ function updateSuggestedCommands ( ) {
511+ let inputVal = $ ( "#commandLine input" ) . val ( ) . toLowerCase ( ) . split ( " " ) ;
512+ if ( inputVal [ 0 ] == "" ) {
513+ $ . each ( currentCommands . list , ( index , obj ) => {
514+ obj . found = true ;
515+ } ) ;
523516 } else {
524- obj . found = false ;
517+ $ . each ( currentCommands . list , ( index , obj ) => {
518+ let foundcount = 0 ;
519+ $ . each ( inputVal , ( index2 , obj2 ) => {
520+ if ( obj2 == "" ) return ;
521+ let re = new RegExp ( "\\b" + obj2 , "g" ) ;
522+ let res = obj . display . toLowerCase ( ) . match ( re ) ;
523+ if ( res != null && res . length > 0 ) {
524+ foundcount ++ ;
525+ } else {
526+ foundcount -- ;
527+ }
528+ } ) ;
529+ if ( foundcount > 0 ) {
530+ obj . found = true ;
531+ } else {
532+ obj . found = false ;
533+ }
534+ } ) ;
525535 }
526- } ) ;
527- }
528- displayFoundCommands ( ) ;
529- }
530-
531- function displayFoundCommands ( ) {
532- $ ( "#commandLine .suggestions" ) . empty ( ) ;
533- $ . each ( currentCommands . list , ( index , obj ) => {
534- if ( obj . found ) {
535- $ ( "#commandLine .suggestions" ) . append (
536- '<div class="entry" command="' + obj . id + '">' + obj . display + "</div>"
537- ) ;
536+ displayFoundCommands ( ) ;
538537 }
539- } ) ;
540- if ( $ ( "#commandLine .suggestions .entry" ) . length == 0 ) {
541- $ ( "#commandLine .separator" ) . css ( { height : 0 , margin : 0 } ) ;
542- } else {
543- $ ( "#commandLine .separator" ) . css ( {
544- height : "1px" ,
545- "margin-bottom" : ".5rem"
546- } ) ;
547- }
548- let entries = $ ( "#commandLine .suggestions .entry" ) ;
549- if ( entries . length > 0 ) {
550- $ ( entries [ 0 ] ) . addClass ( "active" ) ;
551- try {
538+
539+ function displayFoundCommands ( ) {
540+ $ ( "#commandLine .suggestions" ) . empty ( ) ;
552541 $ . each ( currentCommands . list , ( index , obj ) => {
553542 if ( obj . found ) {
554- obj . hover ( ) ;
555- return false ;
543+ $ ( "#commandLine .suggestions" ) . append (
544+ '<div class="entry" command="' + obj . id + '">' + obj . display + "</div>"
545+ ) ;
546+ }
547+ } ) ;
548+ if ( $ ( "#commandLine .suggestions .entry" ) . length == 0 ) {
549+ $ ( "#commandLine .separator" ) . css ( { height : 0 , margin : 0 } ) ;
550+ } else {
551+ $ ( "#commandLine .separator" ) . css ( {
552+ height : "1px" ,
553+ "margin-bottom" : ".5rem"
554+ } ) ;
556555 }
557- } ) ;
558- } catch ( e ) { }
559- }
560- $ ( "#commandLine .listTitle" ) . remove ( ) ;
561- // if(currentCommands.title != ''){
562- // $("#commandLine .suggestions").before("<div class='listTitle'>"+currentCommands.title+"</div>");
563- // }
564- }
556+ let entries = $ ( "#commandLine .suggestions .entry" ) ;
557+ if ( entries . length > 0 ) {
558+ $ ( entries [ 0 ] ) . addClass ( "active" ) ;
559+ try {
560+ $ . each ( currentCommands . list , ( index , obj ) => {
561+ if ( obj . found ) {
562+ obj . hover ( ) ;
563+ return false ;
564+ }
565+ } ) ;
566+ } catch ( e ) { }
567+ }
568+ $ ( "#commandLine .listTitle" ) . remove ( ) ;
569+ // if(currentCommands.title != ''){
570+ // $("#commandLine .suggestions").before("<div class='listTitle'>"+currentCommands.title+"</div>");
571+ // }
572+ }
573+
0 commit comments