fix warnings

This commit is contained in:
Mario 2020-09-16 15:50:55 +02:00
parent bbd14c58b5
commit 6a4de9c7a2
4 changed files with 12 additions and 11 deletions

View File

@ -331,7 +331,7 @@ Blockly.Blocks['switch_case'] = {
}
break;
default:
throw 'Unknown block type.';
throw new Error('Unknown block type.');
}
caseBlock = caseBlock.nextConnection &&
caseBlock.nextConnection.targetBlock();
@ -355,7 +355,7 @@ Blockly.Blocks['switch_case'] = {
caseBlock.satementConnection_ = defaultInput && defaultInput.connection.targetConnection;
break;
default:
throw 'Unknown block type';
throw new Error('Unknown block type');
}
caseBlock = caseBlock.nextConnection &&
caseBlock.nextConnection.targetBlock();

View File

@ -64,7 +64,7 @@ Blockly.Blocks['sensebox_sd_write_file'] = {
// Is the block nested in a loop?
var block = this;
do {
if (this.LOOP_TYPES.indexOf(block.type) != -1) {
if (this.LOOP_TYPES.indexOf(block.type) !== -1) {
legal = true;
break;
}

View File

@ -139,13 +139,13 @@ Blockly.Arduino['switch_case'] = function (block) {
var default_code = '';
var DO = Blockly.Arduino.statementToCode(block, ('CASE' + n));
for (n = 0; n <= block.caseCount_; n++) {
var DO = Blockly.Arduino.statementToCode(block, ('CASE' + n));
var branch = Blockly.Arduino.valueToCode(block, ('CASECONDITION' + n), Blockly.Arduino.ORDER_NONE) || '0';
DO = Blockly.Arduino.statementToCode(block, ('CASE' + n));
branch = Blockly.Arduino.valueToCode(block, ('CASECONDITION' + n), Blockly.Arduino.ORDER_NONE) || '0';
cases += 'case ' + branch + ':\n';
cases += DO + '\nbreak;\n';
}
if (block.defaultCount_) {
var branch = Blockly.Arduino.statementToCode(block, 'ONDEFAULT');
branch = Blockly.Arduino.statementToCode(block, 'ONDEFAULT');
default_code = 'default: \n' + branch + '\n break;\n';
}
var code = 'switch (' + argument + ') {\n' + cases + default_code + '}';

View File

@ -32,22 +32,23 @@ Blockly.Arduino.sensebox_sd_open_file = function (block) {
};
Blockly.Arduino.sensebox_sd_write_file = function (block) {
var res = filename.slice(0, 4);
if (this.parentBlock_ != null) {
var filename = this.getSurroundParent().getFieldValue('Filename');
}
var res = filename.slice(0, 4);
var text = Blockly.Arduino.valueToCode(this, 'DATA', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
var linebreak = this.getFieldValue('linebreak');
if (linebreak == "TRUE") {
if (linebreak === "TRUE") {
linebreak = "ln";
} else {
linebreak = "";
}
if (text == "gps.getLongitude()" || text == "gps.getLatitude()") {
var code = 'dataFile' + res + '.print' + linebreak + '(' + text + ',5);\n'
var code = '';
if (text === "gps.getLongitude()" || text === "gps.getLatitude()") {
code = 'dataFile' + res + '.print' + linebreak + '(' + text + ',5);\n'
}
else {
var code = 'dataFile' + res + '.print' + linebreak + '(' + text + ');\n'
code = 'dataFile' + res + '.print' + linebreak + '(' + text + ');\n'
}
return code;
};