iobroker.javascript 7.6.3 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,6 +46,10 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
46
46
  <!--
47
47
  ### **WORK IN PROGRESS**
48
48
  -->
49
+ ### 7.7.0 (2024-01-14)
50
+
51
+ * (klein0r) Added block for multiple and conditions
52
+
49
53
  ### 7.6.3 (2024-01-11)
50
54
 
51
55
  * (klein0r) Fixed bug in formatTimeDiff Blockly
@@ -66,12 +70,6 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
66
70
  * (klein0r) Added option for calendar week to Blockly
67
71
  * (klein0r) Fixed inpaired round brackets of getMinutes (Blockly)
68
72
 
69
- ### 7.5.0 (2023-12-15)
70
-
71
- * (klein0r) Blockly: Day of week as number always returns 1 (monday) to 7 (sunday)
72
- * (klein0r) Fixed layout of script type selection
73
- * (klein0r) Fixed sendto with multiple instances (for callback / timeout handling)
74
-
75
73
  ## License
76
74
  The MIT License (MIT)
77
75
 
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "/static/js/main.01d22eda.js",
3
+ "main.js": "/static/js/main.15faf317.js",
4
4
  "static/css/864.42bfc5f3.chunk.css": "/static/css/864.42bfc5f3.chunk.css",
5
- "static/js/864.964c55a4.chunk.js": "/static/js/864.964c55a4.chunk.js",
5
+ "static/js/864.f79b3560.chunk.js": "/static/js/864.f79b3560.chunk.js",
6
6
  "static/js/805.7c367e53.chunk.js": "/static/js/805.7c367e53.chunk.js",
7
7
  "static/js/723.c39332d7.chunk.js": "/static/js/723.c39332d7.chunk.js",
8
8
  "static/js/66.65480213.chunk.js": "/static/js/66.65480213.chunk.js",
@@ -33,7 +33,7 @@
33
33
  "static/js/377.2f585ccd.chunk.js": "/static/js/377.2f585ccd.chunk.js",
34
34
  "static/js/838.32784fd6.chunk.js": "/static/js/838.32784fd6.chunk.js",
35
35
  "static/js/17.abbe9f7d.chunk.js": "/static/js/17.abbe9f7d.chunk.js",
36
- "static/js/917.f1e12831.chunk.js": "/static/js/917.f1e12831.chunk.js",
36
+ "static/js/344.3ec4fcdf.chunk.js": "/static/js/344.3ec4fcdf.chunk.js",
37
37
  "static/media/tileRules.png": "/static/media/tileRules.7ed5885a66686cc288b1.png",
38
38
  "static/media/docs.md": "/static/media/docs.1f96bec81cf08933d921.md",
39
39
  "static/media/back.jpg": "/static/media/back.bda2bbe51be338a0f657.jpg",
@@ -161,9 +161,9 @@
161
161
  "static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
162
162
  "static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
163
163
  "static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
164
- "main.01d22eda.js.map": "/static/js/main.01d22eda.js.map",
164
+ "main.15faf317.js.map": "/static/js/main.15faf317.js.map",
165
165
  "864.42bfc5f3.chunk.css.map": "/static/css/864.42bfc5f3.chunk.css.map",
166
- "864.964c55a4.chunk.js.map": "/static/js/864.964c55a4.chunk.js.map",
166
+ "864.f79b3560.chunk.js.map": "/static/js/864.f79b3560.chunk.js.map",
167
167
  "805.7c367e53.chunk.js.map": "/static/js/805.7c367e53.chunk.js.map",
168
168
  "723.c39332d7.chunk.js.map": "/static/js/723.c39332d7.chunk.js.map",
169
169
  "66.65480213.chunk.js.map": "/static/js/66.65480213.chunk.js.map",
@@ -194,9 +194,9 @@
194
194
  "377.2f585ccd.chunk.js.map": "/static/js/377.2f585ccd.chunk.js.map",
195
195
  "838.32784fd6.chunk.js.map": "/static/js/838.32784fd6.chunk.js.map",
