function updateCommandDescription() {
        var description = '';

        // first explain manually defined commands and then all by all used engines
        var descriptions = [];

        var i, j;
        for (i = 0; i < patterns.length; i++) {
            if (patterns[i].description != undefined) {
                descriptions.push(patterns[i].description);
            }
        }
        for (i = 0; i < engines.length; i++) {
            var caps = engines[i].getCapabilities();
            for (j = 0; j < caps.length; j++) {
                descriptions.push(caps[j]);
            }
        }

        examplePhrases = [];
        for (i = 0; i < descriptions.length; i++) {
            var pdesc = descriptions[i].replace(/(['"][^'"]+['"])/gi, '<span class="phraseHighlight">$1</span>');
            pdesc = pdesc.replace(/(\[[^\[\]]+\])/gi, '<span class="placeholderHighlight">$1</span>');
            //console.log(pdesc);
            var matches = pdesc.match(/<span class=['"]phraseHighlight["']>['"](.+?)['"]<\/span>/gi);
            //console.log(matches);
            if (matches != null) {
                //console.log(matches);
                for (j = 0; j < matches.length; j++) {
                    var cleanMatch = matches[j].replace(/<\/?span[^>]*>/gi, '');
                    examplePhrases.push(cleanMatch.replace(/['"]/gi, ''));
                }
            }
            description += '<div class="commandDescription">' + pdesc + '</div>';
        }

        var datalist = $('#chatBotCommands');
        if (datalist.size() == 0) {
            datalist = $('<datalist id="chatBotCommands">');
            $('body').append(datalist);
        } else {
            datalist.html('');
        }

        for (i = 0; i < examplePhrases.length; i++) {
            datalist.append($('<option value="' + examplePhrases[i] + '"></option>'));
        }

        //console.log(examplePhrases);

        $('#chatBotCommandDescription').html(description);
    }
// list all the predefined commands and the commands of each engine
list all the predefined commands and the commands of each engine
list all the predefined commands and the commands of each engine
function updateCommandDescription() {
        var description = '';
        var descriptions = [];
        var i, j;
        for (i = 0; i < patterns.length; i++) {
            if (patterns[i].description != undefined) {
                descriptions.push(patterns[i].description);
            }
        }
        for (i = 0; i < engines.length; i++) {
            var caps = engines[i].getCapabilities();
            for (j = 0; j < caps.length; j++) {
                descriptions.push(caps[j]);
            }
        }
        examplePhrases = [];
        for (i = 0; i < descriptions.length; i++) {
            var pdesc = descriptions[i].replace(/(['"][^'"]+['"])/gi, '<span class="phraseHighlight">$1</span>');
            pdesc = pdesc.replace(/(\[[^\[\]]+\])/gi, '<span class="placeholderHighlight">$1</span>');
            var matches = pdesc.match(/<span class=['"]phraseHighlight["']>['"](.+?)['"]<\/span>/gi);
            if (matches != null) {
                for (j = 0; j < matches.length; j++) {
                    var cleanMatch = matches[j].replace(/<\/?span[^>]*>/gi, '');
                    examplePhrases.push(cleanMatch.replace(/['"]/gi, ''));
                }
            }
            description += '<div class="commandDescription">' + pdesc + '</div>';
        }
        var datalist = $('#chatBotCommands');
        if (datalist.size() == 0) {
            datalist = $('<datalist id="chatBotCommands">');
            $('body').append(datalist);
        } else {
            datalist.html('');
        }
        for (i = 0; i < examplePhrases.length; i++) {
            datalist.append($('<option value="' + examplePhrases[i] + '"></option>'));
        }
        $('#chatBotCommandDescription').html(description);
    }
function updateCommandDescription ( ) { var description = '' ; var descriptions = [ ] ; var i , j ; for ( i = 0 ; i < patterns . length ; i ++ ) { if ( patterns [ i ] . description != undefined ) { descriptions . push ( patterns [ i ] . description ) ; } } for ( i = 0 ; i < engines . length ; i ++ ) { var caps = engines [ i ] . getCapabilities ( ) ; for ( j = 0 ; j < caps . length ; j ++ ) { descriptions . push ( caps [ j ] ) ; } } examplePhrases = [ ] ; for ( i = 0 ; i < descriptions . length ; i ++ ) { var pdesc = descriptions [ i ] . replace ( / (['"][^'"]+['"]) / gi , '<span class="phraseHighlight">$1</span>' ) ; pdesc = pdesc . replace ( / (\[[^\[\]]+\]) / gi , '<span class="placeholderHighlight">$1</span>' ) ; var matches = pdesc . match ( / <span class=['"]phraseHighlight["']>['"](.+?)['"]<\/span> / gi ) ; if ( matches != null ) { for ( j = 0 ; j < matches . length ; j ++ ) { var cleanMatch = matches [ j ] . replace ( / <\/?span[^>]*> / gi , '' ) ; examplePhrases . push ( cleanMatch . replace ( / ['"] / gi , '' ) ) ; } } description += '<div class="commandDescription">' + pdesc + '</div>' ; } var datalist = $ ( '#chatBotCommands' ) ; if ( datalist . size ( ) == 0 ) { datalist = $ ( '<datalist id="chatBotCommands">' ) ; $ ( 'body' ) . append ( datalist ) ; } else { datalist . html ( '' ) ; } for ( i = 0 ; i < examplePhrases . length ; i ++ ) { datalist . append ( $ ( '<option value="' + examplePhrases [ i ] + '"></option>' ) ) ; } $ ( '#chatBotCommandDescription' ) . html ( description ) ; }
list all the predefined commands and the commands of each engine
list all the predefined commands and the commands of each engine
// first explain manually defined commands and then all by all used engines //console.log(pdesc); //console.log(matches); //console.log(matches); //console.log(examplePhrases);