Skip to content

Commit b42df1f

Browse files
committed
update initblock func
1 parent 02e3760 commit b42df1f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

js/blocks/EnsembleBlocks.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,19 @@ function setupEnsembleBlocks(activity) {
7575
blockInstance.setHelpString(helpText);
7676
}
7777

78+
// New function to initialize block with common properties
79+
function initializeBlock(blockInstance, paletteName, helpText) {
80+
blockInstance.setPalette(paletteName, activity);
81+
setHelpString(blockInstance, helpText);
82+
}
83+
7884
// Refactor TurtleHeapBlock
7985
class TurtleHeapBlock extends LeftBlock {
8086
constructor() {
8187
super("turtleheap", _THIS_IS_MUSIC_BLOCKS_ ? _("mouse index heap") : _("turtle index heap"));
82-
this.setPalette("ensemble", activity);
83-
84-
const helpText = _THIS_IS_MUSIC_BLOCKS_
88+
initializeBlock(this, "ensemble", _THIS_IS_MUSIC_BLOCKS_
8589
? [_("The Mouse index heap block returns a value in the heap at a specified location for a specified mouse."), "documentation", ""]
86-
: [_("The Turtle index heap block returns a value in the heap at a specified location for a specified turtle."), "documentation", ""];
87-
setHelpString(this, helpText);
90+
: [_("The Turtle index heap block returns a value in the heap at a specified location for a specified turtle."), "documentation", ""]);
8891

8992
const formOptions = {
9093
args: 2,

0 commit comments

Comments
 (0)