Skip to content

Commit

Permalink
Migrate to Blockly 10.x - see #1598
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Jun 7, 2024
1 parent 126112a commit e17c900
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/public/google-blockly/own/blocks_timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Blockly.Blocks['timeouts_settimeout'] = {
};

Blockly.JavaScript.forBlock['timeouts_settimeout'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
const unit = block.getFieldValue('UNIT');

let delay = block.getFieldValue('DELAY');
Expand Down Expand Up @@ -234,7 +234,7 @@ Blockly.Blocks['timeouts_settimeout_variable'] = {

Blockly.JavaScript.forBlock['timeouts_settimeout_variable'] = function(block) {
const delay = Blockly.JavaScript.valueToCode(block, 'DELAY_MS', Blockly.JavaScript.ORDER_ATOMIC);
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');

return `${name} = setTimeout(async () => {\n` +
Expand Down Expand Up @@ -292,7 +292,7 @@ Blockly.Blocks['timeouts_cleartimeout'] = {
};

Blockly.JavaScript.forBlock['timeouts_cleartimeout'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
return `(() => { if (${name}) { clearTimeout(${name}); ${name} = null; }})();\n`;
};

Expand All @@ -319,7 +319,7 @@ Blockly.Blocks['timeouts_gettimeout'] = {
};

Blockly.JavaScript.forBlock['timeouts_gettimeout'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));

return [name, Blockly.JavaScript.ORDER_ATOMIC];
};
Expand Down Expand Up @@ -370,7 +370,7 @@ Blockly.Blocks['timeouts_setinterval'] = {
};

Blockly.JavaScript.forBlock['timeouts_setinterval'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
const unit = block.getFieldValue('UNIT');

let delay = block.getFieldValue('INTERVAL');
Expand Down Expand Up @@ -435,7 +435,7 @@ Blockly.Blocks['timeouts_setinterval_variable'] = {

Blockly.JavaScript.forBlock['timeouts_setinterval_variable'] = function(block) {
const delay = Blockly.JavaScript.valueToCode(block, 'INTERVAL_MS', Blockly.JavaScript.ORDER_ATOMIC);
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');

return `${name} = setInterval(async () => {\n` +
Expand Down Expand Up @@ -492,7 +492,7 @@ Blockly.Blocks['timeouts_clearinterval'] = {
};

Blockly.JavaScript.forBlock['timeouts_clearinterval'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));

return `(() => { if (${name}) { clearInterval(${name}); ${name} = null; }})();\n`;
};
Expand Down Expand Up @@ -520,7 +520,7 @@ Blockly.Blocks['timeouts_getinterval'] = {
};

Blockly.JavaScript.forBlock['timeouts_getinterval'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));

return [name, Blockly.JavaScript.ORDER_ATOMIC];
};
4 changes: 2 additions & 2 deletions src/public/google-blockly/own/blocks_trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ Blockly.Blocks['schedule_create'] = {
};

Blockly.JavaScript.forBlock['schedule_create'] = function (block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
const schedule = Blockly.JavaScript.valueToCode(block, 'SCHEDULE', Blockly.JavaScript.ORDER_ATOMIC);
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');

Expand Down Expand Up @@ -936,7 +936,7 @@ Blockly.Blocks['schedule_clear'] = {
};

Blockly.JavaScript.forBlock['schedule_clear'] = function(block) {
const name = Blockly.JavaScript.variableDB_.safeName_(block.getFieldValue('NAME'));
const name = Blockly.JavaScript.nameDB_.safeName(block.getFieldValue('NAME'));
return `(() => { if (${name}) { clearSchedule(${name}); ${name} = null; }})();\n`;
};

Expand Down
6 changes: 3 additions & 3 deletions src/public/google-blockly/own/field_cron.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class FieldCRON extends Blockly.Field {
* @private
*/
resizeEditor_() {
const div = Blockly.WidgetDiv.DIV;
const div = Blockly.WidgetDiv.getDiv();
const bBox = this.fieldGroup_.getBBox();
div.style.width = bBox.width * this.workspace_.scale + 'px';
div.style.height = bBox.height * this.workspace_.scale + 'px';
Expand All @@ -109,7 +109,7 @@ class FieldCRON extends Blockly.Field {
}
// Shift by a few pixels to line up exactly.
xy.y += 1;
if (goog.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) {
if (goog.userAgent.GECKO && Blockly.WidgetDiv.getDiv().style.top) {
// Firefox mis-reports the location of the border by a pixel
// once the WidgetDiv is moved into position.
xy.x -= 1;
Expand Down Expand Up @@ -146,7 +146,7 @@ class FieldCRON extends Blockly.Field {
Blockly.FieldCRON.htmlInput_ = null;

// Delete style properties.
const style = Blockly.WidgetDiv.DIV.style;
const style = Blockly.WidgetDiv.getDiv().style;
style.width = 'auto';
style.height = 'auto';
style.fontSize = '';
Expand Down
6 changes: 3 additions & 3 deletions src/public/google-blockly/own/field_oid.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class FieldOID extends Blockly.Field {
* @private
*/
resizeEditor_() {
const div = Blockly.WidgetDiv.DIV;
const div = Blockly.WidgetDiv.getDiv();
const bBox = this.fieldGroup_.getBBox();
div.style.width = bBox.width * this.workspace_.scale + 'px';
div.style.height = bBox.height * this.workspace_.scale + 'px';
Expand All @@ -171,7 +171,7 @@ class FieldOID extends Blockly.Field {
}
// Shift by a few pixels to line up exactly.
xy.y += 1;
if (goog.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) {
if (goog.userAgent.GECKO && Blockly.WidgetDiv.getDiv().style.top) {
// Firefox mis-reports the location of the border by a pixel
// once the WidgetDiv is moved into position.
xy.x -= 1;
Expand Down Expand Up @@ -207,7 +207,7 @@ class FieldOID extends Blockly.Field {
this.htmlInput_ = null;

// Delete style properties.
const style = Blockly.WidgetDiv.DIV.style;
const style = Blockly.WidgetDiv.getDiv().style;
style.width = 'auto';
style.height = 'auto';
style.fontSize = '';
Expand Down
2 changes: 1 addition & 1 deletion src/public/google-blockly/own/field_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class FieldScript extends Blockly.Field {
Blockly.FieldScript.htmlInput_ = null;
// Delete style properties.
const style = Blockly.WidgetDiv.DIV.style;
const style = Blockly.WidgetDiv.getDiv().style;
style.width = 'auto';
style.height = 'auto';
style.fontSize = '';
Expand Down

0 comments on commit e17c900

Please sign in to comment.