components/blockly-src/blocks/lists.js
function() {
    var MODE =
        [[Blockly.Msg.LISTS_GET_INDEX_GET, 'GET'],
         [Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE, 'GET_REMOVE'],
         [Blockly.Msg.LISTS_GET_INDEX_REMOVE, 'REMOVE']];
    this.WHERE_OPTIONS =
        [[Blockly.Msg.LISTS_GET_INDEX_FROM_START, 'FROM_START'],
         [Blockly.Msg.LISTS_GET_INDEX_FROM_END, 'FROM_END'],
         [Blockly.Msg.LISTS_GET_INDEX_FIRST, 'FIRST'],
         [Blockly.Msg.LISTS_GET_INDEX_LAST, 'LAST'],
         [Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']];
    this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
    this.setColour(Blockly.Blocks.lists.HUE);
    var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
      var isStatement = (value == 'REMOVE');
      this.sourceBlock_.updateStatement_(isStatement);
    });
    this.appendValueInput('VALUE')
        .setCheck('Array')
        .appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);
    this.appendDummyInput()
        .appendField(modeMenu, 'MODE')
        .appendField('', 'SPACE');
    this.appendDummyInput('AT');
    if (Blockly.Msg.LISTS_GET_INDEX_TAIL) {
      this.appendDummyInput('TAIL')
          .appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL);
    }
    this.setInputsInline(true);
    this.setOutput(true);
    this.updateAt_(true);
    // Assign 'this' to a variable for use in the tooltip closure below.
    var thisBlock = this;
    this.setTooltip(function() {
      var combo = thisBlock.getFieldValue('MODE') + '_' +
          thisBlock.getFieldValue('WHERE');
      return Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_' + combo];
    });
  }
function() {
    var MODE =
        [[Blockly.Msg.LISTS_GET_INDEX_GET, 'GET'],
         [Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE, 'GET_REMOVE'],
         [Blockly.Msg.LISTS_GET_INDEX_REMOVE, 'REMOVE']];
    this.WHERE_OPTIONS =
        [[Blockly.Msg.LISTS_GET_INDEX_FROM_START, 'FROM_START'],
         [Blockly.Msg.LISTS_GET_INDEX_FROM_END, 'FROM_END'],
         [Blockly.Msg.LISTS_GET_INDEX_FIRST, 'FIRST'],
         [Blockly.Msg.LISTS_GET_INDEX_LAST, 'LAST'],
         [Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']];
    this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
    this.setColour(Blockly.Blocks.lists.HUE);
    var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
      var isStatement = (value == 'REMOVE');
      this.sourceBlock_.updateStatement_(isStatement);
    });
    this.appendValueInput('VALUE')
        .setCheck('Array')
        .appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);
    this.appendDummyInput()
        .appendField(modeMenu, 'MODE')
        .appendField('', 'SPACE');
    this.appendDummyInput('AT');
    if (Blockly.Msg.LISTS_GET_INDEX_TAIL) {
      this.appendDummyInput('TAIL')
          .appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL);
    }
    this.setInputsInline(true);
    this.setOutput(true);
    this.updateAt_(true);
    // Assign 'this' to a variable for use in the tooltip closure below.
    var thisBlock = this;
    this.setTooltip(function() {
      var combo = thisBlock.getFieldValue('MODE') + '_' +
          thisBlock.getFieldValue('WHERE');
      return Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_' + combo];
    });
  }
function ( ) { var MODE = [ [ Blockly . Msg . LISTS_GET_INDEX_GET , 'GET' ] , [ Blockly . Msg . LISTS_GET_INDEX_GET_REMOVE , 'GET_REMOVE' ] , [ Blockly . Msg . LISTS_GET_INDEX_REMOVE , 'REMOVE' ] ] ; this . WHERE_OPTIONS = [ [ Blockly . Msg . LISTS_GET_INDEX_FROM_START , 'FROM_START' ] , [ Blockly . Msg . LISTS_GET_INDEX_FROM_END , 'FROM_END' ] , [ Blockly . Msg . LISTS_GET_INDEX_FIRST , 'FIRST' ] , [ Blockly . Msg . LISTS_GET_INDEX_LAST , 'LAST' ] , [ Blockly . Msg . LISTS_GET_INDEX_RANDOM , 'RANDOM' ] ] ; this . setHelpUrl ( Blockly . Msg . LISTS_GET_INDEX_HELPURL ) ; this . setColour ( Blockly . Blocks . lists . HUE ) ; var modeMenu = new Blockly . FieldDropdown ( MODE , function ( value ) { var isStatement = ( value == 'REMOVE' ) ; this . sourceBlock_ . updateStatement_ ( isStatement ) ; } ) ; this . appendValueInput ( 'VALUE' ) . setCheck ( 'Array' ) . appendField ( Blockly . Msg . LISTS_GET_INDEX_INPUT_IN_LIST ) ; this . appendDummyInput ( ) . appendField ( modeMenu , 'MODE' ) . appendField ( '' , 'SPACE' ) ; this . appendDummyInput ( 'AT' ) ; if ( Blockly . Msg . LISTS_GET_INDEX_TAIL ) { this . appendDummyInput ( 'TAIL' ) . appendField ( Blockly . Msg . LISTS_GET_INDEX_TAIL ) ; } this . setInputsInline ( true ) ; this . setOutput ( true ) ; this . updateAt_ ( true ) ; // Assign 'this' to a variable for use in the tooltip closure below. var thisBlock = this ; this . setTooltip ( function ( ) { var combo = thisBlock . getFieldValue ( 'MODE' ) + '_' + thisBlock . getFieldValue ( 'WHERE' ) ; return Blockly . Msg [ 'LISTS_GET_INDEX_TOOLTIP_' + combo ] ; } ) ; }
Block for getting element at index.
@this Blockly.Block
Block for getting element at index .