196
196
  "17.abbe9f7d.chunk.js.map": "/static/js/17.abbe9f7d.chunk.js.map",
197
- "917.f1e12831.chunk.js.map": "/static/js/917.f1e12831.chunk.js.map"
197
+ "344.3ec4fcdf.chunk.js.map": "/static/js/344.3ec4fcdf.chunk.js.map"
198
198
  },
199
199
  "entrypoints": [
200
- "static/js/main.01d22eda.js"
200
+ "static/js/main.15faf317.js"
201
201
  ]
202
202
  }
@@ -4,6 +4,190 @@ if (typeof goog !== 'undefined') {
4
4
  goog.require('Blockly.JavaScript');
5
5
  }
6
6
 
7
+ // --- logic multi and --------------------------------------------------
8
+
9
+ Blockly.Blocks['logic_multi_and_container'] = {
10
+ /**
11
+ * Mutator block for container.
12
+ * @this Blockly.Block
13
+ */
14
+ init: function() {
15
+ this.setColour("%{BKY_LOGIC_HUE}");
16
+
17
+ this.appendDummyInput()
18
+ .appendField(Blockly.Translate('logic_multi_and'));
19
+
20
+ this.appendStatementInput('STACK');
21
+ this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
22
+
23
+ this.contextMenu = false;
24
+ }
25
+ };
26
+
27
+ Blockly.Blocks['logic_multi_and_mutator'] = {
28
+ /**
29
+ * Mutator block for add items.
30
+ * @this Blockly.Block
31
+ */
32
+ init: function() {
33
+ this.setColour("%{BKY_LOGIC_HUE}");
34
+
35
+ this.appendDummyInput('AND')
36
+ .appendField(Blockly.Translate('logic_multi_and_and'));
37
+
38
+ this.setPreviousStatement(true);
39
+ this.setNextStatement(true);
40
+
41
+ this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
42
+
43
+ this.contextMenu = false;
44
+ }
45
+ };
46
+
47
+ Blockly.Blocks['logic_multi_and'] = {
48
+ init: function() {
49
+ this.itemCount_ = 2;
50
+ this.setMutator(new Blockly.Mutator(['logic_multi_and_mutator']));
51
+
52
+ this.setInputsInline(false);
53
+ this.setOutput(true, 'Boolean');
54
+
55
+ this.setColour("%{BKY_LOGIC_HUE}");
56
+ this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
57
+ // this.setHelpUrl(getHelp('logic_multi_and_help'));
58
+ },
59
+ /**
60
+ * Create XML to represent number of text inputs.
61
+ * @return {!Element} XML storage element.
62
+ * @this Blockly.Block
63
+ */
64
+ mutationToDom: function () {
65
+ const container = document.createElement('mutation');
66
+ container.setAttribute('items', this.itemCount_);
67
+
68
+ return container;
69
+ },
70
+ /**
71
+ * Parse XML to restore the text inputs.
72
+ * @param {!Element} xmlElement XML storage element.
73
+ * @this Blockly.Block
74
+ */
75
+ domToMutation: function (xmlElement) {
76
+ this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
77
+ this.updateShape_();
78
+ },
79
+ /**
80
+ * Populate the mutator's dialog with this block's components.
81
+ * @param {!Blockly.Workspace} workspace Mutator's workspace.
82
+ * @return {!Blockly.Block} Root block in mutator.
83
+ * @this Blockly.Block
84
+ */
85
+ decompose: function (workspace) {
86
+ const containerBlock = workspace.newBlock('logic_multi_and_container');
87
+ containerBlock.initSvg();
88
+
89
+ let connection = containerBlock.getInput('STACK').connection;
90
+ for (let i = 0; i < this.itemCount_; i++) {
91
+ const itemBlock = workspace.newBlock('logic_multi_and_mutator');
92
+ itemBlock.initSvg();
93
+ connection.connect(itemBlock.previousConnection);
94
+ connection = itemBlock.nextConnection;
95
+ }
96
+
97
+ return containerBlock;
98
+ },
99
+ /**
100
+ * Reconfigure this block based on the mutator dialog's components.
101
+ * @param {!Blockly.Block} containerBlock Root block in mutator.
102
+ * @this Blockly.Block
103
+ */
104
+ compose: function (containerBlock) {
105
+ let itemBlock = containerBlock.getInputTargetBlock('STACK');
106
+ // Count number of inputs.
107
+ const connections = [];
108
+ while (itemBlock) {
109
+ connections.push(itemBlock.valueConnection_);
110
+ itemBlock = itemBlock.nextConnection &&
111
+ itemBlock.nextConnection.targetBlock();
112
+ }
113
+
114
+ // Disconnect any children that don't belong.
115
+ for (let k = 0; k < this.itemCount_; k++) {
116
+ const connection = this.getInput('AND' + k).connection.targetConnection;
117
+ if (connection && connections.indexOf(connection) === -1) {
118
+ connection.disconnect();
119
+ }
120
+ }
121
+
122
+ this.itemCount_ = connections.length;
123
+ if (this.itemCount_ < 2) {
124
+ this.itemCount_ = 2;
125
+ }
126
+ this.updateShape_();
127
+
128
+ // Reconnect any child blocks.
129
+ for (let i = 0; i < this.itemCount_; i++) {
130
+ Blockly.Mutator.reconnect(connections[i], this, 'AND' + i);
131
+ }
132
+ },
133
+ /**
134
+ * Store pointers to any connected child blocks.
135
+ * @param {!Blockly.Block} containerBlock Root block in mutator.
136
+ * @this Blockly.Block
137
+ */
138
+ saveConnections: function(containerBlock) {
139
+ let itemBlock = containerBlock.getInputTargetBlock('STACK');
140
+ let i = 0;
141
+
142
+ while (itemBlock) {
143
+ const input = this.getInput('AND' + i);
144
+ itemBlock.valueConnection_ = input && input.connection.targetConnection;
145
+ i++;
146
+ itemBlock = itemBlock.nextConnection &&
147
+ itemBlock.nextConnection.targetBlock();
148
+ }
149
+ },
150
+ /**
151
+ * Modify this block to have the correct number of inputs.
152
+ * @private
153
+ * @this Blockly.Block
154
+ */
155
+ updateShape_: function() {
156
+ if (this.itemCount_ && this.getInput('EMPTY')) {
157
+ this.removeInput('EMPTY');
158
+ } else if (!this.itemCount_ && !this.getInput('EMPTY')) {
159
+ this.appendDummyInput('EMPTY')
160
+ .appendField(this.newQuote_(true))
161
+ .appendField(this.newQuote_(false));
162
+ }
163
+ // Add new inputs.
164
+ for (let i = 0; i < this.itemCount_; i++) {
165
+ if (!this.getInput('AND' + i)) {
166
+ const input = this.appendValueInput('AND' + i).setAlign(Blockly.ALIGN_RIGHT);
167
+ if (i > 0) {
168
+ input.appendField(Blockly.Translate('logic_multi_and_and'));
169
+ }
170
+ }
171
+ }
172
+ // Remove deleted inputs.
173
+ for (let i = this.itemCount_; this.getInput('AND' + i); i++) {
174
+ this.removeInput('AND' + i);
175
+ }
176
+ }
177
+ };
178
+
179
+ Blockly.JavaScript['logic_multi_and'] = function(block) {
180
+ const ands = [];
181
+ for (let n = 0; n < block.itemCount_; n++) {
182
+ const condition = Blockly.JavaScript.valueToCode(block, 'AND' + n, Blockly.JavaScript.ORDER_COMMA);
183
+ if (condition) {
184
+ ands.push(condition);
185
+ }
186
+ }
187
+
188
+ return [`(${ands.length > 0 ? ands.join(' && ') : 'false'})`, Blockly.JavaScript.ORDER_ATOMIC];
189
+ };
190
+
7
191
  // --- logic between --------------------------------------------------
