Commit 80e1e9d1 authored by Beka Westberg's avatar Beka Westberg Committed by Evan W. Patton

Remove duplicate code in bump

parent 0d585f17
......@@ -35,11 +35,12 @@ Blockly.Blocks['text'] = {
typeblock: [{translatedName: Blockly.Msg.LANG_CATEGORY_TEXT}]
};
Blockly.Blocks.text.connectionCheck = function (myConnection, otherConnection) {
Blockly.Blocks.text.connectionCheck = function (myConnection, otherConnection, opt_value) {
var block = myConnection.sourceBlock_;
var otherTypeArray = otherConnection.check_;
var shouldIgnoreError = Blockly.mainWorkspace.isLoading;
var value = block.getFieldValue('TEXT');
var value = opt_value || block.getFieldValue('TEXT');
for (var i = 0; i < otherTypeArray.length; i++) {
if (otherTypeArray[i] == "String") {
return true;
......@@ -69,23 +70,12 @@ Blockly.Blocks.text.bumpBlockOnFinishEdit = function(finalValue) {
if (!connection) {
return;
}
if (!isNaN(parseFloat(finalValue))) {
// Block is a number, so no matter where it lives it is valid.
return;
}
var typeArray = connection.check_;
var length = typeArray.length;
for (var i = 0; i < length; i++) {
var type = typeArray[i];
if (type == "String" || type == "Key") {
// There is another valid type on the connection.
return;
}
}
// If the connections are no longer compatible.
if (!Blockly.Blocks.text.connectionCheck(
this.outputConnection, connection, finalValue)) {
connection.disconnect();
connection.sourceBlock_.bumpNeighbours_();
}
}
Blockly.Blocks['text_join'] = {
......
......@@ -39,15 +39,6 @@ Blockly.WarningHandler.WarningState = {
ERROR: 2
};
/**
* Regular expression for floating point numbers.
*
* @type {!RegExp}
* @const
*/
Blockly.WarningHandler.NUMBER_REGEX =
new RegExp("^[-+]?[0-9]*(\\.[0-9]+)?([eE][-+][0-9]+)?$")
/**
* The currently selected index into the array of block IDs with warnings. If nothing has been
* selected (i.e., if we are not stepping through warnings), this should be -1 so that the next
......
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