public/js/CmdPrompt.js
/**
 *
 * @param cmds String[] a list of cmds used to generate prompt options
 * @param data the data user inputted (command argument)
 */
@param cmds String[] a list of cmds used to generate prompt options
@param data the data user inputted (command argument)
@param cmds String [] a list of cmds used to generate prompt options @param data the data user inputted ( command argument )
function populateCmdPromptCmds(cmds, data) {
    let $prompt = $('#cmd-prompt');
    $prompt.prepend($('<div class="button" data-id="cancel">Cancel</div>'));
    _.forEach(cmds, function (cmd) {
        let $cmd = $('<div class="button">' + cmd + '</div>');
        $cmd.attr('cmd', cmd);
        $prompt.prepend($cmd);
    });
    $('#cmd-prompt .button').click(function (e) {
        let $button = $(e.target);
        if ($button.attr('data-id') == 'cancel') {
            hideCmdPrompt();
        }
        else {
            let cmdName = $button.attr('cmd');
            hideCmdPrompt();
            if (_.has(SpecialsCommands, cmdName)) {
                SpecialsCommandsNextStep[cmdName].apply(this, data);
            }
            else {
                Commands[cmdName].apply(this, data);
            }
        }
    });
}
function populateCmdPromptCmds ( cmds , data ) { let $prompt = $ ( '#cmd-prompt' ) ; $prompt . prepend ( $ ( '<div class="button" data-id="cancel">Cancel</div>' ) ) ; _ . forEach ( cmds , function ( cmd ) { let $cmd = $ ( '<div class="button">' + cmd + '</div>' ) ; $cmd . attr ( 'cmd' , cmd ) ; $prompt . prepend ( $cmd ) ; } ) ; $ ( '#cmd-prompt .button' ) . click ( function ( e ) { let $button = $ ( e . target ) ; if ( $button . attr ( 'data-id' ) == 'cancel' ) { hideCmdPrompt ( ) ; } else { let cmdName = $button . attr ( 'cmd' ) ; hideCmdPrompt ( ) ; if ( _ . has ( SpecialsCommands , cmdName ) ) { SpecialsCommandsNextStep [ cmdName ] . apply ( this , data ) ; } else { Commands [ cmdName ] . apply ( this , data ) ; } } } ) ; }
@param cmds String[] a list of cmds used to generate prompt options
 @param data the data user inputted (command argument)
@param cmds String [] a list of cmds used to generate prompt options @param data the data user inputted ( command argument )
//$prompt.find('.button').not('.button[data-id=cancel]').remove(); // add listener here because we generate the buttons dynamically // console.log($button.attr('cmd'));