8
192
 
9
193
  Blockly.Blocks['logic_between'] = {
@@ -21,9 +205,9 @@ Blockly.Blocks['logic_between'] = {
21
205
  this.setOutput(true, 'Boolean');
22
206
  this.setColour("%{BKY_LOGIC_HUE}");
23
207
  this.setTooltip(Blockly.Translate('logic_between_tooltip'));
24
- // this.setHelpUrl(Blockly.Translate('logic_between_helpurl'));
208
+ // this.setHelpUrl(getHelp('logic_between_help'));
25
209
  }
26
- }
210
+ };
27
211
 
28
212
  Blockly.JavaScript['logic_between'] = function(block) {
29
213
  const min = Blockly.JavaScript.valueToCode(block, 'MIN', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
@@ -33,28 +217,28 @@ Blockly.JavaScript['logic_between'] = function(block) {
33
217
  const maxOperator = block.getFieldValue('MAX_OPERATOR') === 'LT' ? '<' : '<=';
34
218
 
35
219
  return [`${min} ${minOperator} ${value} && ${value} ${maxOperator} ${max}`, Blockly.JavaScript.ORDER_LOGICAL_AND];
36
- }
220
+ };
37
221
 
38
222
  // --- logic ifempty --------------------------------------------------
39
223
 
40
224
  Blockly.Blocks['logic_ifempty'] = {
41
- init: function() {
42
- this.appendValueInput('VALUE')
43
- .setCheck(null)
44
- .setAlign(Blockly.ALIGN_RIGHT)
45
- .appendField(Blockly.Translate('logic_ifempty'));
46
- this.appendValueInput('DEFLT')
47
- .setCheck(null)
48
- .setAlign(Blockly.ALIGN_RIGHT)
49
- .appendField(Blockly.Translate('logic_ifempty_then'));
50
-
51
- this.setOutput(true, null);
52
- this.setInputsInline(true);
53
- this.setColour("%{BKY_LOGIC_HUE}");
54
- this.setTooltip(Blockly.Translate('logic_ifempty_tooltip'));
55
- // this.setHelpUrl(Blockly.Translate('logic_ifempty_helpurl'));
56
- }
57
- }
225
+ init: function() {
226
+ this.appendValueInput('VALUE')
227
+ .setCheck(null)
228
+ .setAlign(Blockly.ALIGN_RIGHT)
229
+ .appendField(Blockly.Translate('logic_ifempty'));
230
+ this.appendValueInput('DEFLT')
231
+ .setCheck(null)
232
+ .setAlign(Blockly.ALIGN_RIGHT)
233
+ .appendField(Blockly.Translate('logic_ifempty_then'));
234
+
235
+ this.setOutput(true, null);
236
+ this.setInputsInline(true);
237
+ this.setColour("%{BKY_LOGIC_HUE}");
238
+ this.setTooltip(Blockly.Translate('logic_ifempty_tooltip'));
239
+ // this.setHelpUrl(getHelp('logic_ifempty_help'));
240
+ }
241
+ };
58
242
 
