Skip to content

Commit

Permalink
### 4.6.5 (2020-05-16)
Browse files Browse the repository at this point in the history
* (bluefox) Fixed blockly blocks because of deprecated functions
  • Loading branch information
GermanBluefox committed May 15, 2020
1 parent 92c428c commit 88178b8
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 105 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ And then call "npm run build".
- ...

## Changelog
### 4.6.5 (2020-05-16)
* (bluefox) Fixed blockly blocks because of deprecated functions

### 4.6.4 (2020-05-15)
* (bluefox) Corrected block: request, exec
Expand Down
10 changes: 5 additions & 5 deletions admin/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"files": {
"main.css": "/static/css/main.ec63fb86.chunk.css",
"main.js": "/static/js/main.b4b5f2df.chunk.js",
"main.js.map": "/static/js/main.b4b5f2df.chunk.js.map",
"main.js": "/static/js/main.3c6b3448.chunk.js",
"main.js.map": "/static/js/main.3c6b3448.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.a500de04.js",
"runtime-main.js.map": "/static/js/runtime-main.a500de04.js.map",
"static/css/2.93e5c0a0.chunk.css": "/static/css/2.93e5c0a0.chunk.css",
"static/js/2.2e4ba0c3.chunk.js": "/static/js/2.2e4ba0c3.chunk.js",
"static/js/2.2e4ba0c3.chunk.js.map": "/static/js/2.2e4ba0c3.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.529e7bd99291585d441fb061e53a8478.js": "/precache-manifest.529e7bd99291585d441fb061e53a8478.js",
"precache-manifest.b3d257e35e338db06675b3fe51497924.js": "/precache-manifest.b3d257e35e338db06675b3fe51497924.js",
"service-worker.js": "/service-worker.js",
"static/css/2.93e5c0a0.chunk.css.map": "/static/css/2.93e5c0a0.chunk.css.map",
"static/css/main.ec63fb86.chunk.css.map": "/static/css/main.ec63fb86.chunk.css.map",
"static/js/2.2e4ba0c3.chunk.js.LICENSE.txt": "/static/js/2.2e4ba0c3.chunk.js.LICENSE.txt",
"static/js/main.b4b5f2df.chunk.js.LICENSE.txt": "/static/js/main.b4b5f2df.chunk.js.LICENSE.txt",
"static/js/main.3c6b3448.chunk.js.LICENSE.txt": "/static/js/main.3c6b3448.chunk.js.LICENSE.txt",
"static/media/copy-content.svg": "/static/media/copy-content.6fe0b363.svg"
},
"entrypoints": [
"static/js/runtime-main.a500de04.js",
"static/css/2.93e5c0a0.chunk.css",
"static/js/2.2e4ba0c3.chunk.js",
"static/css/main.ec63fb86.chunk.css",
"static/js/main.b4b5f2df.chunk.js"
"static/js/main.3c6b3448.chunk.js"
]
}
19 changes: 10 additions & 9 deletions admin/google-blockly/own/blocks_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Blockly.Blocks['exec'] = {
this.appendDummyInput('WITH_STATEMENT')
.appendField(Blockly.Translate('exec_statement'))
.appendField(new Blockly.FieldCheckbox('FALSE', function (option) {
var delayInput = option === true || option === 'true' || option === 'TRUE';
this.sourceBlock_.updateShape_(delayInput);
this.sourceBlock_.updateShape_(option === true || option === 'true' || option === 'TRUE');
}), 'WITH_STATEMENT');

this.appendDummyInput('LOG')
Expand All @@ -65,11 +64,13 @@ Blockly.Blocks['exec'] = {
},
mutationToDom: function() {
var container = document.createElement('mutation');
container.setAttribute('with_statement', this.getFieldValue('WITH_STATEMENT') === 'TRUE');
var option = this.getFieldValue('WITH_STATEMENT');
container.setAttribute('with_statement', option === true || option === 'true' || option === 'TRUE');
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('with_statement') === 'true');
var option = xmlElement.getAttribute('with_statement');
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
},
updateShape_: function(withStatement) {
// Add or remove a statement Input.
Expand Down Expand Up @@ -97,7 +98,7 @@ Blockly.JavaScript['exec'] = function(block) {
logText = '';
}

if (withStatement === 'TRUE') {
if (withStatement === 'TRUE' || withStatement === 'true' || withStatement === true) {
var statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
if (statement) {
return 'exec(' + value_command + ', function (error, result, stderr) {\n ' + statement + '});\n' +
Expand Down Expand Up @@ -138,8 +139,7 @@ Blockly.Blocks['request'] = {
this.appendDummyInput('WITH_STATEMENT')
.appendField(Blockly.Translate('request_statement'))
.appendField(new Blockly.FieldCheckbox('FALSE', function (option) {
var delayInput = option === true || option === 'true' || option === 'TRUE';
this.sourceBlock_.updateShape_(delayInput);
this.sourceBlock_.updateShape_(option === true || option === 'true' || option === 'TRUE');
}), 'WITH_STATEMENT');

this.appendDummyInput('LOG')
Expand All @@ -166,7 +166,8 @@ Blockly.Blocks['request'] = {
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('with_statement') == 'true');
var option = xmlElement.getAttribute('with_statement');
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
},
updateShape_: function(withStatement) {
// Add or remove a statement Input.
Expand Down Expand Up @@ -194,7 +195,7 @@ Blockly.JavaScript['request'] = function(block) {
logText = '';
}

if (withStatement === 'TRUE') {
if (withStatement === 'TRUE' || withStatement === 'true' || withStatement === true) {
var statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
if (statement) {
return 'try {\n require("request")(' + URL + ', function (error, response, result) {\n ' + statement + ' }).on("error", function (e) {console.error(e);});\n} catch (e) { console.error(e); }\n' +
Expand Down
9 changes: 6 additions & 3 deletions admin/google-blockly/own/blocks_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ Blockly.Blocks.convert_from_date = {
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('format') === 'true', xmlElement.getAttribute('language') === 'true');
var format = xmlElement.getAttribute('format');
var language = xmlElement.getAttribute('language');

this.updateShape_(format === true || format === 'true' || format === 'TRUE', language === true || language === 'true' || language === 'TRUE');
},
updateShape_: function(isFormat, isLanguage) {
// Add or remove a delay Input.
Expand Down Expand Up @@ -332,8 +335,8 @@ Blockly.Blocks.convert_object2json = {
};
Blockly.JavaScript.convert_object2json = function (block) {
var prettify = block.getFieldValue('PRETTIFY');

return ['JSON.stringify(' + Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC) + (prettify == 'TRUE' ? ', null, 2' : '') + ')', Blockly.JavaScript.ORDER_ATOMIC];
prettify = prettify === 'TRUE' || prettify === 'true' || prettify === true;
return ['JSON.stringify(' + Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC) + (prettify ? ', null, 2' : '') + ')', Blockly.JavaScript.ORDER_ATOMIC];
};

// --- to single value -------------------------------------------
Expand Down
60 changes: 39 additions & 21 deletions admin/google-blockly/own/blocks_system.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ Blockly.Blocks['control'] = {
this.appendDummyInput('WITH_DELAY')
.appendField(Blockly.Translate('control_delay'))
.appendField(new Blockly.FieldCheckbox('FALSE', function(option) {
var delayInput = (option == true);
this.sourceBlock_.updateShape_(delayInput);
this.sourceBlock_.updateShape_(option === true || option === 'true' || option === 'TRUE');
}), 'WITH_DELAY');


Expand All @@ -124,11 +123,13 @@ Blockly.Blocks['control'] = {
},
mutationToDom: function() {
var container = document.createElement('mutation');
container.setAttribute('delay_input', this.getFieldValue('WITH_DELAY') === 'TRUE');
var option = this.getFieldValue('WITH_DELAY');
container.setAttribute('delay_input', option === true || option === 'true' || option === 'TRUE');
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('delay_input') == 'true');
var option = xmlElement.getAttribute('delay_input');
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
},
updateShape_: function(delayInput) {
// Add or remove a delay Input.
Expand Down Expand Up @@ -176,12 +177,15 @@ Blockly.JavaScript['control'] = function(block) {
} else if (unit === 'sec') {
valueDelay *= 1000;
}
var clearRunning = block.getFieldValue('CLEAR_RUNNING') === 'TRUE';
var clearRunning = block.getFieldValue('CLEAR_RUNNING');
var valueValue = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC);
var objectName = main.objects[valueObjectID] && main.objects[valueObjectID].common && main.objects[valueObjectID].common.name ? main.objects[valueObjectID].common.name : '';
var code;

if (this.getFieldValue('WITH_DELAY') === 'TRUE') {
clearRunning = clearRunning === 'true' || clearRunning === true || clearRunning === 'true';
var withDelay = this.getFieldValue('WITH_DELAY');

if (withDelay === 'true' || withDelay === true || withDelay === 'TRUE') {
code = 'setStateDelayed("' + valueObjectID + '"' + (objectName ? '/*' + objectName + '*/' : '') + ', ' + valueValue + ', ' + valueDelay + ', ' + clearRunning + ');\n';
} else {
code = 'setState("' + valueObjectID + '"' + (objectName ? '/*' + objectName + '*/' : '') + ', ' + valueValue + ');\n';
Expand Down Expand Up @@ -217,8 +221,7 @@ Blockly.Blocks['toggle'] = {
this.appendDummyInput('WITH_DELAY')
.appendField(Blockly.Translate('toggle_delay'))
.appendField(new Blockly.FieldCheckbox('FALSE', function(option) {
var delayInput = (option == true);
this.sourceBlock_.updateShape_(delayInput);
this.sourceBlock_.updateShape_(option === true || option === 'true' || option === 'TRUE');
}), 'WITH_DELAY');

this.setInputsInline(true);
Expand All @@ -230,11 +233,13 @@ Blockly.Blocks['toggle'] = {
},
mutationToDom: function() {
var container = document.createElement('mutation');
container.setAttribute('delay_input', this.getFieldValue('WITH_DELAY') === 'TRUE');
var option = this.getFieldValue('WITH_DELAY');
container.setAttribute('delay_input', option === true || option === 'true' || option === 'TRUE');
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('delay_input') == 'true');
var option = xmlElement.getAttribute('delay_input');
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
},
updateShape_: function(delayInput) {
// Add or remove a delay Input.
Expand Down Expand Up @@ -282,11 +287,14 @@ Blockly.JavaScript['toggle'] = function(block) {
} else if (unit === 'sec') {
valueDelay *= 1000;
}
var clearRunning = block.getFieldValue('CLEAR_RUNNING') === 'TRUE';
var clearRunning = block.getFieldValue('CLEAR_RUNNING');
var objectName = main.objects[valueObjectID] && main.objects[valueObjectID].common && main.objects[valueObjectID].common.name ? main.objects[valueObjectID].common.name : '';
var objectType = main.objects[valueObjectID] && main.objects[valueObjectID].common && main.objects[valueObjectID].common.type ? main.objects[valueObjectID].common.type : 'boolean';
var code;
var setCommand;

clearRunning = clearRunning === 'TRUE' || clearRunning === 'true' || clearRunning === true;

if (objectType === 'number') {
var max = 100;
var min = 0;
Expand All @@ -300,8 +308,9 @@ Blockly.JavaScript['toggle'] = function(block) {
} else {
setCommand = ' setState("' + valueObjectID + '"' + (objectName ? '/*' + objectName + '*/' : '') + ', state ? !state.val : true);\n';
}
var withDelay = block.getFieldValue('WITH_DELAY');

if (this.getFieldValue('WITH_DELAY') === 'TRUE') {
if (withDelay === 'TRUE' || withDelay === 'true' || withDelay === true) {
code =
'getState("' + valueObjectID + '", function (err, state) {\n' +
' setStateDelayed("' + valueObjectID + '"' + (objectName ? '/*' + objectName + '*/' : '') + ', state ? !state.val : true, ' + valueDelay + ', ' + clearRunning + ');\n' +
Expand Down Expand Up @@ -350,7 +359,7 @@ Blockly.Blocks['update'] = {
this.appendDummyInput('WITH_DELAY')
.appendField(Blockly.Translate('update_delay'))
.appendField(new Blockly.FieldCheckbox('FALSE', function(option) {
this.sourceBlock_.updateShape_(option == true);
this.sourceBlock_.updateShape_(option === true || option === 'true' || option === 'TRUE');
}), 'WITH_DELAY');

this.setInputsInline(true);
Expand All @@ -362,11 +371,13 @@ Blockly.Blocks['update'] = {
},
mutationToDom: function() {
var container = document.createElement('mutation');
container.setAttribute('delay_input', this.getFieldValue('WITH_DELAY') === 'TRUE');
var option = this.getFieldValue('WITH_DELAY');
container.setAttribute('delay_input', option === true || option === 'true' || option === 'TRUE');
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('delay_input') == 'true');
var option = xmlElement.getAttribute('delay_input');
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
},
updateShape_: function(delayInput) {
// Add or remove a delay Input.
Expand Down Expand Up @@ -409,16 +420,21 @@ Blockly.JavaScript['update'] = function(block) {

var value_value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC);
var value_delay = parseInt(block.getFieldValue('DELAY_MS'), 10);
var clearRunning = block.getFieldValue('CLEAR_RUNNING') === 'TRUE';
var clearRunning = block.getFieldValue('CLEAR_RUNNING');
var unit = block.getFieldValue('UNIT');
if (unit === 'min') {
value_delay *= 60000;
} else if (unit === 'sec') {
value_delay *= 1000;
}

clearRunning = clearRunning === true || clearRunning === 'true' || clearRunning === 'TRUE';

var objectname = main.objects[value_objectid] && main.objects[value_objectid].common && main.objects[value_objectid].common.name ? main.objects[value_objectid].common.name : '';
var code;
if (this.getFieldValue('WITH_DELAY') === 'TRUE') {
var withDelay = this.getFieldValue('WITH_DELAY');

if (withDelay === true || withDelay === 'true' || withDelay === 'TRUE') {
code = 'setStateDelayed("' + value_objectid + '"' + (objectname ? '/*' + objectname + '*/' : '') + ', ' + value_value + ', true, ' + value_delay + ', ' + clearRunning + ');\n';
} else {
code = 'setState("' + value_objectid + '"' + (objectname ? '/*' + objectname + '*/' : '') + ', ' + value_value + ', true);\n';
Expand Down Expand Up @@ -473,8 +489,8 @@ Blockly.JavaScript['direct'] = function(block) {
var oidSrc = Blockly.JavaScript.valueToCode(block, 'OID_SRC', Blockly.JavaScript.ORDER_ATOMIC);
var onlyChanges = block.getFieldValue('ONLY_CHANGES');
var oidDest = Blockly.JavaScript.valueToCode(block, 'OID_DST', Blockly.JavaScript.ORDER_ATOMIC);

return 'on({id: ' + oidSrc + ', change: "' + (onlyChanges == 'TRUE' ? 'ne' : 'any') + '"}, function (obj) {\n setState(' + oidDest + ', obj.state.val);\n});';
onlyChanges = onlyChanges === true || onlyChanges === 'true' || onlyChanges === 'TRUE';
return 'on({id: ' + oidSrc + ', change: "' + (onlyChanges ? 'ne' : 'any') + '"}, function (obj) {\n setState(' + oidDest + ', obj.state.val);\n});';
};

// --- control ex -----------------------------------------------------------
Expand Down Expand Up @@ -541,8 +557,10 @@ Blockly.JavaScript['control_ex'] = function(block) {
var valueObjectID = Blockly.JavaScript.valueToCode(block, 'OID', Blockly.JavaScript.ORDER_ATOMIC);
var value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC);
var valueDelay = Blockly.JavaScript.valueToCode(block, 'DELAY_MS', Blockly.JavaScript.ORDER_ATOMIC);
var clearRunning = block.getFieldValue('CLEAR_RUNNING') === 'TRUE';
var type = block.getFieldValue('TYPE') === 'true';
var clearRunning = block.getFieldValue('CLEAR_RUNNING');
var type = block.getFieldValue('TYPE');
type = type === true || type === 'true' || type === 'TRUE';
clearRunning = clearRunning === true || clearRunning === 'true' || clearRunning === 'TRUE';
return 'setStateDelayed(' + valueObjectID + ', ' + value + ', ' + type + ', parseInt(' + valueDelay + ', 10), ' + clearRunning + ');\n';
};

Expand Down
20 changes: 13 additions & 7 deletions admin/google-blockly/own/blocks_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ Blockly.Blocks['time_compare_ex'] = {
var option = this.getFieldValue('OPTION');
var use_actual_time = this.getFieldValue('USE_ACTUAL_TIME');
container.setAttribute('end_time', (option === 'between' || option === 'not between') ? 'true' : 'false');
container.setAttribute('actual_time', (use_actual_time === 'TRUE') ? 'true' : 'false');
container.setAttribute('actual_time', use_actual_time === 'TRUE' || use_actual_time === 'true' || use_actual_time === true ? 'true' : 'false');
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('end_time') === 'true', xmlElement.getAttribute('actual_time') === 'true');
var end_time = xmlElement.getAttribute('end_time');
var actual_time = xmlElement.getAttribute('actual_time');
this.updateShape_(end_time === true || end_time === 'true' || end_time === 'TRUE', actual_time === true || actual_time === 'true' || actual_time === 'TRUE');
},
updateShape_: function(isBetween, useActualTime) {
if (isBetween === undefined) {
Expand Down Expand Up @@ -133,12 +135,13 @@ Blockly.Blocks['time_compare_ex'] = {
}

if (useActualTime === undefined) {
useActualTime = this.getFieldValue('USE_ACTUAL_TIME') === 'TRUE';
useActualTime = this.getFieldValue('USE_ACTUAL_TIME');
useActualTime = useActualTime === 'true' || useActualTime === 'TRUE' || useActualTime === true;
}
inputExists = this.getInput('CUSTOM_TIME');

if (!useActualTime) {
this.getInput('TIME_TEXT').fieldRow[0].setText(Blockly.Translate('time_compare_custom_ex'));
this.getInput('TIME_TEXT').fieldRow[0].setValue(Blockly.Translate('time_compare_custom_ex'));

if (!inputExists) {
this.appendDummyInput('CUSTOM_TEXT')
Expand All @@ -147,7 +150,7 @@ Blockly.Blocks['time_compare_ex'] = {
this.appendValueInput('CUSTOM_TIME');
}
} else if (inputExists) {
this.getInput('TIME_TEXT').fieldRow[0].setText(Blockly.Translate('time_compare_ex'));
this.getInput('TIME_TEXT').fieldRow[0].setValue(Blockly.Translate('time_compare_ex'));
this.removeInput('CUSTOM_TIME');
this.removeInput('CUSTOM_TEXT');
}
Expand Down Expand Up @@ -219,7 +222,8 @@ Blockly.Blocks['time_compare'] = {
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('end_time') === 'true');
var option = xmlElement.getAttribute('end_time');
this.updateShape_(option === true || option === 'true' || option === 'TRUE');
},
updateShape_: function(isBetween) {
// Add or remove a delay Input.
Expand Down Expand Up @@ -340,7 +344,9 @@ Blockly.Blocks['time_get'] = {
return container;
},
domToMutation: function(xmlElement) {
this.updateShape_(xmlElement.getAttribute('format') === 'true', xmlElement.getAttribute('language') === 'true');
var format = xmlElement.getAttribute('format');
var language = xmlElement.getAttribute('language');
this.updateShape_(format === true || format === 'true' || format === 'TRUE', language === true || language === 'true' || language === 'TRUE');
},
updateShape_: function(isFormat, isLanguage) {
// Add or remove a delay Input.
Expand Down
Loading

0 comments on commit 88178b8

Please sign in to comment.