iobroker.javascript 7.0.10 → 7.1.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 +2 -1
- package/admin/asset-manifest.json +5 -5
- package/admin/google-blockly/blockly-9.3.3.tgz +0 -0
- package/admin/google-blockly/blockly_compressed.js +1704 -1469
- package/admin/google-blockly/blocks_compressed.js +218 -164
- package/admin/google-blockly/javascript_compressed.js +328 -100
- package/admin/google-blockly/msg/js/de.js +70 -64
- package/admin/google-blockly/msg/js/en.js +20 -14
- package/admin/google-blockly/msg/js/es.js +45 -39
- package/admin/google-blockly/msg/js/fr.js +65 -59
- package/admin/google-blockly/msg/js/it.js +25 -19
- package/admin/google-blockly/msg/js/nl.js +61 -55
- package/admin/google-blockly/msg/js/pl.js +52 -46
- package/admin/google-blockly/msg/js/pt.js +36 -30
- package/admin/google-blockly/msg/js/ru.js +47 -41
- package/admin/google-blockly/msg/js/uk.js +17 -13
- package/admin/google-blockly/msg/js/zh-cn.js +92 -86
- package/admin/google-blockly/own/blocks_action.js +4 -4
- package/admin/google-blockly/own/blocks_number.js +4 -3
- package/admin/google-blockly/own/blocks_procedures.js +106 -75
- package/admin/google-blockly/own/blocks_sendto.js +2 -2
- package/admin/google-blockly/own/blocks_switch.js +8 -19
- package/admin/google-blockly/own/blocks_system.js +171 -113
- package/admin/google-blockly/own/blocks_text.js +1 -1
- package/admin/google-blockly/own/blocks_time.js +2 -1
- package/admin/google-blockly/own/blocks_timeout.js +31 -27
- package/admin/google-blockly/own/blocks_trigger.js +62 -44
- package/admin/google-blockly/own/blocks_words.js +3 -3
- package/admin/google-blockly/own/field_cron.js +138 -189
- package/admin/google-blockly/own/field_oid.js +167 -249
- package/admin/google-blockly/own/field_script.js +124 -170
- package/admin/static/js/98.7af6b699.chunk.js +2 -0
- package/admin/static/js/98.7af6b699.chunk.js.map +1 -0
- package/admin/static/js/{main.d5dc2784.js → main.bf8794f5.js} +2 -2
- package/admin/static/js/{main.d5dc2784.js.map → main.bf8794f5.js.map} +1 -1
- package/admin/tab.html +1 -1
- package/io-package.json +13 -13
- package/main.js +9 -10
- package/package.json +1 -1
- package/admin/blockly-9.0.1.tgz +0 -0
- package/admin/static/js/98.eee0c52f.chunk.js +0 -2
- package/admin/static/js/98.eee0c52f.chunk.js.map +0 -1
|
@@ -113,13 +113,15 @@ Blockly.Blocks['timeouts_wait'] = {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
Blockly.JavaScript['timeouts_wait'] = function(block) {
|
|
116
|
+
const unit = block.getFieldValue('UNIT');
|
|
117
|
+
|
|
116
118
|
let delay = block.getFieldValue('DELAY');
|
|
117
|
-
const unit = block.getFieldValue('UNIT');
|
|
118
119
|
if (unit === 'min') {
|
|
119
120
|
delay *= 60000;
|
|
120
121
|
} else if (unit === 'sec') {
|
|
121
122
|
delay *= 1000;
|
|
122
123
|
}
|
|
124
|
+
|
|
123
125
|
return 'await wait(' + delay + ');\n';
|
|
124
126
|
};
|
|
125
127
|
|
|
@@ -172,23 +174,25 @@ Blockly.Blocks['timeouts_settimeout'] = {
|
|
|
172
174
|
},
|
|
173
175
|
getVarModels: function () {
|
|
174
176
|
const name = this.getFieldValue('NAME');
|
|
175
|
-
return [{getId:
|
|
177
|
+
return [{ getId: () => { return name; }, name: name, type: 'timeout' }];
|
|
176
178
|
}
|
|
177
179
|
};
|
|
178
180
|
|
|
179
181
|
Blockly.JavaScript['timeouts_settimeout'] = function(block) {
|
|
182
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
183
|
+
const unit = block.getFieldValue('UNIT');
|
|
184
|
+
|
|
180
185
|
let delay = block.getFieldValue('DELAY');
|
|
181
|
-
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
182
|
-
const unit = block.getFieldValue('UNIT');
|
|
183
186
|
if (unit === 'min') {
|
|
184
187
|
delay *= 60000;
|
|
185
188
|
} else if (unit === 'sec') {
|
|
186
189
|
delay *= 1000;
|
|
187
190
|
}
|
|
188
|
-
|
|
189
|
-
|
|
191
|
+
|
|
192
|
+
const statements = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
193
|
+
return name + ' = setTimeout(async () => {\n' +
|
|
190
194
|
Blockly.JavaScript.prefixLines(name + ' = null;', Blockly.JavaScript.INDENT) + '\n' +
|
|
191
|
-
|
|
195
|
+
statements +
|
|
192
196
|
'}, ' + delay + ');\n';
|
|
193
197
|
};
|
|
194
198
|
|
|
@@ -239,18 +243,18 @@ Blockly.Blocks['timeouts_settimeout_variable'] = {
|
|
|
239
243
|
},
|
|
240
244
|
getVarModels: function () {
|
|
241
245
|
const name = this.getFieldValue('NAME');
|
|
242
|
-
return [{getId:
|
|
246
|
+
return [{ getId: () => { return name; }, name: name, type: 'timeout' }];
|
|
243
247
|
}
|
|
244
248
|
};
|
|
245
249
|
|
|
246
250
|
Blockly.JavaScript['timeouts_settimeout_variable'] = function(block) {
|
|
247
251
|
const delay = Blockly.JavaScript.valueToCode(block, 'DELAY_MS', Blockly.JavaScript.ORDER_ATOMIC);
|
|
248
|
-
const name
|
|
249
|
-
const
|
|
252
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
253
|
+
const statements = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
250
254
|
|
|
251
|
-
return name + ' = setTimeout(async
|
|
255
|
+
return name + ' = setTimeout(async () => {\n' +
|
|
252
256
|
Blockly.JavaScript.prefixLines(name + ' = null;', Blockly.JavaScript.INDENT) + '\n' +
|
|
253
|
-
|
|
257
|
+
statements +
|
|
254
258
|
'}, parseInt(' + delay + '));\n';
|
|
255
259
|
};
|
|
256
260
|
|
|
@@ -305,7 +309,7 @@ Blockly.Blocks['timeouts_cleartimeout'] = {
|
|
|
305
309
|
|
|
306
310
|
Blockly.JavaScript['timeouts_cleartimeout'] = function(block) {
|
|
307
311
|
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
308
|
-
return '(
|
|
312
|
+
return '(() => { if (' + name + ') { clearTimeout(' + name + '); ' + name + ' = null; }})();\n';
|
|
309
313
|
};
|
|
310
314
|
|
|
311
315
|
// --- getTimeout -----------------------------------------------------------
|
|
@@ -386,24 +390,24 @@ Blockly.Blocks['timeouts_setinterval'] = {
|
|
|
386
390
|
},
|
|
387
391
|
getVarModels: function () {
|
|
388
392
|
const name = this.getFieldValue('NAME');
|
|
389
|
-
return [{getId:
|
|
393
|
+
return [{ getId: () => { return name; }, name: name, type: 'interval' }];
|
|
390
394
|
}
|
|
391
395
|
};
|
|
392
396
|
|
|
393
397
|
Blockly.JavaScript['timeouts_setinterval'] = function(block) {
|
|
398
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
399
|
+
const unit = block.getFieldValue('UNIT');
|
|
400
|
+
|
|
394
401
|
let delay = block.getFieldValue('INTERVAL');
|
|
395
|
-
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
396
|
-
const unit = block.getFieldValue('UNIT');
|
|
397
402
|
if (unit === 'min') {
|
|
398
403
|
delay *= 60000;
|
|
399
404
|
} else if (unit === 'sec') {
|
|
400
405
|
delay *= 1000;
|
|
401
406
|
}
|
|
402
407
|
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
statements_name +
|
|
408
|
+
const statements = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
409
|
+
return name + ' = setInterval(async () => {\n' +
|
|
410
|
+
statements +
|
|
407
411
|
'}, ' + delay + ');\n';
|
|
408
412
|
};
|
|
409
413
|
|
|
@@ -454,17 +458,17 @@ Blockly.Blocks['timeouts_setinterval_variable'] = {
|
|
|
454
458
|
},
|
|
455
459
|
getVarModels: function () {
|
|
456
460
|
const name = this.getFieldValue('NAME');
|
|
457
|
-
return [{getId:
|
|
461
|
+
return [{ getId: () => { return name; }, name: name, type: 'interval' }];
|
|
458
462
|
}
|
|
459
463
|
};
|
|
460
464
|
|
|
461
465
|
Blockly.JavaScript['timeouts_setinterval_variable'] = function(block) {
|
|
462
466
|
const delay = Blockly.JavaScript.valueToCode(block, 'INTERVAL_MS', Blockly.JavaScript.ORDER_ATOMIC);
|
|
463
|
-
const name
|
|
464
|
-
const
|
|
467
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
468
|
+
const statements = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
465
469
|
|
|
466
|
-
return name + ' = setInterval(async
|
|
467
|
-
|
|
470
|
+
return name + ' = setInterval(async () => {\n' +
|
|
471
|
+
statements +
|
|
468
472
|
'}, parseInt(' + delay + '));\n';
|
|
469
473
|
};
|
|
470
474
|
|
|
@@ -520,7 +524,7 @@ Blockly.Blocks['timeouts_clearinterval'] = {
|
|
|
520
524
|
Blockly.JavaScript['timeouts_clearinterval'] = function(block) {
|
|
521
525
|
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
522
526
|
|
|
523
|
-
return '(
|
|
527
|
+
return '(() => { if (' + name + ') { clearInterval(' + name + '); ' + name + ' = null; }})();\n';
|
|
524
528
|
};
|
|
525
529
|
|
|
526
530
|
// --- getInterval -----------------------------------------------------------
|
|
@@ -549,5 +553,5 @@ Blockly.Blocks['timeouts_getinterval'] = {
|
|
|
549
553
|
Blockly.JavaScript['timeouts_getinterval'] = function(block) {
|
|
550
554
|
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
551
555
|
|
|
552
|
-
return [name, Blockly.JavaScript.ORDER_ATOMIC]
|
|
556
|
+
return [name, Blockly.JavaScript.ORDER_ATOMIC];
|
|
553
557
|
};
|
|
@@ -85,6 +85,7 @@ Blockly.Blocks['on_ext'] = {
|
|
|
85
85
|
mutationToDom: function () {
|
|
86
86
|
const container = document.createElement('mutation');
|
|
87
87
|
container.setAttribute('items', this.itemCount_);
|
|
88
|
+
|
|
88
89
|
return container;
|
|
89
90
|
},
|
|
90
91
|
/**
|
|
@@ -105,6 +106,7 @@ Blockly.Blocks['on_ext'] = {
|
|
|
105
106
|
decompose: function (workspace) {
|
|
106
107
|
const containerBlock = workspace.newBlock('on_ext_oid_container');
|
|
107
108
|
containerBlock.initSvg();
|
|
109
|
+
|
|
108
110
|
let connection = containerBlock.getInput('STACK').connection;
|
|
109
111
|
for (let i = 0; i < this.itemCount_; i++) {
|
|
110
112
|
const itemBlock = workspace.newBlock('on_ext_oid');
|
|
@@ -112,6 +114,7 @@ Blockly.Blocks['on_ext'] = {
|
|
|
112
114
|
connection.connect(itemBlock.previousConnection);
|
|
113
115
|
connection = itemBlock.nextConnection;
|
|
114
116
|
}
|
|
117
|
+
|
|
115
118
|
return containerBlock;
|
|
116
119
|
},
|
|
117
120
|
/**
|
|
@@ -128,6 +131,7 @@ Blockly.Blocks['on_ext'] = {
|
|
|
128
131
|
itemBlock = itemBlock.nextConnection &&
|
|
129
132
|
itemBlock.nextConnection.targetBlock();
|
|
130
133
|
}
|
|
134
|
+
|
|
131
135
|
// Disconnect any children that don't belong.
|
|
132
136
|
for (let k = 0; k < this.itemCount_; k++) {
|
|
133
137
|
const connection = this.getInput('OID' + k).connection.targetConnection;
|
|
@@ -135,11 +139,13 @@ Blockly.Blocks['on_ext'] = {
|
|
|
135
139
|
connection.disconnect();
|
|
136
140
|
}
|
|
137
141
|
}
|
|
142
|
+
|
|
138
143
|
this.itemCount_ = connections.length;
|
|
139
144
|
if (this.itemCount_ < 1) {
|
|
140
145
|
this.itemCount_ = 1;
|
|
141
146
|
}
|
|
142
147
|
this.updateShape_();
|
|
148
|
+
|
|
143
149
|
// Reconnect any child blocks.
|
|
144
150
|
for (let i = 0; i < this.itemCount_; i++) {
|
|
145
151
|
Blockly.Mutator.reconnect(connections[i], this, 'OID' + i);
|
|
@@ -153,6 +159,7 @@ Blockly.Blocks['on_ext'] = {
|
|
|
153
159
|
saveConnections: function(containerBlock) {
|
|
154
160
|
let itemBlock = containerBlock.getInputTargetBlock('STACK');
|
|
155
161
|
let i = 0;
|
|
162
|
+
|
|
156
163
|
while (itemBlock) {
|
|
157
164
|
const input = this.getInput('OID' + i);
|
|
158
165
|
itemBlock.valueConnection_ = input && input.connection.targetConnection;
|
|
@@ -216,6 +223,7 @@ Blockly.Blocks['on_ext'] = {
|
|
|
216
223
|
}, 100, _input);
|
|
217
224
|
}
|
|
218
225
|
}
|
|
226
|
+
|
|
219
227
|
// Remove deleted inputs.
|
|
220
228
|
while (this.getInput('OID' + i)) {
|
|
221
229
|
this.removeInput('OID' + i);
|
|
@@ -252,13 +260,14 @@ Blockly.Blocks['on_ext'] = {
|
|
|
252
260
|
};
|
|
253
261
|
Blockly.JavaScript['on_ext'] = function(block) {
|
|
254
262
|
const dropdown_condition = block.getFieldValue('CONDITION');
|
|
255
|
-
const statements_name = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
256
263
|
const ack_condition = block.getFieldValue('ACK_CONDITION');
|
|
264
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
265
|
+
|
|
257
266
|
let val;
|
|
258
267
|
if (dropdown_condition === 'true' || dropdown_condition === 'false') {
|
|
259
268
|
val = 'val: ' + dropdown_condition;
|
|
260
269
|
} else {
|
|
261
|
-
val =
|
|
270
|
+
val = `change: '${dropdown_condition}'`;
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
const oids = [];
|
|
@@ -274,12 +283,12 @@ Blockly.JavaScript['on_ext'] = function(block) {
|
|
|
274
283
|
}
|
|
275
284
|
}
|
|
276
285
|
}
|
|
286
|
+
|
|
277
287
|
const oid = '[].concat(' + oids.join(').concat(') + ')';
|
|
278
288
|
|
|
279
|
-
|
|
289
|
+
return `on({ id: ${oid}, ${val} ${ack_condition ? ', ack: ' + ack_condition : ''} }, async (obj) => {\n` +
|
|
280
290
|
(oids.length === 1 ? Blockly.JavaScript.prefixLines('let value = obj.state.val;\nlet oldValue = obj.oldState.val;', Blockly.JavaScript.INDENT) + '\n' : '') +
|
|
281
|
-
|
|
282
|
-
return code;
|
|
291
|
+
statement + '});\n';
|
|
283
292
|
};
|
|
284
293
|
|
|
285
294
|
// --- ON -----------------------------------------------------------
|
|
@@ -338,8 +347,8 @@ Blockly.JavaScript['on'] = function(block) {
|
|
|
338
347
|
const value_objectid = block.getFieldValue('OID');
|
|
339
348
|
const dropdown_condition = block.getFieldValue('CONDITION');
|
|
340
349
|
const ack_condition = block.getFieldValue('ACK_CONDITION');
|
|
341
|
-
const
|
|
342
|
-
const
|
|
350
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
351
|
+
const objectName = main.objects[value_objectid] && main.objects[value_objectid].common && main.objects[value_objectid].common.name ? main.objects[value_objectid].common.name : '';
|
|
343
352
|
|
|
344
353
|
Blockly.Msg.VARIABLES_DEFAULT_NAME = 'value';
|
|
345
354
|
|
|
@@ -347,13 +356,13 @@ Blockly.JavaScript['on'] = function(block) {
|
|
|
347
356
|
if (dropdown_condition === 'true' || dropdown_condition === 'false') {
|
|
348
357
|
val = 'val: ' + dropdown_condition;
|
|
349
358
|
} else {
|
|
350
|
-
val =
|
|
359
|
+
val = `change: '${dropdown_condition}'`;
|
|
351
360
|
}
|
|
352
361
|
|
|
353
|
-
return
|
|
354
|
-
Blockly.JavaScript.prefixLines('let value = obj.state.val
|
|
362
|
+
return `on({ id: '${value_objectid}'${objectName ? ` /* ${objectName} */` : ''}, ${val} ${ack_condition ? ', ack: ' + ack_condition : ''} }, async (obj) => {\n` +
|
|
363
|
+
Blockly.JavaScript.prefixLines('let value = obj.state.val;', Blockly.JavaScript.INDENT) + '\n' +
|
|
355
364
|
Blockly.JavaScript.prefixLines('let oldValue = obj.oldState.val;', Blockly.JavaScript.INDENT) + '\n' +
|
|
356
|
-
|
|
365
|
+
statement +
|
|
357
366
|
'});\n';
|
|
358
367
|
};
|
|
359
368
|
|
|
@@ -397,7 +406,7 @@ Blockly.Blocks['on_source'] = {
|
|
|
397
406
|
[Blockly.Translate('on_source_oldstate_ack'), 'oldState.ack'],
|
|
398
407
|
[Blockly.Translate('on_source_oldstate_lc'), 'oldState.lc'],
|
|
399
408
|
[Blockly.Translate('on_source_oldstate_c'), 'oldState.c'],
|
|
400
|
-
[Blockly.Translate('on_source_oldstate_user'),
|
|
409
|
+
[Blockly.Translate('on_source_oldstate_user'), 'oldState.user']
|
|
401
410
|
]), 'ATTR');
|
|
402
411
|
|
|
403
412
|
this.setInputsInline(true);
|
|
@@ -440,11 +449,13 @@ Blockly.Blocks['on_source'] = {
|
|
|
440
449
|
Blockly.JavaScript['on_source'] = function(block) {
|
|
441
450
|
let attr = block.getFieldValue('ATTR');
|
|
442
451
|
const parts = attr.split('.');
|
|
452
|
+
|
|
443
453
|
if (parts.length > 1) {
|
|
444
454
|
attr = '(obj.' + parts[0] + ' ? obj.' + attr + ' : "")';
|
|
445
455
|
} else {
|
|
446
456
|
attr = 'obj.' + attr;
|
|
447
457
|
}
|
|
458
|
+
|
|
448
459
|
return [attr, Blockly.JavaScript.ORDER_ATOMIC];
|
|
449
460
|
};
|
|
450
461
|
|
|
@@ -452,9 +463,6 @@ Blockly.JavaScript['on_source'] = function(block) {
|
|
|
452
463
|
Blockly.Trigger.blocks['schedule'] =
|
|
453
464
|
'<block type="schedule">'
|
|
454
465
|
+ ' <value name="SCHEDULE">'
|
|
455
|
-
//+ ' <shadow type="text">'
|
|
456
|
-
//+ ' <field name="TEXT">test</field>'
|
|
457
|
-
//+ ' </shadow>'
|
|
458
466
|
+ ' </value>'
|
|
459
467
|
+ ' <value name="STATEMENT">'
|
|
460
468
|
+ ' </value>'
|
|
@@ -481,15 +489,16 @@ Blockly.Blocks['schedule'] = {
|
|
|
481
489
|
};
|
|
482
490
|
Blockly.JavaScript['schedule'] = function(block) {
|
|
483
491
|
let schedule = block.getFieldValue('SCHEDULE');
|
|
484
|
-
const
|
|
492
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
485
493
|
|
|
486
494
|
if (schedule[0] === '{') {
|
|
487
495
|
schedule = "'" + schedule + "'";
|
|
488
496
|
} else {
|
|
489
497
|
schedule = '"' + schedule + '"';
|
|
490
498
|
}
|
|
491
|
-
|
|
492
|
-
|
|
499
|
+
|
|
500
|
+
return `schedule(${schedule}, async () => {\n` +
|
|
501
|
+
statement +
|
|
493
502
|
'});\n';
|
|
494
503
|
};
|
|
495
504
|
|
|
@@ -552,11 +561,11 @@ Blockly.Blocks['astro'] = {
|
|
|
552
561
|
};
|
|
553
562
|
Blockly.JavaScript['astro'] = function(block) {
|
|
554
563
|
const astrotype = block.getFieldValue('TYPE');
|
|
555
|
-
const offset
|
|
556
|
-
const
|
|
564
|
+
const offset = parseInt(block.getFieldValue('OFFSET'), 10);
|
|
565
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
557
566
|
|
|
558
|
-
return
|
|
559
|
-
|
|
567
|
+
return `schedule({ astro: '${astrotype}', shift: ${offset} }, async () => {\n` +
|
|
568
|
+
statement +
|
|
560
569
|
'});\n';
|
|
561
570
|
};
|
|
562
571
|
|
|
@@ -669,17 +678,17 @@ Blockly.Blocks['schedule_create'] = {
|
|
|
669
678
|
},
|
|
670
679
|
getVarModels: function () {
|
|
671
680
|
const name = this.getFieldValue('NAME');
|
|
672
|
-
return [{getId:
|
|
681
|
+
return [{ getId: () => { return name; }, name: name, type: 'cron' }];
|
|
673
682
|
}
|
|
674
683
|
};
|
|
675
684
|
|
|
676
685
|
Blockly.JavaScript['schedule_create'] = function (block) {
|
|
677
686
|
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
678
687
|
const schedule = Blockly.JavaScript.valueToCode(block, 'SCHEDULE', Blockly.JavaScript.ORDER_ATOMIC);
|
|
679
|
-
const
|
|
688
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
680
689
|
|
|
681
690
|
return name + ' = schedule(' + schedule + ', async () => {\n' +
|
|
682
|
-
|
|
691
|
+
statement +
|
|
683
692
|
'});\n';
|
|
684
693
|
};
|
|
685
694
|
|
|
@@ -734,7 +743,7 @@ Blockly.Blocks['schedule_clear'] = {
|
|
|
734
743
|
|
|
735
744
|
Blockly.JavaScript['schedule_clear'] = function(block) {
|
|
736
745
|
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
737
|
-
return
|
|
746
|
+
return `(function () { if (${name}) { clearSchedule(${name}); ${name} = null; }})();\n`;
|
|
738
747
|
};
|
|
739
748
|
|
|
740
749
|
// --- CRON dialog --------------------------------------------------
|
|
@@ -762,7 +771,7 @@ Blockly.Blocks['field_cron'] = {
|
|
|
762
771
|
|
|
763
772
|
Blockly.JavaScript['field_cron'] = function(block) {
|
|
764
773
|
const cron = block.getFieldValue('CRON');
|
|
765
|
-
return ['
|
|
774
|
+
return [`'${cron}'`, Blockly.JavaScript.ORDER_ATOMIC]
|
|
766
775
|
};
|
|
767
776
|
|
|
768
777
|
// --- CRON builder --------------------------------------------------
|
|
@@ -801,6 +810,7 @@ Blockly.Blocks['cron_builder'] = {
|
|
|
801
810
|
.appendField(Blockly.Translate('cron_builder_dow'));
|
|
802
811
|
|
|
803
812
|
const wp = this.workspace;
|
|
813
|
+
|
|
804
814
|
setTimeout(function (_input) {
|
|
805
815
|
if (!_input.connection.isConnected()) {
|
|
806
816
|
const _shadow = wp.newBlock('text');
|
|
@@ -810,9 +820,9 @@ Blockly.Blocks['cron_builder'] = {
|
|
|
810
820
|
}
|
|
811
821
|
}, 100, _input);
|
|
812
822
|
|
|
813
|
-
|
|
814
823
|
_input = this.appendValueInput('MONTHS')
|
|
815
824
|
.appendField(Blockly.Translate('cron_builder_month'));
|
|
825
|
+
|
|
816
826
|
setTimeout(function (_input) {
|
|
817
827
|
if (!_input.connection.isConnected()) {
|
|
818
828
|
const _shadow = wp.newBlock('text');
|
|
@@ -824,6 +834,7 @@ Blockly.Blocks['cron_builder'] = {
|
|
|
824
834
|
|
|
825
835
|
_input = this.appendValueInput('DAYS')
|
|
826
836
|
.appendField(Blockly.Translate('cron_builder_day'));
|
|
837
|
+
|
|
827
838
|
setTimeout(function (_input) {
|
|
828
839
|
if (!_input.connection.isConnected()) {
|
|
829
840
|
const _shadow = wp.newBlock('text');
|
|
@@ -835,6 +846,7 @@ Blockly.Blocks['cron_builder'] = {
|
|
|
835
846
|
|
|
836
847
|
_input = this.appendValueInput('HOURS')
|
|
837
848
|
.appendField(Blockly.Translate('cron_builder_hour'));
|
|
849
|
+
|
|
838
850
|
setTimeout(function (_input) {
|
|
839
851
|
if (!_input.connection.isConnected()) {
|
|
840
852
|
const _shadow = wp.newBlock('text');
|
|
@@ -846,6 +858,7 @@ Blockly.Blocks['cron_builder'] = {
|
|
|
846
858
|
|
|
847
859
|
_input = this.appendValueInput('MINUTES')
|
|
848
860
|
.appendField(Blockly.Translate('cron_builder_minutes'));
|
|
861
|
+
|
|
849
862
|
setTimeout(function (_input) {
|
|
850
863
|
if (!_input.connection.isConnected()) {
|
|
851
864
|
const _shadow = wp.newBlock('text');
|
|
@@ -878,6 +891,7 @@ Blockly.Blocks['cron_builder'] = {
|
|
|
878
891
|
const container = document.createElement('mutation');
|
|
879
892
|
container.setAttribute('seconds', this.seconds_);
|
|
880
893
|
container.setAttribute('as_line', this.as_line_);
|
|
894
|
+
|
|
881
895
|
return container;
|
|
882
896
|
},
|
|
883
897
|
/**
|
|
@@ -930,11 +944,12 @@ Blockly.JavaScript['cron_builder'] = function(block) {
|
|
|
930
944
|
const code =
|
|
931
945
|
(withSeconds === 'TRUE' || withSeconds === 'true' || withSeconds === true ?
|
|
932
946
|
seconds + '.toString().trim() + \' \' + ' : '') +
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
947
|
+
minutes + '.toString().trim() + \' \' + ' +
|
|
948
|
+
hours + '.toString().trim() + \' \' + ' +
|
|
949
|
+
days + '.toString().trim() + \' \' + ' +
|
|
950
|
+
months + '.toString().trim() + \' \' + ' +
|
|
951
|
+
dow + '.toString().trim()';
|
|
952
|
+
|
|
938
953
|
return [code, Blockly.JavaScript.ORDER_ATOMIC]
|
|
939
954
|
};
|
|
940
955
|
|
|
@@ -972,10 +987,10 @@ Blockly.Blocks['onMessage'] = {
|
|
|
972
987
|
|
|
973
988
|
Blockly.JavaScript['onMessage'] = function (block) {
|
|
974
989
|
const message = block.getFieldValue('MESSAGE');
|
|
975
|
-
const
|
|
990
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
976
991
|
|
|
977
|
-
return
|
|
978
|
-
|
|
992
|
+
return `onMessage('${message}', async (data) => {\n` +
|
|
993
|
+
statement +
|
|
979
994
|
'});\n';
|
|
980
995
|
};
|
|
981
996
|
|
|
@@ -1023,16 +1038,18 @@ Blockly.Blocks['onFile'] = {
|
|
|
1023
1038
|
this.setHelpUrl(getHelp('onFile_help'));
|
|
1024
1039
|
}
|
|
1025
1040
|
};
|
|
1041
|
+
|
|
1026
1042
|
Blockly.JavaScript['onFile'] = function (block) {
|
|
1027
1043
|
const value_objectid = Blockly.JavaScript.valueToCode(block, 'OID', Blockly.JavaScript.ORDER_ATOMIC);
|
|
1028
1044
|
const file = Blockly.JavaScript.valueToCode(block, 'FILE', Blockly.JavaScript.ORDER_ATOMIC);
|
|
1029
1045
|
const withFile = block.getFieldValue('WITH_FILE');
|
|
1030
|
-
const
|
|
1031
|
-
const
|
|
1046
|
+
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
1047
|
+
const objectName = main.objects[value_objectid] && main.objects[value_objectid].common && main.objects[value_objectid].common.name ? main.objects[value_objectid].common.name : '';
|
|
1032
1048
|
|
|
1033
|
-
return
|
|
1034
|
-
|
|
1035
|
-
|
|
1049
|
+
return `onFile(${value_objectid}${objectName ? ` /* ${objectName} */` : ''}, ${file}, ${withFile === 'TRUE' ? 'true' : 'false'}, ` +
|
|
1050
|
+
'async (id, fileName, size, data, mimeType) => {\n' +
|
|
1051
|
+
statement +
|
|
1052
|
+
'});\n';
|
|
1036
1053
|
};
|
|
1037
1054
|
|
|
1038
1055
|
// --- onFile -----------------------------------------------------------
|
|
@@ -1067,10 +1084,11 @@ Blockly.Blocks['offFile'] = {
|
|
|
1067
1084
|
this.setHelpUrl(getHelp('offFile_help'));
|
|
1068
1085
|
}
|
|
1069
1086
|
};
|
|
1087
|
+
|
|
1070
1088
|
Blockly.JavaScript['offFile'] = function (block) {
|
|
1071
1089
|
const value_objectid = Blockly.JavaScript.valueToCode(block, 'OID', Blockly.JavaScript.ORDER_ATOMIC);
|
|
1072
1090
|
const file = Blockly.JavaScript.valueToCode(block, 'FILE', Blockly.JavaScript.ORDER_ATOMIC);
|
|
1073
|
-
const
|
|
1091
|
+
const objectName = main.objects[value_objectid] && main.objects[value_objectid].common && main.objects[value_objectid].common.name ? main.objects[value_objectid].common.name : '';
|
|
1074
1092
|
|
|
1075
|
-
return
|
|
1076
|
-
};
|
|
1093
|
+
return `offFile(${value_objectid}${objectName ? ` /* ${objectName} */` : ''}, ${file});\n`;
|
|
1094
|
+
};
|
|
@@ -412,9 +412,9 @@ Blockly.Words['logic_switch_case'] = {'en': 'Switch / case',
|
|
|
412
412
|
Blockly.Words['logic_switch_case_is'] = {'en': 'the case is', 'de': 'der Fall ist', 'ru': 'условие', 'pt': 'o caso é', 'nl': 'het geval is', 'fr': 'le cas est', 'it': 'il caso è', 'es': 'el caso es', 'pl': 'sprawa jest', 'zh-cn': '情况是', 'uk': 'справа є'};
|
|
413
413
|
Blockly.Words['logic_switch_case_of'] = {'en': 'in case of', 'de': 'im Falle von', 'ru': 'в случае', 'pt': 'no caso de', 'nl': 'in het geval van', 'fr': 'en cas de', 'it': 'in caso di', 'es': 'en caso de', 'pl': 'w przypadku', 'zh-cn': '的情况下', 'uk': 'в випадку'};
|
|
414
414
|
Blockly.Words['logic_switch_do'] = {'en': 'do', 'de': 'machen', 'ru': 'выполнить', 'pt': 'Faz', 'nl': 'Doen', 'fr': 'faire', 'it': 'fare', 'es': 'hacer', 'pl': 'zrobić', 'zh-cn': '做', 'uk': 'робити'};
|
|
415
|
-
Blockly.Words['
|
|
416
|
-
Blockly.Words['
|
|
417
|
-
Blockly.Words['
|
|
415
|
+
Blockly.Words['logic_switch_tooltip'] = {'en': 'Does something if the condition is true. If there isn\'t a matching case the default function will be executed.', 'de': 'Tut etwas, wenn die Bedingung erfüllt ist. Wenn es keinen passenden Fall gibt, wird die Standardfunktion ausgeführt.', 'ru': 'Делает что-то, если условие выполняется. Если совпадения не найдено, будет выполнена функция по умолчанию.', 'pt': 'Faz alguma coisa se a condição for verdadeira. Se não houver um caso correspondente, a função padrão será executada.', 'nl': 'Doet iets als de voorwaarde waar is. Als er geen overeenkomende case is, wordt de standaardfunctie uitgevoerd.', 'fr': 'Fait quelque chose si la condition est vraie. S\'il n\'y a pas de cas correspondant, la fonction par défaut sera exécutée.', 'it': 'Fa qualcosa se la condizione è vera. Se non esiste un caso corrispondente, verrà eseguita la funzione predefinita.', 'es': 'Hace algo si la condición es verdadera. Si no hay un caso coincidente, se ejecutará la función predeterminada.', 'pl': 'Robi coś, jeśli warunek jest spełniony. Jeśli nie ma pasującego przypadku, zostanie wykonana funkcja domyślna.', 'zh-cn': '如果条件为真,则执行某些操作。如果没有匹配的情况,将执行默认功能。', 'uk': 'Робить щось, якщо умова істинна. Якщо відповідного регістру немає, буде виконано функцію за замовчуванням.'};
|
|
416
|
+
Blockly.Words['logic_switch_default_tooltip'] = {'en': 'This function will run if there aren\'t any matching cases.', 'de': 'Diese Funktion wird ausgeführt, wenn keine übereinstimmenden Fälle vorliegen.', 'ru': 'Эта функция будет запущена, если нет соответствующих случаев.', 'pt': 'Esta função será executada se não houver casos correspondentes.', 'nl': 'Deze functie wordt uitgevoerd als er geen overeenkomende gevallen zijn.', 'fr': 'Cette fonction s\'exécutera s\'il n\'y a pas de cas correspondants.', 'it': 'Questa funzione verrà eseguita se non ci sono casi corrispondenti.', 'es': 'Esta función se ejecutará si no hay casos coincidentes.', 'pl': 'Ta funkcja będzie działać, jeśli nie ma pasujących przypadków.', 'zh-cn': '如果没有匹配的情况,此功能将运行。', 'uk': 'Ця функція запуститься, якщо немає відповідних регістрів.'};
|
|
417
|
+
Blockly.Words['logic_switch_control_case_tooltip'] = {'en': 'This is a variable for condition.', 'de': 'Dies ist eine Variable für die Bedingung.', 'ru': 'Это переменная для условия.', 'pt': 'Esta é uma variável para a condição.', 'nl': 'Dit is een variabele voor conditie.', 'fr': 'Il s\'agit d\'une variable de condition.', 'it': 'Questa è una variabile per condizione.', 'es': 'Esta es una variable para la condición.', 'pl': 'Jest to zmienna warunku.', 'zh-cn': '这是用于条件的变量。', 'uk': 'Це змінна умови.'};
|
|
418
418
|
|
|
419
419
|
// --- trigger onFile --------------------------------------------------
|
|
420
420
|
Blockly.Words['onFile'] = {'en': 'Event: file update', 'de': 'Ereignis: Datei geändert', 'ru': 'Событие: файл обновлён', 'pt': 'Evento: se arquivo', 'nl': 'Gebeurtenis: als bestand', 'fr': 'Evénement : si fichier', 'it': 'Evento: se file', 'es': 'Evento: si el archivo', 'pl': 'Zdarzenie: jeśli plik', 'zh-cn': '事件:如果文件', 'uk': 'Подія: оновлення файлу'};
|