59
243
  Blockly.JavaScript['logic_ifempty'] = function(block) {
60
244
  const value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_LOGICAL_OR) || null;
@@ -378,13 +378,13 @@ Blockly.Words['on_ack'] = {'en': 'Ack is',
378
378
  Blockly.Words['on_ack_any'] = {'en': 'any', 'de': 'egal', 'ru': 'не важно', 'pt': 'qualquer', 'nl': 'ieder', 'fr': 'tout', 'it': 'qualunque', 'es': 'alguna', 'pl': 'any', 'zh-cn': '任何', 'uk': 'будь-який'};
379
379
  Blockly.Words['on_ack_true'] = {'en': 'update', 'de': 'bestätigte Änderung', 'ru': 'обновление', 'pt': 'atualizar', 'nl': 'bijwerken', 'fr': 'mettre à jour', 'it': 'aggiornare', 'es': 'actualizar', 'pl': 'update', 'zh-cn': '更新', 'uk': 'оновлення'};
380
380
  Blockly.Words['on_ack_false'] = {'en': 'command', 'de': 'unbestätigte Änderung', 'ru': 'команда', 'pt': 'comando', 'nl': 'opdracht', 'fr': 'commander', 'it': 'comando', 'es': 'mando', 'pl': 'command', 'zh-cn': '命令', 'uk': 'команда'};
381
- Blockly.Words['on_ext'] = {'en': 'Event: if objects', 'de': 'Falls Objekt', 'ru': 'Событие: если объект', 'pt': 'Se o objeto', 'nl': 'Evenement: als objecten', 'fr': 'Evénement: si des objets', 'it': 'Evento: se oggetti', 'es': 'Evento: si los objetos', 'pl': 'Event: if objects', 'zh-cn': '事件:如果对象', 'uk': 'Подія: якщо об\'єкти'};
381
+ Blockly.Words['on_ext'] = {'en': 'Event: if objects', 'de': 'Falls Objekte', 'ru': 'Событие: если объект', 'pt': 'Se o objeto', 'nl': 'Evenement: als objecten', 'fr': 'Evénement: si des objets', 'it': 'Evento: se oggetti', 'es': 'Evento: si los objetos', 'pl': 'Event: if objects', 'zh-cn': '事件:如果对象', 'uk': 'Подія: якщо об\'єкти'};
382
382
  Blockly.Words['on_ext_tooltip'] = {'en': 'If some state changed or updated', 'de': 'Bei Zustandsänderung', 'ru': 'При изменении или обновлении состояния', 'pt': 'Se mudou o estado', 'nl': 'Als een bepaalde staat is gewijzigd of bijgewerkt', 'fr': 'Si un état a été modifié ou mis à jour', 'it': 'Se qualche stato è cambiato o aggiornato', 'es': 'Si algún estado cambió o se actualizó', 'pl': 'If some state changed or updated', 'zh-cn': '如果对象有改变或更新则触发', 'uk': 'Якщо якийсь стан змінено або оновлено'};
383
383
  Blockly.Words['on_ext_oid'] = {'en': 'object ID', 'de': 'Objekt ID', 'ru': 'ID объекта', 'pt': 'ID do objeto', 'nl': 'object-ID', 'fr': 'ID d\'objet', 'it': 'ID oggetto', 'es': 'ID de objeto', 'pl': 'object ID', 'zh-cn': '对象ID', 'uk': 'ID об\'єкта'};
384
384
  Blockly.Words['on_ext_oid_tooltip'] = {'en': 'Object ID', 'de': 'Objekt ID', 'ru': 'ID объекта', 'pt': 'ID do objeto', 'nl': 'Object ID', 'fr': 'ID de l\'objet', 'it': 'ID oggetto', 'es': 'ID del objeto', 'pl': 'Object ID', 'zh-cn': '对象ID', 'uk': 'ID об\'єкта'};
385
385
  Blockly.Words['on_ext_on'] = {'en': 'trigger on', 'de': 'falls Trigger auf', 'ru': 'если cобытие', 'pt': 'trigger no', 'nl': 'trigger aan', 'fr': 'déclencher', 'it': 'innesco su', 'es': 'desencadenar', 'pl': 'trigger on', 'zh-cn': '触发源', 'uk': 'тригер увімкнено'};
386
386
  Blockly.Words['on_ext_on_tooltip'] = {'en': 'trigger on', 'de': 'falls Trigger auf', 'ru': 'если cобытие', 'pt': 'trigger no', 'nl': 'trigger aan', 'fr': 'déclencher', 'it': 'innesco su', 'es': 'desencadenar', 'pl': 'trigger on', 'zh-cn': '多触发源触发', 'uk': 'тригер увімкнено'};
387
- Blockly.Words['on'] = {'en': 'Event: if object', 'de': 'falls Objekt', 'ru': 'Событие: если объект', 'pt': 'se o objeto', 'nl': 'Evenement: als object', 'fr': 'Evénement: si objet', 'it': 'Evento: se oggetto', 'es': 'Evento: si el objeto', 'pl': 'Event: if object', 'zh-cn': '事件:如果对象', 'uk': 'Подія: якщо об\'єкт'};
387
+ Blockly.Words['on'] = {'en': 'Event: if object', 'de': 'Falls Objekt', 'ru': 'Событие: если объект', 'pt': 'se o objeto', 'nl': 'Evenement: als object', 'fr': 'Evénement: si objet', 'it': 'Evento: se oggetto', 'es': 'Evento: si el objeto', 'pl': 'Event: if object', 'zh-cn': '事件:如果对象', 'uk': 'Подія: якщо об\'єкт'};
388
388
  Blockly.Words['on_tooltip'] = {'en': 'If some state changed or updated', 'de': 'Bei Zustandsänderung', 'ru': 'При изменении или обновлении состояния', 'pt': 'se mudou o estado', 'nl': 'Als een bepaalde staat is gewijzigd of bijgewerkt', 'fr': 'Si un état a été modifié ou mis à jour', 'it': 'Se qualche stato è cambiato o aggiornato', 'es': 'Si algún estado cambió o se actualizó', 'pl': 'If some state changed or updated', 'zh-cn': '如果对象有改变或更新则触发', 'uk': 'Якщо якийсь стан змінено або оновлено'};
389
389
  Blockly.Words['on_source'] = {'en': 'get', 'de': 'Nehme', 'ru': 'взять', 'pt': 'pege', 'nl': 'krijgen', 'fr': 'obtenir', 'it': 'ottenere', 'es': 'obtener', 'pl': 'get', 'zh-cn': '得到', 'uk': 'отримати'};
390
390
  Blockly.Words['on_source_of'] = {'en': 'of trigger', 'de': 'von Trigger', 'ru': 'триггера', 'pt': 'do trigger', 'nl': 'van trigger', 'fr': 'de déclenchement', 'it': 'di innesco', 'es': 'de gatillo', 'pl': 'of trigger', 'zh-cn': '触发器', 'uk': 'тригера'};
@@ -516,6 +516,11 @@ Blockly.Words['onMessage_help'] = {'en': 'onMessage',
516
516
 
517
517
  // --- LOGIC --------------------------------------------------
518
518
 
519
+ // --- logic multi and --------------------------------------------------
520
+ Blockly.Words['logic_multi_and'] = {'en': 'Conditions', 'de': 'Bedingungen', 'ru': 'Условия', 'pt': 'Condições', 'nl': 'Voorwaarden', 'fr': 'Conditions', 'it': 'Condizioni', 'es': 'Condiciones', 'pl': 'Warunki', 'zh-cn': '条件', 'uk': 'Умови'};
521
+ Blockly.Words['logic_multi_and_and'] = {'en': 'and', 'de': 'und', 'ru': 'и', 'pt': 'e', 'nl': 'en', 'fr': 'et', 'it': 'e', 'es': 'y', 'pl': 'and', 'zh-cn': '和', 'uk': 'і'};
522
+ Blockly.Words['logic_multi_and_tooltip'] = {'en': '', 'de': '', 'ru': '', 'pt': '', 'nl': '', 'fr': '', 'it': '', 'es': '', 'pl': '', 'zh-cn': '', 'uk': ''};
523
+
519
524
  // --- logic between --------------------------------------------------
520
525
  Blockly.Words['logic_between_min'] = {'en': 'Min', 'de': 'Min', 'ru': 'Мин', 'pt': 'Min', 'nl': 'Min', 'fr': 'Min', 'it': 'Min', 'es': 'Min', 'pl': 'Min', 'zh-cn': '明 明', 'uk': 'Мінуси'};
521
526
  Blockly.Words['logic_between_max'] = {'en': 'Max', 'de': 'Max', 'ru': 'Макс', 'pt': 'Max', 'nl': 'Max', 'fr': 'Max', 'it': 'Max', 'es': 'Max', 'pl': 'Max', 'zh-cn': 'Max', 'uk': 'Макс'};