I know it's probably an extremely dumb question on my side. I am still quite inexperienced. But what I'm supposed to do to, for my project to work properly with the newest version?
Blockly.Blocks['colors_block'] = {
init: function () {
this.appendDummyInput()
.appendField("Цветове")
.appendField(new Blockly.FieldDropdown([
["ЗЕЛЕН", "colors/green"],
["ОРАНЖЕВ", "colors/orange"],
["ЧЕРВЕН", "colors/red"],
["СИН", "colors/blue"],
["РОЗОВ", "colors/pink"],
["БЯЛ", "colors/white"],
["ЖЪЛТ", "colors/yellow"]
]), "COLOR");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setTooltip("Изберете цвят");
this.setHelpUrl("");
}
};
Blockly.JavaScript['colors_block'] = function (block) {
return generateFetchCode(block, 'COLOR', 'nao2');
};
function generateFetchCode(block, fieldName, endpoint) {
var fieldValue = block.getFieldValue(fieldName);
var code = `fetch('http://localhost:3000/${endpoint}?IP=' + encodeURIComponent('${ipRobotNao}') + '&BN=' + encodeURIComponent('${fieldValue}')) .then(response => response.json())
.then(data => console.log('Response:', data))
.catch((error) => { console.error('Error:', error); });`;
return code;
}