Skip to content

Commit

Permalink
### 4.6.12 (2020-05-19)
Browse files Browse the repository at this point in the history
* (bluefox) Fixed blockly blocks because of deprecated functions
* (bluefox) Corrected schedule wizard
  • Loading branch information
GermanBluefox committed May 19, 2020
1 parent 9bc896a commit b8beec2
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 46 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

Executes Javascript, Typescript and Coffescript Scripts.

**Coffescript is deprecated**

[Function documentation](docs/en/javascript.md)

[Benutzung](docs/de/usage.md)
Expand All @@ -33,7 +35,7 @@ And then call "npm run build".
- ...

## Changelog
### 4.6.11 (2020-05-16)
### 4.6.12 (2020-05-19)
* (bluefox) Fixed blockly blocks because of deprecated functions
* (bluefox) Corrected schedule wizard

Expand Down
4 changes: 2 additions & 2 deletions admin/google-blockly/own/blocks_timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Blockly.Blocks['timeouts_settimeout'] = {
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name;}, type: 'timeout', name: name}];
return [{getId: function () {return name;}, name: name, type: 'timeout'}];
}
};

Expand Down Expand Up @@ -251,7 +251,7 @@ Blockly.Blocks['timeouts_setinterval'] = {
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name;}, type: 'interval', name: name}];
return [{getId: function () {return name;}, name: name, type: 'interval'}];
}
};

Expand Down
14 changes: 12 additions & 2 deletions admin/google-blockly/own/blocks_trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ Blockly.Blocks['schedule_create'] = {
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name}, name: name}];
return [{getId: function () {return name;}, name: name, type: 'cron'}];
}
};

Expand All @@ -672,7 +672,17 @@ Blockly.Trigger.getAllSchedules = function (workspace) {
result.push([blocks[i].getFieldValue('NAME'), blocks[i].getFieldValue('NAME')]);
}
}
if (!result.length) result.push(['', '']);

// BF(2020.05.16) : for back compatibility. Remove it after 5 years
if (window.scripts.loading) {
var variables = workspace.getVariablesOfType('');
variables.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));
}

var variables1 = workspace.getVariablesOfType('cron');
variables1.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));

!result.length && result.push(['', '']);

