I've just discovered "blockly" and it is exacly what i was looking for to take my webApp to the next level. The problem i have is that i don't realy understand how i can initiate python or js code variables.
Here is my block :
Blockly.Language.myapp_ifdo = {
helpUrl: '',
init: function() {
this.setColour(210);
this.appendDummyInput()
.appendTitle("if")
.appendTitle(new Blockly.FieldDropdown([["Temperature", "Temperature"], ["Humidity", "Humidity"]]), "SENSOR")
.appendTitle(" ")
.appendTitle(new Blockly.FieldDropdown([["=", "="], ["≠", "≠"], ["<", "<"], ["≤", "≤"], [">", ">"], ["≥", "≥"]]), "OPERATOR")
.appendTitle(" ")
.appendTitle(new Blockly.FieldTextInput("0"), "SENSORVALUE");
this.appendStatementInput("DO")
.appendTitle("do");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip('');
}
};
The rendering is :
Dropdown list content :
What i'm trying to do :
If "temperature" is selected then i want to initialize variable at the beginning of the generated code :
temperature = None
if temperature <= '30':
pass
Just the same if "humidity" is selected :
humidity = None
if humidity >= '60':
pass
In my "template.soy" file i have this :
<block type="myapp_ifdo"></block>
Hope i am clear enough... Thanks for your help !
Regards,