mosaicode/extensions/javascript/blocks/webaudio/Form/Text.json

54 lines
1.7 KiB
JSON

{
"source": "JSON",
"data": "BLOCK",
"version": "0.0.1",
"type": "javascript.form.text",
"language": "javascript",
"extension": "webaudio",
"help": "Text",
"label": "Text",
"color": "#F92317",
"group": "Form",
"codes": [
{
"name": "declaration",
"code": "\n// block_$id$ = $label$\nvar $port[value]$ = [];\n\nvar $port[invalue]$ = function(value){\n document.getElementById(\"block_$id$\").value = value;\n return true;\n };\n\n"
},
{
"name": "execution",
"code": "\nfunction enter_value$id$(e){\n e = e || window.event;\n if (e.keyCode != 13) //Ignore if it is not enter\n return;\n value = document.getElementById(\"block_$id$\").value;\n for (var i = 0; i < $port[value]$.length ; i++){\n $port[value]$[i](value);\n }\n};\n"
},
{
"name": "html",
"code": "\n$prop[label]$ <input type=\"text\" value=\"$prop[value]$\" onkeypress=\"enter_value$id$(event);\"\nid=\"block_$id$\"><br>\n"
}
],
"properties": [
{
"name": "value",
"label": "Value",
"type": "String",
"value": ""
},
{
"name": "label",
"label": "Label",
"type": "String",
"value": "Label"
}
],
"ports": [
{
"conn_type": "output",
"name": "value",
"label": "Value",
"type": "javascript.string"
},
{
"conn_type": "input",
"name": "invalue",
"label": "Value",
"type": "javascript.string"
}
]
}