-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57889ee
commit d33567f
Showing
3 changed files
with
100 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly/converters/convertJSONString.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Blockly.Blocks['converttojson'] = { | ||
init: function () { | ||
this.appendDummyInput() | ||
.appendField("ConvertToJSON"); | ||
this.appendValueInput("ValueToConvert") | ||
.setCheck(null); | ||
this.setInputsInline(true); | ||
this.setOutput(true, null); | ||
this.setTooltip("Convert to JSON"); | ||
this.setHelpUrl(""); | ||
} | ||
}; | ||
Blockly.JavaScript['converttojson'] = function (block) { | ||
var value_ValueToConvert = Blockly.JavaScript.valueToCode(block, 'ValueToConvert', Blockly.JavaScript.ORDER_ATOMIC); | ||
//value_ValueToConvert = value_ValueToConvert.replace(/(\r\n|\n|\r)/gm, "") | ||
const code = 'JSON.parse(' + value_ValueToConvert + ')'; | ||
return [code, Blockly.JavaScript.ORDER_NONE]; | ||
|
||
}; | ||
|
||
Blockly.Blocks['converttostring'] = { | ||
init: function () { | ||
this.appendDummyInput() | ||
.appendField("ConvertToString"); | ||
this.appendValueInput("ValueToConvert") | ||
.setCheck(null); | ||
this.setInputsInline(true); | ||
this.setOutput(true, null); | ||
this.setTooltip("Convert to String"); | ||
this.setHelpUrl(""); | ||
} | ||
}; | ||
Blockly.JavaScript['converttostring'] = function (block) { | ||
var value_ValueToConvert = Blockly.JavaScript.valueToCode(block, 'ValueToConvert', Blockly.JavaScript.ORDER_ATOMIC); | ||
var code = 'JSON.stringify(' + value_ValueToConvert + ')'; | ||
return [code, Blockly.JavaScript.ORDER_NONE]; | ||
}; |
59 changes: 59 additions & 0 deletions
59
src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly/objects/propJS.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Blockly.Blocks['modifyproperty'] = { | ||
init: function () { | ||
this.appendDummyInput() | ||
.appendField("Modify "); | ||
this.appendValueInput("ObjectToChange") | ||
.setCheck(null) | ||
.setAlign(Blockly.ALIGN_CENTRE) | ||
.appendField(new Blockly.FieldLabelSerializable("object"), "objectName"); | ||
this.appendValueInput("PropertyName") | ||
.setCheck(null) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(new Blockly.FieldLabelSerializable(",property"), "prop"); | ||
this.appendValueInput("NewValue") | ||
.setCheck(null) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(new Blockly.FieldLabelSerializable("toValue"), "newValue"); | ||
this.setInputsInline(true); | ||
this.setPreviousStatement(true, null); | ||
this.setNextStatement(true, null); | ||
this.setTooltip(""); | ||
this.setHelpUrl(""); | ||
} | ||
}; | ||
Blockly.JavaScript['modifyproperty'] = function (block) { | ||
var value_objecttochange = Blockly.JavaScript.valueToCode(block, 'ObjectToChange', Blockly.JavaScript.ORDER_ATOMIC); | ||
var value_propertyname = Blockly.JavaScript.valueToCode(block, 'PropertyName', Blockly.JavaScript.ORDER_ATOMIC); | ||
var value_newvalue = Blockly.JavaScript.valueToCode(block, 'NewValue', Blockly.JavaScript.ORDER_ATOMIC); | ||
var code = value_objecttochange + "[" + value_propertyname + ']=' + value_newvalue + ";"; | ||
return code; | ||
}; | ||
Blockly.Blocks['getproperty'] = { | ||
init: function () { | ||
this.appendDummyInput() | ||
.appendField("Get from"); | ||
this.appendValueInput("ObjectToChange") | ||
.setCheck(null) | ||
.setAlign(Blockly.ALIGN_CENTRE) | ||
.appendField(new Blockly.FieldLabelSerializable("object"), "objectName"); | ||
this.appendValueInput("PropertyName") | ||
.setCheck(null) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(new Blockly.FieldLabelSerializable("property"), "prop"); | ||
this.setInputsInline(true); | ||
this.setOutput(true, null) | ||
//this.setTooltip(""); | ||
//this.setHelpUrl(""); | ||
} | ||
|
||
}; | ||
Blockly.JavaScript['getproperty'] = function (block) { | ||
var value_objecttochange = Blockly.JavaScript.valueToCode(block, 'ObjectToChange', Blockly.JavaScript.ORDER_ATOMIC); | ||
var value_propertyname = Blockly.JavaScript.valueToCode(block, 'PropertyName', Blockly.JavaScript.ORDER_ATOMIC); | ||
|
||
var code = value_objecttochange + "[" + value_propertyname + ']'; | ||
// TODO: Change ORDER_NONE to the correct strength. | ||
return [code, Blockly.JavaScript.ORDER_NONE]; | ||
}; | ||
|
||
|