From 72761f05d5342819ac07ffecb8e67b70449e3efb Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Wed, 25 Oct 2023 18:14:45 +0200 Subject: [PATCH] blockly plugin: fix deprecated block definition --- blockly/webif/static/shblocks/sh_items.js | 12 ++++++------ blockly/webif/static/shblocks/sh_logic.js | 11 +++++------ blockly/webif/static/shblocks/sh_logics.js | 12 ++++++------ blockly/webif/static/shblocks/sh_notify.js | 5 ++--- blockly/webif/static/shblocks/sh_time.js | 7 +++---- blockly/webif/static/shblocks/sh_tools.js | 9 ++++----- 6 files changed, 26 insertions(+), 30 deletions(-) diff --git a/blockly/webif/static/shblocks/sh_items.js b/blockly/webif/static/shblocks/sh_items.js index 47cfae6c7..621c8546c 100755 --- a/blockly/webif/static/shblocks/sh_items.js +++ b/blockly/webif/static/shblocks/sh_items.js @@ -46,7 +46,7 @@ Blockly.Blocks['sh_item_obj'] = { } }; -Blockly.Python['sh_item_obj'] = function(block) { +python.pythonGenerator.forBlock['sh_item_obj'] = function(block) { var iName = block.getFieldValue('N'); var iPath = block.getFieldValue('P'); @@ -84,7 +84,7 @@ Blockly.Python['sh_item_obj'] = function(block) { }, }; -Blockly.Python['sh_item'] = function(block) { +python.pythonGenerator.forBlock['sh_item'] = function(block) { // Variable getter. var code = 'sh.' + block.getFieldValue('ITEM'); return [code, Blockly.Python.ORDER_ATOMIC]; @@ -108,7 +108,7 @@ Blockly.Blocks['sh_item_get'] = { } }; -Blockly.Python['sh_item_get'] = function(block) { +python.pythonGenerator.forBlock['sh_item_get'] = function(block) { var itemobj = Blockly.Python.valueToCode(block, 'ITEMOBJECT', Blockly.Python.ORDER_ATOMIC) || 'item'; var code = itemobj + '.property.value'; return [code, Blockly.Python.ORDER_NONE]; @@ -135,7 +135,7 @@ Blockly.Blocks['sh_item_set'] = { } }; -Blockly.Python['sh_item_set'] = function(block) { +python.pythonGenerator.forBlock['sh_item_set'] = function(block) { var itemobject = Blockly.Python.valueToCode(block, 'ITEMOJECT', Blockly.Python.ORDER_ATOMIC) || 'item'; var value = Blockly.Python.valueToCode(block, 'VALUE', Blockly.Python.ORDER_ATOMIC) || '0'; // TODO: Assemble Python into code variable. @@ -161,7 +161,7 @@ Blockly.Blocks['sh_item_hasattr'] = { } }; -Blockly.Python['sh_item_hasattr'] = function(block) { +python.pythonGenerator.forBlock['sh_item_hasattr'] = function(block) { var value_item = Blockly.Python.valueToCode(block, 'ITEM', Blockly.Python.ORDER_ATOMIC); var text_attr = block.getFieldValue('ATTR'); // TODO: Assemble Python into code variable. @@ -197,7 +197,7 @@ Blockly.Blocks['sh_item_attr'] = { } }; -Blockly.Python['sh_item_attr'] = function(block) { +python.pythonGenerator.forBlock['sh_item_attr'] = function(block) { var dropdown_attr = block.getFieldValue('ATTR'); var value_item = Blockly.Python.valueToCode(block, 'ITEM', Blockly.Python.ORDER_ATOMIC); // TODO: Assemble Python into code variable. diff --git a/blockly/webif/static/shblocks/sh_logic.js b/blockly/webif/static/shblocks/sh_logic.js index 28f7b64eb..a069b763f 100755 --- a/blockly/webif/static/shblocks/sh_logic.js +++ b/blockly/webif/static/shblocks/sh_logic.js @@ -23,7 +23,7 @@ Blockly.Blocks['shlogic_by'] = { this.setTooltip(''); } }; -Blockly.Python['shlogic_by'] = function(block) { +python.pythonGenerator.forBlock['shlogic_by'] = function(block) { var code = "trigger['by']"; // TODO: Change ORDER_NONE to the correct strength. return [code, Blockly.Python.ORDER_NONE]; @@ -43,7 +43,7 @@ Blockly.Blocks['shlogic_value'] = { this.setTooltip(''); } }; -Blockly.Python['shlogic_value'] = function(block) { +python.pythonGenerator.forBlock['shlogic_value'] = function(block) { var code = "trigger['value']"; // TODO: Change ORDER_NONE to the correct strength. return [code, Blockly.Python.ORDER_NONE]; @@ -63,7 +63,7 @@ Blockly.Blocks['shlogic_source'] = { this.setTooltip(''); } }; -Blockly.Python['shlogic_source'] = function(block) { +python.pythonGenerator.forBlock['shlogic_source'] = function(block) { var code = "trigger['source']"; // TODO: Change ORDER_NONE to the correct strength. return [code, Blockly.Python.ORDER_NONE]; @@ -83,7 +83,7 @@ Blockly.Blocks['shlogic_dest'] = { this.setTooltip(''); } }; -Blockly.Python['shlogic_dest'] = function(block) { +python.pythonGenerator.forBlock['shlogic_dest'] = function(block) { var code = "trigger['dest']"; // TODO: Change ORDER_NONE to the correct strength. return [code, Blockly.Python.ORDER_NONE]; @@ -107,11 +107,10 @@ Blockly.Blocks['shlogic_trigger'] = { this.setTooltip(''); } }; -Blockly.Python['shlogic_trigger'] = function(block) { +python.pythonGenerator.forBlock['shlogic_trigger'] = function(block) { var value_datetime = Blockly.Python.valueToCode(block, 'DATETIME', Blockly.Python.ORDER_ATOMIC); // TODO: Assemble Python into code variable. var code = '...'; return code; }; */ - diff --git a/blockly/webif/static/shblocks/sh_logics.js b/blockly/webif/static/shblocks/sh_logics.js index ae5bbba25..7d3d4cc81 100755 --- a/blockly/webif/static/shblocks/sh_logics.js +++ b/blockly/webif/static/shblocks/sh_logics.js @@ -176,7 +176,7 @@ function NextLevel(trigger_block, logicname, ignore_crontab, ignore_watchitem) }; }; -Blockly.Python['sh_logic_main'] = function(block) +python.pythonGenerator.forBlock['sh_logic_main'] = function(block) { this.data = 'sh_logic_main' var trigger_block = block.getChildren(); @@ -323,7 +323,7 @@ Blockly.Blocks['sh_trigger_item'] = { } }; -Blockly.Python['sh_trigger_item'] = function(block) +python.pythonGenerator.forBlock['sh_trigger_item'] = function(block) { var code = ''; return code; @@ -360,7 +360,7 @@ Blockly.Blocks['sh_trigger_cycle'] = { } }; -Blockly.Python['sh_trigger_cycle'] = function(block) { +python.pythonGenerator.forBlock['sh_trigger_cycle'] = function(block) { var code = '' return code; }; @@ -396,7 +396,7 @@ Blockly.Blocks['sh_trigger_sun'] = { } }; -Blockly.Python['sh_trigger_sun'] = function(block) +python.pythonGenerator.forBlock['sh_trigger_sun'] = function(block) { var code = ''; return code; @@ -437,7 +437,7 @@ Blockly.Blocks['sh_trigger_daily'] = { } }; -Blockly.Python['sh_trigger_daily'] = function(block) +python.pythonGenerator.forBlock['sh_trigger_daily'] = function(block) { var code = ''; return code; @@ -469,7 +469,7 @@ Blockly.Blocks['sh_trigger_init'] = { } }; -Blockly.Python['sh_trigger_init'] = function(block) +python.pythonGenerator.forBlock['sh_trigger_init'] = function(block) { var code = ''; return code; diff --git a/blockly/webif/static/shblocks/sh_notify.js b/blockly/webif/static/shblocks/sh_notify.js index b62facb43..47c27f782 100755 --- a/blockly/webif/static/shblocks/sh_notify.js +++ b/blockly/webif/static/shblocks/sh_notify.js @@ -30,7 +30,7 @@ Blockly.Blocks['shnotify_email'] = { this.setTooltip(''); } }; -Blockly.Python['shnotify_email'] = function(block) { +python.pythonGenerator.forBlock['shnotify_email'] = function(block) { var to = block.getFieldValue('TO'); var subject = block.getFieldValue('SUBJECT'); var text = Blockly.Python.valueToCode(block, 'TO', Blockly.Python.ORDER_ATOMIC); @@ -71,7 +71,7 @@ Blockly.Blocks['shnotify_nma'] = { this.setTooltip(''); } }; -Blockly.Python['shnotify_nma'] = function(block) { +python.pythonGenerator.forBlock['shnotify_nma'] = function(block) { var text_subject = block.getFieldValue('SUBJECT'); var value_text = Blockly.Python.valueToCode(block, 'TEXT', Blockly.Python.ORDER_ATOMIC); // TODO: Assemble Python into code variable. @@ -92,4 +92,3 @@ Blockly.Blocks['shnotify_pushbullit'] = { this.appendDummyInput().appendField('Sende Nachricht mit Pushbullit:'); }, }; - diff --git a/blockly/webif/static/shblocks/sh_time.js b/blockly/webif/static/shblocks/sh_time.js index be835843a..1c11bd54c 100755 --- a/blockly/webif/static/shblocks/sh_time.js +++ b/blockly/webif/static/shblocks/sh_time.js @@ -25,7 +25,7 @@ Blockly.Blocks['shtime_now'] = { this.setTooltip(''); } }; -Blockly.Python['shtime_now'] = function(block) { +python.pythonGenerator.forBlock['shtime_now'] = function(block) { // var code = 'sh.now()'; var code = 'sh.shtime.now()'; // TODO: Change ORDER_NONE to the correct strength. @@ -61,7 +61,7 @@ Blockly.Blocks['shtime_time'] = { } }; -Blockly.Python['shtime_time'] = function(block) { +python.pythonGenerator.forBlock['shtime_time'] = function(block) { var text_time = block.getFieldValue('TIME'); var code = 'datetime.strptime("'+text_time+'", "%H:%M")'; // TODO: Change ORDER_NONE to the correct strength. @@ -89,7 +89,7 @@ Blockly.Blocks['shtime_sunpos'] = { this.setTooltip(''); } }; -Blockly.Python['shtime_sunpos'] = function(block) { +python.pythonGenerator.forBlock['shtime_sunpos'] = function(block) { var delta = Blockly.Python.valueToCode(block, 'DELTA', Blockly.Python.ORDER_ATOMIC); var aa = block.getFieldValue('AA'); var pm = block.getFieldValue('PM'); @@ -120,4 +120,3 @@ Blockly.Blocks['shtime_auto'] = { this.appendDummyInput().appendField('Autotimer:'); }, }; - diff --git a/blockly/webif/static/shblocks/sh_tools.js b/blockly/webif/static/shblocks/sh_tools.js index aa6773a3f..85eb83571 100755 --- a/blockly/webif/static/shblocks/sh_tools.js +++ b/blockly/webif/static/shblocks/sh_tools.js @@ -28,7 +28,7 @@ Blockly.Blocks['shtools_logger'] = { this.setTooltip(''); } }; -Blockly.Python['shtools_logger'] = function(block) { +python.pythonGenerator.forBlock['shtools_logger'] = function(block) { var loglevel = block.getFieldValue('LOGLEVEL').toLowerCase(); var logtext = Blockly.Python.valueToCode(block, 'LOGTEXT', Blockly.Python.ORDER_NONE) || '\'\''; var code = "logger." + loglevel + "(" + logtext + ")\n"; @@ -54,7 +54,7 @@ Blockly.Blocks['shtools_dewpoint'] = { this.setTooltip(''); } }; -Blockly.Python['shtools_dewpoint'] = function(block) { +python.pythonGenerator.forBlock['shtools_dewpoint'] = function(block) { var value_hum = Blockly.Python.valueToCode(block, 'HUM', Blockly.Python.ORDER_ATOMIC); var value_temp = Blockly.Python.valueToCode(block, 'TEMP', Blockly.Python.ORDER_ATOMIC); var code = 'sh.tools.dewpoint(' + value_temp + ', ' + value_hum + ')'; @@ -78,7 +78,7 @@ Blockly.Blocks['shtools_fetchurl'] = { this.setTooltip(''); } }; -Blockly.Python['shtools_fetchurl'] = function(block) { +python.pythonGenerator.forBlock['shtools_fetchurl'] = function(block) { var text_url = block.getFieldValue('URL'); var code = 'sh.tools.fetch_url("' + text_url + '")' ; // TODO: Change ORDER_NONE to the correct strength. @@ -104,7 +104,7 @@ Blockly.Blocks['shtools_fetchurl2'] = { this.setTooltip(''); } }; -Blockly.Python['shtools_fetchurl2'] = function(block) { +python.pythonGenerator.forBlock['shtools_fetchurl2'] = function(block) { var text_url = block.getFieldValue('URL'); var text_user = block.getFieldValue('USER'); var text_password = block.getFieldValue('PASSWORD'); @@ -112,4 +112,3 @@ Blockly.Python['shtools_fetchurl2'] = function(block) { // TODO: Change ORDER_NONE to the correct strength. return [code, Blockly.Python.ORDER_NONE]; }; -