return result;
};
Expand Down
27 changes: 2 additions & 25 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "javascript",
"version": "4.6.11",
"version": "4.6.12",
"title": "Script Engine",
"titleLang": {
"en": "Script Engine",
Expand All @@ -22,7 +22,7 @@
"AlCalzone"
],
"news": {
"4.6.11": {
"4.6.12": {
"en": "Fixed blockly blocks because of deprecated functions",
"de": "Blockierte Blöcke wegen veralteter Funktionen behoben",
"ru": "Исправлены блочные блоки из-за устаревших функций",
Expand Down Expand Up @@ -130,29 +130,6 @@
"pl": "Dostosowano adapter do kontrolera js> = 2.2.x",
"zh-cn": "使适配器与js-controller> = 2.2.x兼容"
},
"4.3.5": {
"en": "fixed the load of zip files if more than one host",
"de": "Das Laden von ZIP-Dateien wurde behoben, wenn mehr als ein Host vorhanden war",
"ru": "исправлена загрузка zip-файлов, если несколько хостов",
"pt": "Corrigido o carregamento de arquivos zip se mais de um host",
"nl": "de belasting van zip-bestanden gerepareerd als meer dan één host",
"fr": "correction de la charge des fichiers zip si plusieurs hôtes",
"it": "corretto il caricamento dei file zip se più di un host",
"es": "reparó la carga de archivos zip si hay más de un host",
"pl": "naprawiono ładowanie plików zip, jeśli więcej niż jeden host",
"zh-cn": "如果一台以上的主机修复了zip文件的加载"
},
"3.7.0": {
"en": "Used VM2 as sandbox. The script errors will be caught.\nrefactoring: split into many modules",
"de": "Verwendete VM2 als Sandbox. Die Skriptfehler werden abgefangen.\nRefactoring: Aufteilung in viele Module",
"ru": "Используется VM2 как песочница. Ошибки скрипта будут обнаружены.\nрефакторинг: разделение на многие модули",
"pt": "Usado VM2 como sandbox. Os erros de script serão capturados.\nrefatoração: dividida em vários módulos",
"nl": "Gebruikte VM2 als sandbox. De scriptfouten worden gepakt.\nrefactoring: opgesplitst in vele modules",
"fr": "VM2 utilisé comme bac à sable. Les erreurs de script seront interceptées.\nrefactoring: divisé en plusieurs modules",
"it": "Usato VM2 come sandbox. Gli errori di script verranno catturati.\nrefactoring: suddiviso in molti moduli",
"es": "Usó VM2 como sandbox. Los errores de script serán capturados.\nrefactorización: dividida en muchos módulos",
"pl": "Używany VM2 jako sandbox. Błędy skryptu zostaną przechwycone.\nrefaktoryzacja: podzielona na wiele modułów"
}
},
"desc": {
"en": "Javascript/Blockly Script Engine for ioBroker",
Expand Down
16 changes: 9 additions & 7 deletions lib/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,12 @@ function sandBox(script, name, verbose, debug, context) {
language = 'de';
}
}
if(typeof date == 'number') date = new Date(date);
if (typeof date == 'number') {
date = new Date(date);
} else if (!(date instanceof Date)) {
sandbox.log('Invalid date object provided: ' + JSON.stringify(date), 'error');
return 'Invalid date';
}
const d = date.getDay();
text = text.replace('НН', consts.dayOfWeeksFull[language][d]);
let initialText = text;
Expand Down Expand Up @@ -2419,16 +2424,13 @@ function sandBox(script, name, verbose, debug, context) {
}

if (typeof callback !== 'function') {
adapter.log.error('No callback found!');
return;
return adapter.log.error('No callback found!');
}
if (!isObject(options)) {
adapter.log.error('No options found!');
return;
return adapter.log.error('No options found!');
}
if (!options.id) {
adapter.log.error('No ID found!');
return;
return adapter.log.error('No ID found!');
}
const timeoutMs = parseInt(options.timeout, 10) || 20000;

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.javascript",
"version": "4.6.11",
"version": "4.6.12",
"description": "Javascript/Coffescript Script Engine for ioBroker",
"author": "bluefox <[email protected]>",
"contributors": [
Expand Down
4 changes: 2 additions & 2 deletions src/public/google-blockly/own/blocks_timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Blockly.Blocks['timeouts_settimeout'] = {
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name;}, type: 'timeout', name: name}];
return [{getId: function () {return name;}, name: name, type: 'timeout'}];
}
};

Expand Down Expand Up @@ -251,7 +251,7 @@ Blockly.Blocks['timeouts_setinterval'] = {
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name;}, type: 'interval', name: name}];
return [{getId: function () {return name;}, name: name, type: 'interval'}];
}
};

Expand Down
14 changes: 12 additions & 2 deletions src/public/google-blockly/own/blocks_trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ Blockly.Blocks['schedule_create'] = {
},
getVarModels: function () {
var name = this.getFieldValue('NAME');
return [{getId: function () {return name}, name: name}];
return [{getId: function () {return name;}, name: name, type: 'cron'}];
}
};

Expand All @@ -672,7 +672,17 @@ Blockly.Trigger.getAllSchedules = function (workspace) {
result.push([blocks[i].getFieldValue('NAME'), blocks[i].getFieldValue('NAME')]);
}
}
if (!result.length) result.push(['', '']);

// BF(2020.05.16): for back compatibility. Remove it after 5 years
if (window.scripts.loading) {
var variables = workspace.getVariablesOfType('');
variables.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));
}

var variables1 = workspace.getVariablesOfType('cron');
variables1.forEach(v => !result.find(it => it[0] === v.name) && result.push([v.name, v.name]));

!result.length && result.push(['', '']);

return result;
};
Expand Down

0 comments on commit b8beec2

Please sign in to comment.