components/blockly-src/blocks/math.js
function() {
    this.jsonInit({
      "message0": "%1 %2 %3",
      "args0": [
        {
          "type": "input_value",
          "name": "A",
          "check": "Number"
        },
        {
          "type": "field_dropdown",
          "name": "OP",
          "options":
            [[Blockly.Msg.MATH_ADDITION_SYMBOL, 'ADD'],
             [Blockly.Msg.MATH_SUBTRACTION_SYMBOL, 'MINUS'],
             [Blockly.Msg.MATH_MULTIPLICATION_SYMBOL, 'MULTIPLY'],
             [Blockly.Msg.MATH_DIVISION_SYMBOL, 'DIVIDE'],
             [Blockly.Msg.MATH_POWER_SYMBOL, 'POWER']]
        },
        {
          "type": "input_value",
          "name": "B",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "output": "Number",
      "colour": Blockly.Blocks.math.HUE,
      "helpUrl": Blockly.Msg.MATH_ARITHMETIC_HELPURL
    });
    // Assign 'this' to a variable for use in the tooltip closure below.
    var thisBlock = this;
    this.setTooltip(function() {
      var mode = thisBlock.getFieldValue('OP');
      var TOOLTIPS = {
        'ADD': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,
        'MINUS': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,
        'MULTIPLY': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,
        'DIVIDE': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,
        'POWER': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER
      };
      return TOOLTIPS[mode];
    });
  }
function() {
    this.jsonInit({
      "message0": "%1 %2 %3",
      "args0": [
        {
          "type": "input_value",
          "name": "A",
          "check": "Number"
        },
        {
          "type": "field_dropdown",
          "name": "OP",
          "options":
            [[Blockly.Msg.MATH_ADDITION_SYMBOL, 'ADD'],
             [Blockly.Msg.MATH_SUBTRACTION_SYMBOL, 'MINUS'],
             [Blockly.Msg.MATH_MULTIPLICATION_SYMBOL, 'MULTIPLY'],
             [Blockly.Msg.MATH_DIVISION_SYMBOL, 'DIVIDE'],
             [Blockly.Msg.MATH_POWER_SYMBOL, 'POWER']]
        },
        {
          "type": "input_value",
          "name": "B",
          "check": "Number"
        }
      ],
      "inputsInline": true,
      "output": "Number",
      "colour": Blockly.Blocks.math.HUE,
      "helpUrl": Blockly.Msg.MATH_ARITHMETIC_HELPURL
    });
    // Assign 'this' to a variable for use in the tooltip closure below.
    var thisBlock = this;
    this.setTooltip(function() {
      var mode = thisBlock.getFieldValue('OP');
      var TOOLTIPS = {
        'ADD': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,
        'MINUS': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,
        'MULTIPLY': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,
        'DIVIDE': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,
        'POWER': Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER
      };
      return TOOLTIPS[mode];
    });
  }
function ( ) { this . jsonInit ( { "message0" : "%1 %2 %3" , "args0" : [ { "type" : "input_value" , "name" : "A" , "check" : "Number" } , { "type" : "field_dropdown" , "name" : "OP" , "options" : [ [ Blockly . Msg . MATH_ADDITION_SYMBOL , 'ADD' ] , [ Blockly . Msg . MATH_SUBTRACTION_SYMBOL , 'MINUS' ] , [ Blockly . Msg . MATH_MULTIPLICATION_SYMBOL , 'MULTIPLY' ] , [ Blockly . Msg . MATH_DIVISION_SYMBOL , 'DIVIDE' ] , [ Blockly . Msg . MATH_POWER_SYMBOL , 'POWER' ] ] } , { "type" : "input_value" , "name" : "B" , "check" : "Number" } ] , "inputsInline" : true , "output" : "Number" , "colour" : Blockly . Blocks . math . HUE , "helpUrl" : Blockly . Msg . MATH_ARITHMETIC_HELPURL } ) ; // Assign 'this' to a variable for use in the tooltip closure below. var thisBlock = this ; this . setTooltip ( function ( ) { var mode = thisBlock . getFieldValue ( 'OP' ) ; var TOOLTIPS = { 'ADD' : Blockly . Msg . MATH_ARITHMETIC_TOOLTIP_ADD , 'MINUS' : Blockly . Msg . MATH_ARITHMETIC_TOOLTIP_MINUS , 'MULTIPLY' : Blockly . Msg . MATH_ARITHMETIC_TOOLTIP_MULTIPLY , 'DIVIDE' : Blockly . Msg . MATH_ARITHMETIC_TOOLTIP_DIVIDE , 'POWER' : Blockly . Msg . MATH_ARITHMETIC_TOOLTIP_POWER } ; return TOOLTIPS [ mode ] ; } ) ; }
Block for basic arithmetic operator.
@this Blockly.Block
Block for basic arithmetic operator .