@@ -258,6 +258,7 @@ function readTextFile(file, callback) {
258
258
rawFile .send (null );
259
259
}
260
260
var instrumentlist = [];// ["pianoooo","pianoo"], ["chitarra","guiitar"], ["flauto","fluute"]];
261
+ var animalist = [];// ["pianoooo","pianoo"], ["chitarra","guiitar"], ["flauto","fluute"]];
261
262
// usage:
262
263
var data = readTextFile ( " ./static/music_package.json" , function (text ){
263
264
var datas = JSON .parse (text);
@@ -266,9 +267,14 @@ var data = readTextFile( "./static/music_package.json" , function(text){
266
267
Object .keys (datas[' packages' ]).forEach (function (key ) {
267
268
console .table (' Key : ' + key + ' , Value : ' + datas[' packages' ][key])
268
269
console .table (' Key : name_IT, Value : ' + datas[' packages' ][key][' name_IT' ])
269
-
270
270
var names = [datas[' packages' ][key][' name_IT' ], key];
271
- instrumentlist[instrumentlist .length ] = names;
271
+
272
+ if (datas[' packages' ][key][' category' ] == ' instrument' ){
273
+ instrumentlist[instrumentlist .length ] = names;
274
+ }
275
+ else if (datas[' packages' ][key][' category' ] == ' animal' ){
276
+ animalist[animalist .length ] = names;
277
+ }
272
278
})
273
279
return datas;
274
280
});
@@ -1723,7 +1729,7 @@ export default {
1723
1729
this .appendDummyInput ()
1724
1730
.appendField (new Blockly.FieldImage (" /static/images/blocks/animal.png" , 30 , 30 , { alt: " *" , flipRtl: " FALSE" }))
1725
1731
.appendField (" Verso del" )
1726
- .appendField (new Blockly.FieldDropdown ([[ " Gatto " , " cat " ], [ " Cane " , " dog " ]] ), " Verso del" );
1732
+ .appendField (new Blockly.FieldDropdown (animalist ), " Verso del" );
1727
1733
this .setInputsInline (true );
1728
1734
this .setPreviousStatement (true , null );
1729
1735
this .setNextStatement (true , null );
@@ -1801,7 +1807,7 @@ export default {
1801
1807
.appendField (new Blockly.FieldDropdown ([[" DO " ," C2" ], [" RE " ," D2" ], [" MI " ," E2" ], [" FA " ," F2" ], [" FA # " ," F#2" ], [" SOL " ," G2" ], [" LA " ," A2" ], [" SI b " ," Bb2" ], [" SI " ," B2" ], [" DO+ " ," C3" ], [" RE+ " ," D3" ] ]), " note" );
1802
1808
this .appendDummyInput ()
1803
1809
.appendField (" animale" )
1804
- .appendField (new Blockly.FieldDropdown ([[ " Gatto " , " cat " ], [ " Cane " , " dog " ], [ " Dinosaur " , " dinosaur " ]] ), " instrument" );
1810
+ .appendField (new Blockly.FieldDropdown (animalist ), " instrument" );
1805
1811
this .appendValueInput (" duration" )
1806
1812
.setCheck (" Number" )
1807
1813
.setAlign (Blockly .ALIGN_CENTRE )
@@ -1907,7 +1913,7 @@ export default {
1907
1913
Blockly .Blocks [' coderbot_music_instrument_adv' ] = {
1908
1914
init : function () {
1909
1915
this .appendDummyInput ()
1910
- .appendField (new Blockly.FieldDropdown ([[ " guitar " , " guitar " ], [ " piano " , " piano " ], [ " flauto " , " flute " ]] ), " instrument" );
1916
+ .appendField (new Blockly.FieldDropdown (instrumentlist ), " instrument" );
1911
1917
this .setInputsInline (true );
1912
1918
this .setOutput (true , ' String' );
1913
1919
this .setColour (345 );
@@ -1925,7 +1931,7 @@ export default {
1925
1931
Blockly .Blocks [' coderbot_music_animal_adv' ] = {
1926
1932
init : function () {
1927
1933
this .appendDummyInput ()
1928
- .appendField (new Blockly.FieldDropdown ([[ " cane " , " dog " ], [ " gatto " , " cat " ]] ), " instrument" );
1934
+ .appendField (new Blockly.FieldDropdown (animalist ), " instrument" );
1929
1935
this .setInputsInline (true );
1930
1936
this .setOutput (true , ' String' );
1931
1937
this .setColour (345 );
0 commit comments