Commit 61ae55dd authored by Susan Rati Lane's avatar Susan Rati Lane Committed by Evan W. Patton

Fix set HELPURLs correctly (#1367)

Set HELPURL correctly for several multi-operation math and logic blocks.

Added HELPURL definition for min and max.
parent 7e13229b
...@@ -225,11 +225,11 @@ Blockly.Blocks['logic_or'] = { ...@@ -225,11 +225,11 @@ Blockly.Blocks['logic_or'] = {
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
var op = thisBlock.getFieldValue('OP'); var op = thisBlock.getFieldValue('OP');
return Blockly.Blocks.logic_operation.TOOLTIPS[op]; return Blockly.Blocks.logic_operation.TOOLTIPS()[op];
}); });
}, },
helpUrl: function () { helpUrl: function () {
var op = this.getFieldValue('OP'); var op = this.getFieldValue('OP');
return Blockly.Blocks.logic_operation.HELPURLS[op]; return Blockly.Blocks.logic_operation.HELPURLS()[op];
} }
}; };
\ No newline at end of file
...@@ -374,7 +374,10 @@ Blockly.Blocks['math_on_list'] = { ...@@ -374,7 +374,10 @@ Blockly.Blocks['math_on_list'] = {
// Evaluate a list of numbers to return sum, average, min, max, etc. // Evaluate a list of numbers to return sum, average, min, max, etc.
// Some functions also work on text (min, max, mode, median). // Some functions also work on text (min, max, mode, median).
category: 'Math', category: 'Math',
helpUrl: '', helpUrl: function () {
var mode = this.getFieldValue('OP');
return Blockly.Blocks.math_on_list.HELPURLS()[mode];
},
init: function () { init: function () {
// Assign 'this' to a variable for use in the closures below. // Assign 'this' to a variable for use in the closures below.
var thisBlock = this; var thisBlock = this;
...@@ -453,6 +456,13 @@ Blockly.Blocks.math_on_list.TOOLTIPS = function () { ...@@ -453,6 +456,13 @@ Blockly.Blocks.math_on_list.TOOLTIPS = function () {
} }
}; };
Blockly.Blocks.math_on_list.HELPURLS = function () {
return {
MIN: Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MIN,
MAX: Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MAX
}
};
Blockly.Blocks['math_single'] = { Blockly.Blocks['math_single'] = {
// Advanced math operators with single operand. // Advanced math operators with single operand.
category: 'Math', category: 'Math',
...@@ -566,7 +576,7 @@ Blockly.Blocks['math_abs'] = { ...@@ -566,7 +576,7 @@ Blockly.Blocks['math_abs'] = {
category: 'Math', category: 'Math',
helpUrl: function () { helpUrl: function () {
var mode = this.getFieldValue('OP'); var mode = this.getFieldValue('OP');
return Blockly.Blocks.math_single.HELPURLS[mode]; return Blockly.Blocks.math_single.HELPURLS()[mode];
}, },
init: function () { init: function () {
this.setColour(Blockly.MATH_CATEGORY_HUE); this.setColour(Blockly.MATH_CATEGORY_HUE);
...@@ -579,7 +589,7 @@ Blockly.Blocks['math_abs'] = { ...@@ -579,7 +589,7 @@ Blockly.Blocks['math_abs'] = {
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
var mode = thisBlock.getFieldValue('OP'); var mode = thisBlock.getFieldValue('OP');
return Blockly.Blocks.math_single.TOOLTIPS[mode]; return Blockly.Blocks.math_single.TOOLTIPS()[mode];
}); });
} }
}; };
...@@ -589,7 +599,7 @@ Blockly.Blocks['math_neg'] = { ...@@ -589,7 +599,7 @@ Blockly.Blocks['math_neg'] = {
category: 'Math', category: 'Math',
helpUrl: function () { helpUrl: function () {
var mode = this.getFieldValue('OP'); var mode = this.getFieldValue('OP');
return Blockly.Blocks.math_single.HELPURLS[mode]; return Blockly.Blocks.math_single.HELPURLS()[mode];
}, },
init: function () { init: function () {
this.setColour(Blockly.MATH_CATEGORY_HUE); this.setColour(Blockly.MATH_CATEGORY_HUE);
...@@ -602,7 +612,7 @@ Blockly.Blocks['math_neg'] = { ...@@ -602,7 +612,7 @@ Blockly.Blocks['math_neg'] = {
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
var mode = thisBlock.getFieldValue('OP'); var mode = thisBlock.getFieldValue('OP');
return Blockly.Blocks.math_single.TOOLTIPS[mode]; return Blockly.Blocks.math_single.TOOLTIPS()[mode];
}); });
} }
}; };
...@@ -612,7 +622,7 @@ Blockly.Blocks['math_round'] = { ...@@ -612,7 +622,7 @@ Blockly.Blocks['math_round'] = {
category: 'Math', category: 'Math',
helpUrl: function () { helpUrl: function () {
var mode = this.getFieldValue('OP'); var mode = this.getFieldValue('OP');
return Blockly.Blocks.math_single.HELPURLS[mode]; return Blockly.Blocks.math_single.HELPURLS()[mode];
}, },
init: function () { init: function () {
this.setColour(Blockly.MATH_CATEGORY_HUE); this.setColour(Blockly.MATH_CATEGORY_HUE);
...@@ -625,7 +635,7 @@ Blockly.Blocks['math_round'] = { ...@@ -625,7 +635,7 @@ Blockly.Blocks['math_round'] = {
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
var mode = thisBlock.getFieldValue('OP'); var mode = thisBlock.getFieldValue('OP');
return Blockly.Blocks.math_single.TOOLTIPS[mode]; return Blockly.Blocks.math_single.TOOLTIPS()[mode];
}); });
} }
}; };
...@@ -635,7 +645,7 @@ Blockly.Blocks['math_ceiling'] = { ...@@ -635,7 +645,7 @@ Blockly.Blocks['math_ceiling'] = {
category: 'Math', category: 'Math',
helpUrl: function () { helpUrl: function () {
var mode = this.getFieldValue('OP'); var mode = this.getFieldValue('OP');
return Blockly.Blocks.math_single.HELPURLS[mode]; return Blockly.Blocks.math_single.HELPURLS()[mode];
}, },
init: function () { init: function () {
this.setColour(Blockly.MATH_CATEGORY_HUE); this.setColour(Blockly.MATH_CATEGORY_HUE);
...@@ -648,7 +658,7 @@ Blockly.Blocks['math_ceiling'] = { ...@@ -648,7 +658,7 @@ Blockly.Blocks['math_ceiling'] = {
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
var mode = thisBlock.getFieldValue('OP'); var mode = thisBlock.getFieldValue('OP');
return Blockly.Blocks.math_single.TOOLTIPS[mode]; return Blockly.Blocks.math_single.TOOLTIPS()[mode];
}); });
} }
}; };
...@@ -658,7 +668,7 @@ Blockly.Blocks['math_floor'] = { ...@@ -658,7 +668,7 @@ Blockly.Blocks['math_floor'] = {
category: 'Math', category: 'Math',
helpUrl: function () { helpUrl: function () {
var mode = this.getFieldValue('OP'); var mode = this.getFieldValue('OP');
return Blockly.Blocks.math_single.HELPURLS[mode]; return Blockly.Blocks.math_single.HELPURLS()[mode];
}, },
init: function () { init: function () {
this.setColour(Blockly.MATH_CATEGORY_HUE); this.setColour(Blockly.MATH_CATEGORY_HUE);
...@@ -671,7 +681,7 @@ Blockly.Blocks['math_floor'] = { ...@@ -671,7 +681,7 @@ Blockly.Blocks['math_floor'] = {
var thisBlock = this; var thisBlock = this;
this.setTooltip(function () { this.setTooltip(function () {
var mode = thisBlock.getFieldValue('OP'); var mode = thisBlock.getFieldValue('OP');
return Blockly.Blocks.math_single.TOOLTIPS[mode]; return Blockly.Blocks.math_single.TOOLTIPS()[mode];
}); });
} }
}; };
......
...@@ -466,6 +466,8 @@ Blockly.Msg.en.switch_language_to_english = { ...@@ -466,6 +466,8 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max'; Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX = 'max';
Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Return the smallest of its arguments..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Return the smallest of its arguments..';
Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Return the largest of its arguments..'; Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Return the largest of its arguments..';
Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MIN = 'http://appinventor.mit.edu/explore/ai2/support/blocks/math#min';
Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MAX = 'http://appinventor.mit.edu/explore/ai2/support/blocks/math#max';
Blockly.Msg.LANG_MATH_DIVIDE = '\u00F7'; Blockly.Msg.LANG_MATH_DIVIDE = '\u00F7';
Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'modulo of'; Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO = 'modulo of';
...@@ -534,19 +536,19 @@ Blockly.Msg.en.switch_language_to_english = { ...@@ -534,19 +536,19 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'convert number'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT = 'convert number';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'base 10 to hex'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX = 'base 10 to hex';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_DEC_TO_HEX = ''; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_DEC_TO_HEX = 'http://appinventor.mit.edu/explore/ai2/support/blocks/math#convertnumber';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Takes a positive integer in base 10 and returns the string that represents the number in hexadecimal'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX = 'Takes a positive integer in base 10 and returns the string that represents the number in hexadecimal';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex to base 10'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC = 'hex to base 10';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_HEX_TO_DEC = ''; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_HEX_TO_DEC = 'http://appinventor.mit.edu/explore/ai2/support/blocks/math#convertnumber';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Takes a string that represents a number in hexadecimal and returns the string that represents the number in base 10'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC = 'Takes a string that represents a number in hexadecimal and returns the string that represents the number in base 10';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'base 10 to binary'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN = 'base 10 to binary';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_DEC_TO_BIN = ''; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_DEC_TO_BIN = 'http://appinventor.mit.edu/explore/ai2/support/blocks/math#convertnumber';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Takes a positive integer in base 10 and returns the string that represents the number in binary'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN = 'Takes a positive integer in base 10 and returns the string that represents the number in binary';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binary to base 10'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC = 'binary to base 10';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_BIN_TO_DEC = ''; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_BIN_TO_DEC = 'http://appinventor.mit.edu/explore/ai2/support/blocks/math#convertnumber';
Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Takes a string that represents a number in binary and returns the string that represents the number in base 10'; Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC = 'Takes a string that represents a number in binary and returns the string that represents the number in base 10';
// Text Blocks. // Text Blocks.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment