Skip to content

Commit

Permalink
chore: release v5.8.9
Browse files Browse the repository at this point in the history
* (klein0r) Added variable timeout block
* (klein0r) Added `getInterval` and `getTimeout` blocks
* (klein0r) Added `sendTo` for scripts and message trigger blocks
  • Loading branch information
GermanBluefox committed Jul 14, 2022
1 parent e2c439e commit fad1eb4
Show file tree
Hide file tree
Showing 55 changed files with 1,435 additions and 1,151 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG_OLD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
The newest change log is in README.md
## 5.8.2 (2022-06-22)
* (bluefox) Updated some packages
* (bluefox) Made it work with ioBroker cloud

## 5.8.1 (2022-06-09)
* (bluefox) Allowed to use javascript behind reverse proxy
* (bluefox) If adapter parameter set to null in `writeFile/readFile`, it will be used `0_userdata.0`
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ And then call `npm run build`.
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
### 5.8.9 (2022-07-14)
* (klein0r) Added variable timeout block
* (klein0r) Added `getInterval` and `getTimeout` blocks
* (klein0r) Added `sendTo` for scripts and message trigger blocks
Expand All @@ -71,10 +71,6 @@ And then call `npm run build`.
### 5.8.3 (2022-06-27)
* (bluefox) Updated the object select dialog

### 5.8.2 (2022-06-22)
* (bluefox) Updated some packages
* (bluefox) Made it work with ioBroker cloud

## License
The MIT License (MIT)

Expand Down
50 changes: 25 additions & 25 deletions admin/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"files": {
"main.js": "/static/js/main.b089db0d.js",
"main.js": "/static/js/main.37bd30e2.js",
"static/css/62.6133d7c1.chunk.css": "/static/css/62.6133d7c1.chunk.css",
"static/js/62.f1e51a0b.chunk.js": "/static/js/62.f1e51a0b.chunk.js",
"static/js/62.8a121c34.chunk.js": "/static/js/62.8a121c34.chunk.js",
"static/js/90.728d6560.chunk.js": "/static/js/90.728d6560.chunk.js",
"static/js/969.769d4d61.chunk.js": "/static/js/969.769d4d61.chunk.js",
"static/js/821.362a16e9.chunk.js": "/static/js/821.362a16e9.chunk.js",
"static/js/13.6f214f89.chunk.js": "/static/js/13.6f214f89.chunk.js",
"static/js/652.30453175.chunk.js": "/static/js/652.30453175.chunk.js",
"static/js/526.b7e29abd.chunk.js": "/static/js/526.b7e29abd.chunk.js",
"static/js/961.21586481.chunk.js": "/static/js/961.21586481.chunk.js",
"static/js/869.9d08162f.chunk.js": "/static/js/869.9d08162f.chunk.js",
"static/js/200.c6266fbe.chunk.js": "/static/js/200.c6266fbe.chunk.js",
"static/js/449.fc8fc64c.chunk.js": "/static/js/449.fc8fc64c.chunk.js",
"static/js/197.4976ce9b.chunk.js": "/static/js/197.4976ce9b.chunk.js",
"static/js/815.ab923bde.chunk.js": "/static/js/815.ab923bde.chunk.js",
"static/js/114.45340edf.chunk.js": "/static/js/114.45340edf.chunk.js",
"static/js/909.aef20231.chunk.js": "/static/js/909.aef20231.chunk.js",
"static/js/230.9729f0f5.chunk.js": "/static/js/230.9729f0f5.chunk.js",
"static/js/624.953d447c.chunk.js": "/static/js/624.953d447c.chunk.js",
"static/js/270.2f146e4b.chunk.js": "/static/js/270.2f146e4b.chunk.js",
"static/js/178.f52a4814.chunk.js": "/static/js/178.f52a4814.chunk.js",
"static/js/691.8c6be625.chunk.js": "/static/js/691.8c6be625.chunk.js",
"static/js/391.0d90eb91.chunk.js": "/static/js/391.0d90eb91.chunk.js",
"static/js/731.130fc30d.chunk.js": "/static/js/731.130fc30d.chunk.js",
"static/js/230.f161f687.chunk.js": "/static/js/230.f161f687.chunk.js",
"static/js/624.dd1ef01f.chunk.js": "/static/js/624.dd1ef01f.chunk.js",
"static/js/59.32b76b6b.chunk.js": "/static/js/59.32b76b6b.chunk.js",
"static/js/178.bc1a8c55.chunk.js": "/static/js/178.bc1a8c55.chunk.js",
"static/js/779.9d782bfe.chunk.js": "/static/js/779.9d782bfe.chunk.js",
"static/media/back.jpg": "/static/media/back.bda2bbe51be338a0f657.jpg",
"static/media/hysteresis.png": "/static/media/hysteresis.04ebd02c6062432f891d.png",
"static/media/Ground Floor.svg": "/static/media/Ground Floor.2b7c5c91db7f070935a2.svg",
Expand Down Expand Up @@ -141,27 +141,27 @@
"static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
"static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
"static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
"main.b089db0d.js.map": "/static/js/main.b089db0d.js.map",
"main.37bd30e2.js.map": "/static/js/main.37bd30e2.js.map",
"62.6133d7c1.chunk.css.map": "/static/css/62.6133d7c1.chunk.css.map",
"62.f1e51a0b.chunk.js.map": "/static/js/62.f1e51a0b.chunk.js.map",
"62.8a121c34.chunk.js.map": "/static/js/62.8a121c34.chunk.js.map",
"90.728d6560.chunk.js.map": "/static/js/90.728d6560.chunk.js.map",
"969.769d4d61.chunk.js.map": "/static/js/969.769d4d61.chunk.js.map",
"821.362a16e9.chunk.js.map": "/static/js/821.362a16e9.chunk.js.map",
"13.6f214f89.chunk.js.map": "/static/js/13.6f214f89.chunk.js.map",
"652.30453175.chunk.js.map": "/static/js/652.30453175.chunk.js.map",
"526.b7e29abd.chunk.js.map": "/static/js/526.b7e29abd.chunk.js.map",
"961.21586481.chunk.js.map": "/static/js/961.21586481.chunk.js.map",
"869.9d08162f.chunk.js.map": "/static/js/869.9d08162f.chunk.js.map",
"200.c6266fbe.chunk.js.map": "/static/js/200.c6266fbe.chunk.js.map",
"449.fc8fc64c.chunk.js.map": "/static/js/449.fc8fc64c.chunk.js.map",
"197.4976ce9b.chunk.js.map": "/static/js/197.4976ce9b.chunk.js.map",
"815.ab923bde.chunk.js.map": "/static/js/815.ab923bde.chunk.js.map",
"114.45340edf.chunk.js.map": "/static/js/114.45340edf.chunk.js.map",
"909.aef20231.chunk.js.map": "/static/js/909.aef20231.chunk.js.map",
"230.9729f0f5.chunk.js.map": "/static/js/230.9729f0f5.chunk.js.map",
"624.953d447c.chunk.js.map": "/static/js/624.953d447c.chunk.js.map",
"270.2f146e4b.chunk.js.map": "/static/js/270.2f146e4b.chunk.js.map",
"178.f52a4814.chunk.js.map": "/static/js/178.f52a4814.chunk.js.map",
"691.8c6be625.chunk.js.map": "/static/js/691.8c6be625.chunk.js.map"
"391.0d90eb91.chunk.js.map": "/static/js/391.0d90eb91.chunk.js.map",
"731.130fc30d.chunk.js.map": "/static/js/731.130fc30d.chunk.js.map",
"230.f161f687.chunk.js.map": "/static/js/230.f161f687.chunk.js.map",
"624.dd1ef01f.chunk.js.map": "/static/js/624.dd1ef01f.chunk.js.map",
"59.32b76b6b.chunk.js.map": "/static/js/59.32b76b6b.chunk.js.map",
"178.bc1a8c55.chunk.js.map": "/static/js/178.bc1a8c55.chunk.js.map",
"779.9d782bfe.chunk.js.map": "/static/js/779.9d782bfe.chunk.js.map"
},
"entrypoints": [
"static/js/main.b089db0d.js"
"static/js/main.37bd30e2.js"
]
}
90 changes: 90 additions & 0 deletions admin/google-blockly/own/blocks_sendto.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,93 @@ Blockly.JavaScript['sendto_custom'] = function (block) {
return 'sendTo("' + instance + '", "' + command + '", {' + (args.length ? args.join(',') + '\n' : '') + '});\n' + logText;
}
};

// --- sendTo JavaScript --------------------------------------------------
Blockly.Sendto.blocks['sendto_otherscript'] =
'<block type="sendto_otherscript">'
+ ' <value name="NAME">'
+ ' </value>'
+ ' <value name="INSTANCE">'
+ ' </value>'
+ ' <value name="OID">'
+ ' <shadow type="field_oid_script">'
+ ' <field name="oid">Script Object ID</field>'
+ ' </shadow>'
+ ' </value>'
+ ' <value name="MESSAGE">'
+ ' </value>'
+ ' <value name="DATA">'
+ ' <shadow type="math_number">'
+ ' <field name="NUM">1</field>'
+ ' </shadow>'
+ ' </value>'
+ '</block>';

