iobroker.javascript 7.0.7 → 7.0.8
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_compressed.js +1469 -1704
- package/admin/google-blockly/blocks_compressed.js +164 -218
- package/admin/google-blockly/javascript_compressed.js +100 -328
- package/admin/google-blockly/msg/js/de.js +64 -70
- package/admin/google-blockly/msg/js/en.js +14 -20
- package/admin/google-blockly/msg/js/es.js +39 -45
- package/admin/google-blockly/msg/js/fr.js +59 -65
- package/admin/google-blockly/msg/js/it.js +19 -25
- package/admin/google-blockly/msg/js/nl.js +55 -61
- package/admin/google-blockly/msg/js/pl.js +46 -52
- package/admin/google-blockly/msg/js/pt.js +30 -36
- package/admin/google-blockly/msg/js/ru.js +41 -47
- package/admin/google-blockly/msg/js/uk.js +13 -17
- package/admin/google-blockly/msg/js/zh-cn.js +86 -92
- package/admin/google-blockly/own/blocks_action.js +4 -4
- package/admin/google-blockly/own/blocks_other.js +103 -0
- package/admin/google-blockly/own/blocks_procedures.js +63 -62
- package/admin/google-blockly/own/blocks_sendto.js +62 -60
- package/admin/google-blockly/own/blocks_switch.js +40 -29
- package/admin/google-blockly/own/blocks_system.js +113 -170
- package/admin/google-blockly/own/blocks_time.js +35 -35
- package/admin/google-blockly/own/blocks_timeout.js +42 -42
- package/admin/google-blockly/own/blocks_trigger.js +51 -68
- package/admin/google-blockly/own/blocks_words.js +8 -9
- package/admin/google-blockly/own/field_cron.js +189 -139
- package/admin/google-blockly/own/field_oid.js +250 -170
- package/admin/google-blockly/own/field_script.js +168 -122
- package/admin/static/js/98.bf3dfa2b.chunk.js +2 -0
- package/admin/static/js/98.bf3dfa2b.chunk.js.map +1 -0
- package/admin/static/js/{main.d86fb9de.js → main.d9e7d255.js} +2 -2
- package/admin/static/js/{main.d86fb9de.js.map → main.d9e7d255.js.map} +1 -1
- package/admin/tab.html +1 -1
- package/io-package.json +14 -14
- package/package.json +1 -1
- package/admin/google-blockly/own/blocks_logic.js +0 -64
- package/admin/google-blockly/own/blocks_number.js +0 -25
- package/admin/google-blockly/own/blocks_text.js +0 -23
- package/admin/static/js/98.f78be4fc.chunk.js +0 -2
- package/admin/static/js/98.f78be4fc.chunk.js.map +0 -1
|
@@ -83,16 +83,16 @@ Blockly.Blocks['time_compare_ex'] = {
|
|
|
83
83
|
this.setHelpUrl(Blockly.Translate('time_compare_ex_help'));
|
|
84
84
|
},
|
|
85
85
|
mutationToDom: function() {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
const container = document.createElement('mutation');
|
|
87
|
+
const option = this.getFieldValue('OPTION');
|
|
88
|
+
const use_actual_time = this.getFieldValue('USE_ACTUAL_TIME');
|
|
89
89
|
container.setAttribute('end_time', option === 'between' || option === 'not between' ? 'true' : 'false');
|
|
90
90
|
container.setAttribute('actual_time', use_actual_time === 'TRUE' || use_actual_time === 'true' || use_actual_time === true ? 'true' : 'false');
|
|
91
91
|
return container;
|
|
92
92
|
},
|
|
93
93
|
domToMutation: function(xmlElement) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const end_time = xmlElement.getAttribute('end_time');
|
|
95
|
+
const actual_time = xmlElement.getAttribute('actual_time');
|
|
96
96
|
this.updateShape_(end_time === true || end_time === 'true' || end_time === 'TRUE', actual_time === true || actual_time === 'true' || actual_time === 'TRUE');
|
|
97
97
|
},
|
|
98
98
|
updateShape_: function(isBetween, useActualTime) {
|
|
@@ -100,7 +100,7 @@ Blockly.Blocks['time_compare_ex'] = {
|
|
|
100
100
|
isBetween = this.getFieldValue('OPTION') === 'between' || this.getFieldValue('OPTION') === 'not between';
|
|
101
101
|
}
|
|
102
102
|
// Add or remove a delay Input.
|
|
103
|
-
|
|
103
|
+
let inputExists = this.getInput('END_TIME');
|
|
104
104
|
|
|
105
105
|
if (isBetween) {
|
|
106
106
|
if (!inputExists) {
|
|
@@ -114,14 +114,14 @@ Blockly.Blocks['time_compare_ex'] = {
|
|
|
114
114
|
this.appendDummyInput('AND')
|
|
115
115
|
.appendField(Blockly.Translate('time_compare_and'));
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
const input = this.appendValueInput('END_TIME');
|
|
118
118
|
|
|
119
119
|
if (!window.scripts.loading) {
|
|
120
|
-
|
|
120
|
+
const wp = this.workspace;
|
|
121
121
|
|
|
122
122
|
setTimeout(function () {
|
|
123
123
|
if (!input.connection.isConnected()) {
|
|
124
|
-
|
|
124
|
+
const shadow = wp.newBlock('text');
|
|
125
125
|
shadow.setShadow(true);
|
|
126
126
|
shadow.setFieldValue('18:00', 'TEXT');
|
|
127
127
|
|
|
@@ -163,12 +163,12 @@ Blockly.Blocks['time_compare_ex'] = {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
Blockly.JavaScript['time_compare_ex'] = function(block) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
const option = block.getFieldValue('OPTION');
|
|
167
|
+
const start_time = Blockly.JavaScript.valueToCode(block, 'START_TIME', Blockly.JavaScript.ORDER_ATOMIC);
|
|
168
|
+
let end_time = Blockly.JavaScript.valueToCode(block, 'END_TIME', Blockly.JavaScript.ORDER_ATOMIC);
|
|
169
|
+
let time = Blockly.JavaScript.valueToCode(block, 'CUSTOM_TIME', Blockly.JavaScript.ORDER_ATOMIC);
|
|
170
|
+
end_time = end_time || null;
|
|
171
|
+
time = time || null;
|
|
172
172
|
return ['compareTime(' + start_time + ', ' + end_time + ', "' + option + '", ' + time + ')', Blockly.JavaScript.ORDER_ATOMIC];
|
|
173
173
|
};
|
|
174
174
|
|
|
@@ -221,18 +221,18 @@ Blockly.Blocks['time_compare'] = {
|
|
|
221
221
|
},
|
|
222
222
|
|
|
223
223
|
mutationToDom: function() {
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
const container = document.createElement('mutation');
|
|
225
|
+
const option = this.getFieldValue('OPTION');
|
|
226
226
|
container.setAttribute('end_time', (option === 'between' || option === 'not between') ? 'true' : 'false');
|
|
227
227
|
return container;
|
|
228
228
|
},
|
|
229
229
|
domToMutation: function(xmlElement) {
|
|
230
|
-
|
|
230
|
+
const option = xmlElement.getAttribute('end_time');
|
|
231
231
|
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
|
|
232
232
|
},
|
|
233
233
|
updateShape_: function(isBetween) {
|
|
234
234
|
// Add or remove a delay Input.
|
|
235
|
-
|
|
235
|
+
const inputExists = this.getInput('END_TIME');
|
|
236
236
|
|
|
237
237
|
if (isBetween) {
|
|
238
238
|
if (!inputExists) {
|
|
@@ -250,10 +250,10 @@ Blockly.Blocks['time_compare'] = {
|
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
Blockly.JavaScript['time_compare'] = function(block) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
const option = block.getFieldValue('OPTION');
|
|
254
|
+
const start_time = block.getFieldValue('START_TIME');
|
|
255
|
+
let end_time = block.getFieldValue('END_TIME');
|
|
256
|
+
end_time = end_time || null;
|
|
257
257
|
|
|
258
258
|
return ['compareTime("' + start_time + '", "' + end_time + '", "' + option + '")', Blockly.JavaScript.ORDER_ATOMIC];
|
|
259
259
|
};
|
|
@@ -342,20 +342,20 @@ Blockly.Blocks['time_get'] = {
|
|
|
342
342
|
this.setHelpUrl(Blockly.Translate('time_get_help'));
|
|
343
343
|
},
|
|
344
344
|
mutationToDom: function() {
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
const container = document.createElement('mutation');
|
|
346
|
+
const option = this.getFieldValue('OPTION');
|
|
347
347
|
container.setAttribute('format', option === 'custom' ? 'true' : 'false');
|
|
348
348
|
container.setAttribute('language', option === 'wdt' || option === 'wdts' || option === 'Mt' || option === 'Mts' ? 'true' : 'false');
|
|
349
349
|
return container;
|
|
350
350
|
},
|
|
351
351
|
domToMutation: function(xmlElement) {
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
const format = xmlElement.getAttribute('format');
|
|
353
|
+
const language = xmlElement.getAttribute('language');
|
|
354
354
|
this.updateShape_(format === true || format === 'true' || format === 'TRUE', language === true || language === 'true' || language === 'TRUE');
|
|
355
355
|
},
|
|
356
356
|
updateShape_: function(isFormat, isLanguage) {
|
|
357
357
|
// Add or remove a delay Input.
|
|
358
|
-
|
|
358
|
+
let inputExists = this.getInput('FORMAT');
|
|
359
359
|
|
|
360
360
|
if (isFormat) {
|
|
361
361
|
if (!inputExists) {
|
|
@@ -371,7 +371,7 @@ Blockly.Blocks['time_get'] = {
|
|
|
371
371
|
|
|
372
372
|
if (isLanguage) {
|
|
373
373
|
if (!inputExists) {
|
|
374
|
-
|
|
374
|
+
let languages;
|
|
375
375
|
if (systemLang === 'en') {
|
|
376
376
|
languages = [['in english', 'en'], ['auf deutsch', 'de'], ['на русском', 'ru']];
|
|
377
377
|
} else if (systemLang === 'de') {
|
|
@@ -391,11 +391,11 @@ Blockly.Blocks['time_get'] = {
|
|
|
391
391
|
};
|
|
392
392
|
|
|
393
393
|
Blockly.JavaScript['time_get'] = function(block) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
const option = block.getFieldValue('OPTION');
|
|
395
|
+
const format = block.getFieldValue('FORMAT');
|
|
396
|
+
const lang = block.getFieldValue('LANGUAGE');
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
let code;
|
|
399
399
|
if (option === 'object') {
|
|
400
400
|
code = '(new Date().getTime())';
|
|
401
401
|
} else if (option === 'ms') {
|
|
@@ -484,7 +484,7 @@ Blockly.Blocks['time_astro'] = {
|
|
|
484
484
|
};
|
|
485
485
|
|
|
486
486
|
Blockly.JavaScript['time_astro'] = function(block) {
|
|
487
|
-
|
|
488
|
-
|
|
487
|
+
const type = block.getFieldValue('TYPE');
|
|
488
|
+
const offset = parseFloat(block.getFieldValue('OFFSET'));
|
|
489
489
|
return ['getAstroDate("' + type + '", undefined, ' + offset + ')', Blockly.JavaScript.ORDER_ATOMIC];
|
|
490
490
|
};
|
|
@@ -33,7 +33,7 @@ Blockly.Timeouts.findLegalName = function(name, block) {
|
|
|
33
33
|
}
|
|
34
34
|
while (!Blockly.Timeouts.isLegalName_(name, block.workspace, block)) {
|
|
35
35
|
// Collision with another procedure.
|
|
36
|
-
|
|
36
|
+
const r = name.match(/^(.*?)(\d+)$/);
|
|
37
37
|
if (!r) {
|
|
38
38
|
name += '2';
|
|
39
39
|
} else {
|
|
@@ -54,14 +54,14 @@ Blockly.Timeouts.findLegalName = function(name, block) {
|
|
|
54
54
|
* @private
|
|
55
55
|
*/
|
|
56
56
|
Blockly.Timeouts.isLegalName_ = function(name, workspace, opt_exclude) {
|
|
57
|
-
|
|
57
|
+
const blocks = workspace.getAllBlocks();
|
|
58
58
|
// Iterate through every block and check the name.
|
|
59
|
-
for (
|
|
59
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
60
60
|
if (blocks[i] == opt_exclude) {
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
63
|
if (blocks[i].isTimeout_ || blocks[i].isInterval_) {
|
|
64
|
-
|
|
64
|
+
const blockName = blocks[i].getFieldValue('NAME');
|
|
65
65
|
if (Blockly.Names.equals(blockName, name)) {
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
@@ -113,8 +113,8 @@ Blockly.Blocks['timeouts_wait'] = {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
Blockly.JavaScript['timeouts_wait'] = function(block) {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
let delay = block.getFieldValue('DELAY');
|
|
117
|
+
const unit = block.getFieldValue('UNIT');
|
|
118
118
|
if (unit === 'min') {
|
|
119
119
|
delay *= 60000;
|
|
120
120
|
} else if (unit === 'sec') {
|
|
@@ -138,7 +138,7 @@ Blockly.Timeouts.blocks['timeouts_settimeout'] =
|
|
|
138
138
|
|
|
139
139
|
Blockly.Blocks['timeouts_settimeout'] = {
|
|
140
140
|
init: function() {
|
|
141
|
-
|
|
141
|
+
const nameField = new Blockly.FieldTextInput(
|
|
142
142
|
Blockly.Timeouts.findLegalName('timeout', this),
|
|
143
143
|
Blockly.Timeouts.rename);
|
|
144
144
|
|
|
@@ -171,21 +171,21 @@ Blockly.Blocks['timeouts_settimeout'] = {
|
|
|
171
171
|
return [this.getFieldValue('NAME')];
|
|
172
172
|
},
|
|
173
173
|
getVarModels: function () {
|
|
174
|
-
|
|
174
|
+
const name = this.getFieldValue('NAME');
|
|
175
175
|
return [{getId: function () {return name;}, name: name, type: 'timeout'}];
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
Blockly.JavaScript['timeouts_settimeout'] = function(block) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
let delay = block.getFieldValue('DELAY');
|
|
181
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
182
|
+
const unit = block.getFieldValue('UNIT');
|
|
183
183
|
if (unit === 'min') {
|
|
184
184
|
delay *= 60000;
|
|
185
185
|
} else if (unit === 'sec') {
|
|
186
186
|
delay *= 1000;
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
const statements_name = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
189
189
|
return name + ' = setTimeout(async function () {\n' +
|
|
190
190
|
Blockly.JavaScript.prefixLines(name + ' = null;', Blockly.JavaScript.INDENT) + '\n' +
|
|
191
191
|
statements_name +
|
|
@@ -208,7 +208,7 @@ Blockly.Timeouts.blocks['timeouts_settimeout_variable'] =
|
|
|
208
208
|
|
|
209
209
|
Blockly.Blocks['timeouts_settimeout_variable'] = {
|
|
210
210
|
init: function() {
|
|
211
|
-
|
|
211
|
+
const nameField = new Blockly.FieldTextInput(
|
|
212
212
|
Blockly.Timeouts.findLegalName('timeout', this),
|
|
213
213
|
Blockly.Timeouts.rename);
|
|
214
214
|
|
|
@@ -238,15 +238,15 @@ Blockly.Blocks['timeouts_settimeout_variable'] = {
|
|
|
238
238
|
return [this.getFieldValue('NAME')];
|
|
239
239
|
},
|
|
240
240
|
getVarModels: function () {
|
|
241
|
-
|
|
241
|
+
const name = this.getFieldValue('NAME');
|
|
242
242
|
return [{getId: function () {return name;}, name: name, type: 'timeout'}];
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
|
|
246
246
|
Blockly.JavaScript['timeouts_settimeout_variable'] = function(block) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
const delay = Blockly.JavaScript.valueToCode(block, 'DELAY_MS', Blockly.JavaScript.ORDER_ATOMIC);
|
|
248
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
249
|
+
const statements_name = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
250
250
|
|
|
251
251
|
return name + ' = setTimeout(async function () {\n' +
|
|
252
252
|
Blockly.JavaScript.prefixLines(name + ' = null;', Blockly.JavaScript.INDENT) + '\n' +
|
|
@@ -256,11 +256,11 @@ Blockly.JavaScript['timeouts_settimeout_variable'] = function(block) {
|
|
|
256
256
|
|
|
257
257
|
// --- clearTimeout -----------------------------------------------------------
|
|
258
258
|
Blockly.Timeouts.getAllTimeouts = function (workspace) {
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
const blocks = workspace.getAllBlocks();
|
|
260
|
+
const result = [];
|
|
261
261
|
|
|
262
262
|
// Iterate through every block and check the name.
|
|
263
|
-
for (
|
|
263
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
264
264
|
if (blocks[i].isTimeout_) {
|
|
265
265
|
result.push([blocks[i].getFieldValue('NAME'), blocks[i].getFieldValue('NAME')]);
|
|
266
266
|
}
|
|
@@ -268,11 +268,11 @@ Blockly.Timeouts.getAllTimeouts = function (workspace) {
|
|
|
268
268
|
|
|
269
269
|
// BF(2020.05.16) : for back compatibility. Remove it after 5 years
|
|
270
270
|
if (window.scripts.loading) {
|
|
271
|
-
|
|
271
|
+
const variables = workspace.getVariablesOfType('');
|
|
272
272
|
variables.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
const variables1 = workspace.getVariablesOfType('timeout');
|
|
276
276
|
variables1.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));
|
|
277
277
|
|
|
278
278
|
!result.length && result.push(['', '']);
|
|
@@ -304,7 +304,7 @@ Blockly.Blocks['timeouts_cleartimeout'] = {
|
|
|
304
304
|
};
|
|
305
305
|
|
|
306
306
|
Blockly.JavaScript['timeouts_cleartimeout'] = function(block) {
|
|
307
|
-
|
|
307
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
308
308
|
return '(function () { if (' + name + ') { clearTimeout(' + name + '); ' + name + ' = null; }})();\n';
|
|
309
309
|
};
|
|
310
310
|
|
|
@@ -332,7 +332,7 @@ Blockly.Blocks['timeouts_gettimeout'] = {
|
|
|
332
332
|
};
|
|
333
333
|
|
|
334
334
|
Blockly.JavaScript['timeouts_gettimeout'] = function(block) {
|
|
335
|
-
|
|
335
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
336
336
|
|
|
337
337
|
return [name, Blockly.JavaScript.ORDER_ATOMIC];;
|
|
338
338
|
};
|
|
@@ -352,7 +352,7 @@ Blockly.Timeouts.blocks['timeouts_setinterval'] =
|
|
|
352
352
|
|
|
353
353
|
Blockly.Blocks['timeouts_setinterval'] = {
|
|
354
354
|
init: function() {
|
|
355
|
-
|
|
355
|
+
const nameField = new Blockly.FieldTextInput(
|
|
356
356
|
Blockly.Timeouts.findLegalName(Blockly.Translate('timeouts_setinterval_name'), this),
|
|
357
357
|
Blockly.Timeouts.rename);
|
|
358
358
|
|
|
@@ -385,22 +385,22 @@ Blockly.Blocks['timeouts_setinterval'] = {
|
|
|
385
385
|
return [this.getFieldValue('NAME')];
|
|
386
386
|
},
|
|
387
387
|
getVarModels: function () {
|
|
388
|
-
|
|
388
|
+
const name = this.getFieldValue('NAME');
|
|
389
389
|
return [{getId: function () {return name;}, name: name, type: 'interval'}];
|
|
390
390
|
}
|
|
391
391
|
};
|
|
392
392
|
|
|
393
393
|
Blockly.JavaScript['timeouts_setinterval'] = function(block) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
let delay = block.getFieldValue('INTERVAL');
|
|
395
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
396
|
+
const unit = block.getFieldValue('UNIT');
|
|
397
397
|
if (unit === 'min') {
|
|
398
398
|
delay *= 60000;
|
|
399
399
|
} else if (unit === 'sec') {
|
|
400
400
|
delay *= 1000;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
|
|
403
|
+
const statements_name = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
404
404
|
|
|
405
405
|
return name + ' = setInterval(async function () {\n' +
|
|
406
406
|
statements_name +
|
|
@@ -423,7 +423,7 @@ Blockly.Timeouts.blocks['timeouts_setinterval_variable'] =
|
|
|
423
423
|
|
|
424
424
|
Blockly.Blocks['timeouts_setinterval_variable'] = {
|
|
425
425
|
init: function() {
|
|
426
|
-
|
|
426
|
+
const nameField = new Blockly.FieldTextInput(
|
|
427
427
|
Blockly.Timeouts.findLegalName(Blockly.Translate('timeouts_setinterval_name'), this),
|
|
428
428
|
Blockly.Timeouts.rename);
|
|
429
429
|
|
|
@@ -453,15 +453,15 @@ Blockly.Blocks['timeouts_setinterval_variable'] = {
|
|
|
453
453
|
return [this.getFieldValue('NAME')];
|
|
454
454
|
},
|
|
455
455
|
getVarModels: function () {
|
|
456
|
-
|
|
456
|
+
const name = this.getFieldValue('NAME');
|
|
457
457
|
return [{getId: function () {return name;}, name: name, type: 'interval'}];
|
|
458
458
|
}
|
|
459
459
|
};
|
|
460
460
|
|
|
461
461
|
Blockly.JavaScript['timeouts_setinterval_variable'] = function(block) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
462
|
+
const delay = Blockly.JavaScript.valueToCode(block, 'INTERVAL_MS', Blockly.JavaScript.ORDER_ATOMIC);
|
|
463
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
464
|
+
const statements_name = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
|
|
465
465
|
|
|
466
466
|
return name + ' = setInterval(async function () {\n' +
|
|
467
467
|
statements_name +
|
|
@@ -476,11 +476,11 @@ Blockly.Timeouts.blocks['timeouts_clearinterval'] =
|
|
|
476
476
|
+ '</block>';
|
|
477
477
|
|
|
478
478
|
Blockly.Timeouts.getAllIntervals = function (workspace) {
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
const blocks = workspace.getAllBlocks();
|
|
480
|
+
const result = [];
|
|
481
481
|
|
|
482
482
|
// Iterate through every block and check the name.
|
|
483
|
-
for (
|
|
483
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
484
484
|
if (blocks[i].isInterval_) {
|
|
485
485
|
result.push([blocks[i].getFieldValue('NAME'), blocks[i].getFieldValue('NAME')]);
|
|
486
486
|
}
|
|
@@ -488,11 +488,11 @@ Blockly.Timeouts.getAllIntervals = function (workspace) {
|
|
|
488
488
|
|
|
489
489
|
// BF(2020.05.16) : for back compatibility. Remove it after 5 years
|
|
490
490
|
if (window.scripts.loading) {
|
|
491
|
-
|
|
491
|
+
const variables = workspace.getVariablesOfType('');
|
|
492
492
|
variables.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
const variables1 = workspace.getVariablesOfType('interval');
|
|
496
496
|
variables1.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));
|
|
497
497
|
|
|
498
498
|
!result.length && result.push(['', '']);
|
|
@@ -518,7 +518,7 @@ Blockly.Blocks['timeouts_clearinterval'] = {
|
|
|
518
518
|
};
|
|
519
519
|
|
|
520
520
|
Blockly.JavaScript['timeouts_clearinterval'] = function(block) {
|
|
521
|
-
|
|
521
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
522
522
|
|
|
523
523
|
return '(function () { if (' + name + ') { clearInterval(' + name + '); ' + name + ' = null; }})();\n';
|
|
524
524
|
};
|
|
@@ -547,7 +547,7 @@ Blockly.Blocks['timeouts_getinterval'] = {
|
|
|
547
547
|
};
|
|
548
548
|
|
|
549
549
|
Blockly.JavaScript['timeouts_getinterval'] = function(block) {
|
|
550
|
-
|
|
550
|
+
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
|
|
551
551
|
|
|
552
552
|
return [name, Blockly.JavaScript.ORDER_ATOMIC];;
|
|
553
553
|
};
|