mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
@@ -35,12 +35,14 @@ Blockly.Blocks['plane_get_rows'] = {
|
||||
this.setHelpUrl(Blockly.Msg['VARIABLES_GET_HELPURL']);
|
||||
this.setColour(330);
|
||||
this.appendDummyInput()
|
||||
.appendField(Plane.getMsg('Plane_getRows'), 'title');
|
||||
.appendField(Plane.getMsg('Plane_getRows')
|
||||
.replace('%1', Plane.rows1st), 'title');
|
||||
this.setOutput(true, 'Number');
|
||||
},
|
||||
customUpdate: function() {
|
||||
this.setFieldValue(
|
||||
Plane.getMsg('Plane_getRows').replace('%1', Plane.rows1st), 'title');
|
||||
Plane.getMsg('Plane_getRows')
|
||||
.replace('%1', Plane.rows1st), 'title');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,12 +57,14 @@ Blockly.Blocks['plane_get_rows1st'] = {
|
||||
this.setHelpUrl(Blockly.Msg['VARIABLES_GET_HELPURL']);
|
||||
this.setColour(330);
|
||||
this.appendDummyInput()
|
||||
.appendField(Plane.getMsg('Plane_getRows1'), 'title');
|
||||
.appendField(Plane.getMsg('Plane_getRows1')
|
||||
.replace('%1', Plane.rows1st), 'title');
|
||||
this.setOutput(true, 'Number');
|
||||
},
|
||||
customUpdate: function() {
|
||||
this.setFieldValue(
|
||||
Plane.getMsg('Plane_getRows1').replace('%1', Plane.rows1st), 'title');
|
||||
Plane.getMsg('Plane_getRows1')
|
||||
.replace('%1', Plane.rows1st), 'title');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,12 +79,14 @@ Blockly.Blocks['plane_get_rows2nd'] = {
|
||||
this.setHelpUrl(Blockly.Msg['VARIABLES_GET_HELPURL']);
|
||||
this.setColour(330);
|
||||
this.appendDummyInput()
|
||||
.appendField(Plane.getMsg('Plane_getRows2'), 'title');
|
||||
.appendField(Plane.getMsg('Plane_getRows2')
|
||||
.replace('%1', Plane.rows2nd), 'title');
|
||||
this.setOutput(true, 'Number');
|
||||
},
|
||||
customUpdate: function() {
|
||||
this.setFieldValue(
|
||||
Plane.getMsg('Plane_getRows2').replace('%1', Plane.rows2nd), 'title');
|
||||
Plane.getMsg('Plane_getRows2')
|
||||
.replace('%1', Plane.rows2nd), 'title');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -200,12 +200,20 @@ Plane.rows1st = 0;
|
||||
Plane.rows2nd = 0;
|
||||
|
||||
/**
|
||||
* Redraw the rows when the slider has moved.
|
||||
* Redraw the rows and update blocks when the slider has moved.
|
||||
* @param {number} value New slider position.
|
||||
*/
|
||||
Plane.sliderChange = function(value) {
|
||||
var newRows = Math.round(value * 410 / 20);
|
||||
Plane.redraw(newRows);
|
||||
|
||||
function updateBlocks(blocks) {
|
||||
for (var i = 0, block; block = blocks[i]; i++) {
|
||||
block.customUpdate && block.customUpdate();
|
||||
}
|
||||
}
|
||||
updateBlocks(Plane.workspace.getAllBlocks(false), true);
|
||||
updateBlocks(Plane.workspace.flyout_.workspace_.getAllBlocks(false));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -340,15 +348,6 @@ Plane.recalculate = function() {
|
||||
Plane.getMsg('Plane_seats').replace(
|
||||
'%1', isNaN(seats) ? '?' : seats));
|
||||
Plane.setCorrect(isNaN(seats) ? null : (Plane.answer() == seats));
|
||||
|
||||
// Update blocks to show values.
|
||||
function updateBlocks(blocks) {
|
||||
for (var i = 0, block; block = blocks[i]; i++) {
|
||||
block.customUpdate && block.customUpdate();
|
||||
}
|
||||
}
|
||||
updateBlocks(Plane.workspace.getAllBlocks(false));
|
||||
updateBlocks(Plane.workspace.flyout_.workspace_.getAllBlocks(false));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user