Blockly.Blocks['sendto_otherscript'] = {
init: function() {
var options = [[Blockly.Translate('sendto_otherscript_anyInstance'), '']];
if (typeof main !== 'undefined' && main.instances) {
for (var i = 0; i < main.instances.length; i++) {
var m = main.instances[i].match(/^system.adapter.javascript.(\d+)$/);
if (m) {
var n = parseInt(m[1], 10);
options.push(['javascript.' + n, '.' + n]);
}
}
}

if (!options.length) {
for (var u = 0; u <= 4; u++) {
options.push(['javascript.' + u, '.' + u]);
}
}

this.appendDummyInput('NAME')
.appendField(Blockly.Translate('sendto_otherscript_name'));

this.appendDummyInput('INSTANCE')
.appendField(Blockly.Translate('sendto_otherscript_instance'))
.appendField(new Blockly.FieldDropdown(options), 'INSTANCE');

this.appendValueInput('OID')
.appendField(Blockly.Translate('sendto_otherscript_script'))
.setCheck(null);

this.appendDummyInput('MESSAGE')
.appendField(Blockly.Translate('sendto_otherscript_message'))
.appendField(new Blockly.FieldTextInput('customMessage'), 'MESSAGE');

this.appendValueInput('DATA')
.appendField(Blockly.Translate('sendto_otherscript_data'));

this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);

this.setColour(Blockly.Sendto.HUE);
this.setTooltip(Blockly.Translate('sendto_otherscript_tooltip'));
this.setHelpUrl(Blockly.Translate('sendto_otherscript_help'));
}
};

Blockly.JavaScript['sendto_otherscript'] = function(block) {
var dropdown_instance = block.getFieldValue('INSTANCE');
var value_objectid = Blockly.JavaScript.valueToCode(block, 'OID', Blockly.JavaScript.ORDER_ATOMIC);
var message = block.getFieldValue('MESSAGE');
var data = Blockly.JavaScript.valueToCode(block, 'DATA', Blockly.JavaScript.ORDER_ATOMIC);

var objectname = main.objects[value_objectid] && main.objects[value_objectid].common && main.objects[value_objectid].common.name ? main.objects[value_objectid].common.name : '';

if (!data) {
data = 'true';
}

var text = '{\n';
text += ' script: ' + value_objectid + ',' + (objectname ? '/*' + objectname + '*/' : '') + '\n';
text += ' message: "' + message + '",\n';
text += ' data: ' + data + '\n';

text += '}';

return 'sendTo("javascript' + dropdown_instance + '", "toScript", ' + text + ');\n';
};
27 changes: 27 additions & 0 deletions admin/google-blockly/own/blocks_system.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,33 @@ Blockly.JavaScript['field_oid_meta'] = function(block) {
return ['\'' + oid + '\'', Blockly.JavaScript.ORDER_ATOMIC];
};

// --- select OID script--------------------------------------------------
Blockly.System.blocks['field_oid_script'] =
'<block type="field_oid_script">'
+ ' <value name="TEXT">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['field_oid_script'] = {
init: function() {
this.appendDummyInput()
.appendField(Blockly.Translate('field_oid_OID'));

this.appendDummyInput()
.appendField(new Blockly.FieldOID('default', 'script'), 'oid');

this.setInputsInline(true);
this.setColour(Blockly.System.HUE);
this.setOutput(true, 'String');
this.setTooltip(Blockly.Translate('field_oid_tooltip'));
}
};

Blockly.JavaScript['field_oid_script'] = function(block) {
var oid = block.getFieldValue('oid');
return ['\'' + oid + '\'', Blockly.JavaScript.ORDER_ATOMIC];
};

// --- get attribute --------------------------------------------------
Blockly.System.blocks['get_attr'] =
'<block type="get_attr">'
Expand Down
116 changes: 116 additions & 0 deletions admin/google-blockly/own/blocks_timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,35 @@ Blockly.JavaScript['timeouts_cleartimeout'] = function(block) {
return '(function () {if (' + name + ') {clearTimeout(' + name + '); ' + name + ' = null;}})();\n';
};

// --- getTimeout -----------------------------------------------------------
Blockly.Timeouts.blocks['timeouts_gettimeout'] =
'<block type="timeouts_gettimeout">'
+ ' <value name="NAME">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['timeouts_gettimeout'] = {
init: function() {
this.appendDummyInput("NAME")
.appendField(Blockly.Translate('timeouts_gettimeout'))
.appendField(new Blockly.FieldDropdown(function () {
return window.scripts.blocklyWorkspace ? Blockly.Timeouts.getAllTimeouts(window.scripts.blocklyWorkspace) : [];
}), "NAME");

this.setInputsInline(true);
this.setOutput(true);
this.setColour(Blockly.Timeouts.HUE);
this.setTooltip(Blockly.Translate('timeouts_gettimeout_tooltip'));
this.setHelpUrl(getHelp('timeouts_gettimeout_help'));
}
};

Blockly.JavaScript['timeouts_gettimeout'] = function(block) {
var name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));

return [name, Blockly.JavaScript.ORDER_ATOMIC];;
};

// --- setInterval -----------------------------------------------------------
Blockly.Timeouts.blocks['timeouts_setinterval'] =
'<block type="timeouts_setinterval">'
Expand Down Expand Up @@ -368,6 +397,64 @@ Blockly.JavaScript['timeouts_setinterval'] = function(block) {
return name + ' = setInterval(async function () {\n' + statements_name + '}, ' + delay + ');\n';
};

// --- setInterval variable -----------------------------------------------------------
Blockly.Timeouts.blocks['timeouts_setinterval_variable'] =
'<block type="timeouts_setinterval_variable">'
+ ' <value name="NAME">'
+ ' </value>'
+ ' <value name="INTERVAL_MS">'
+ ' <shadow type="math_number">'
+ ' <field name="NUM">1000</field>'
+ ' </shadow>'
+ ' </value>'
+ ' <value name="STATEMENT">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['timeouts_setinterval_variable'] = {
init: function() {
var nameField = new Blockly.FieldTextInput(
Blockly.Timeouts.findLegalName(Blockly.Translate('timeouts_setinterval_name'), this),
Blockly.Timeouts.rename);

nameField.setSpellcheck(false);

this.appendDummyInput()
.appendField(Blockly.Translate('timeouts_setinterval'))
.appendField(nameField, 'NAME')
.appendField(Blockly.Translate('timeouts_setinterval_in'));

this.appendValueInput('INTERVAL_MS')
.setCheck('Number')
.appendField(Blockly.Translate('timeouts_settimeout_ms'));

this.appendStatementInput('STATEMENT')
.setCheck(null);

this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
this.setColour(Blockly.Timeouts.HUE);
this.setTooltip(Blockly.Translate('timeouts_setinterval_tooltip'));
this.setHelpUrl(getHelp('timeouts_setinterval_help'));
},
isInterval_: true,
getVars: function () {
return [this.getFieldValue('NAME')];
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name;}, name: name, type: 'interval'}];
}
};

Blockly.JavaScript['timeouts_setinterval_variable'] = function(block) {
var delay = Blockly.JavaScript.valueToCode(block, 'INTERVAL_MS', Blockly.JavaScript.ORDER_ATOMIC);
var name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
var statements_name = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
return name + ' = setInterval(async function () {\n' + statements_name + '}, parseInt(' + delay + '));\n';
};

// --- clearInterval -----------------------------------------------------------
Blockly.Timeouts.blocks['timeouts_clearinterval'] =
'<block type="timeouts_clearinterval">'
Expand Down Expand Up @@ -421,4 +508,33 @@ Blockly.JavaScript['timeouts_clearinterval'] = function(block) {
var name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));

return '(function () {if (' + name + ') {clearInterval(' + name + '); ' + name + ' = null;}})();\n';
};

// --- getInterval -----------------------------------------------------------
Blockly.Timeouts.blocks['timeouts_getinterval'] =
'<block type="timeouts_getinterval">'
+ ' <value name="NAME">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['timeouts_getinterval'] = {
init: function() {
this.appendDummyInput("NAME")
.appendField(Blockly.Translate('timeouts_getinterval'))
.appendField(new Blockly.FieldDropdown(function () {
return window.scripts.blocklyWorkspace ? Blockly.Timeouts.getAllIntervals(window.scripts.blocklyWorkspace) : [];
}), "NAME");

this.setInputsInline(true);
this.setOutput(true);
this.setColour(Blockly.Timeouts.HUE);
this.setTooltip(Blockly.Translate('timeouts_getinterval_tooltip'));
this.setHelpUrl(getHelp('timeouts_getinterval_help'));
}
};

Blockly.JavaScript['timeouts_getinterval'] = function(block) {
var name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));

return [name, Blockly.JavaScript.ORDER_ATOMIC];;
};
Loading

0 comments on commit fad1eb4

Please sign in to comment.