Skip to content

Commit

Permalink
Remove unused music blocks, and add tooltips for each music block.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlip committed Jan 27, 2017
1 parent ad59716 commit 05a1724
Showing 1 changed file with 11 additions and 37 deletions.
48 changes: 11 additions & 37 deletions appengine/accessible/js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,15 @@ Music.Blocks.NOTE_OPTIONS = [
["B4", "59"]
];

var MUSIC_DUMMY_TOOLTIP = 'Dummy tooltip';
var MUSIC_DUMMY_HELPURL = 'Dummy help URL';

// Extensions to Blockly's language and JavaScript generator.

Blockly.Blocks['music_play_random_note'] = {
/**
* Block for playing a random music note.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "play random note",
"previousStatement": null,
"nextStatement": null,
"colour": Music.Blocks.HUE,
"tooltip": MUSIC_DUMMY_TOOLTIP,
"helpUrl": MUSIC_DUMMY_HELPURL
});
}
Music.Blocks.MESSAGES = {
Music_playNoteTooltip: 'Play a single music note.',
Music_playNoteBlankTooltip: 'Play a single music note.',
Music_playPhraseTooltip: 'Play a snippet of music.',
Music_playNoteWithDurationTooltip:
'Play a single music note for a certain number of beats.'
};

Blockly.JavaScript['music_play_random_note'] = function(block) {
var LOWEST_PITCH = 36;
var HIGHEST_PITCH = 60;

var randomPitch =
Math.floor(Math.random() * (HIGHEST_PITCH - LOWEST_PITCH) +
LOWEST_PITCH);
return 'addChord([' + randomPitch + '], 1);\n';
};
// Extensions to Blockly's language and JavaScript generator.

Blockly.Blocks['music_play_note'] = {
/**
Expand All @@ -88,8 +66,7 @@ Blockly.Blocks['music_play_note'] = {
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(Music.Blocks.HUE);
this.setTooltip(MUSIC_DUMMY_TOOLTIP);
this.setHelpUrl(MUSIC_DUMMY_HELPURL);
this.setTooltip(Music.Blocks.MESSAGES.Music_playNoteTooltip);
},
onchange: function(changeEvent) {
if (changeEvent.blockId == this.id && changeEvent.element == 'field' &&
Expand Down Expand Up @@ -120,8 +97,7 @@ Blockly.Blocks['music_play_note_blank'] = {
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(Music.Blocks.HUE);
this.setTooltip(MUSIC_DUMMY_TOOLTIP);
this.setHelpUrl(MUSIC_DUMMY_HELPURL);
this.setTooltip(Music.Blocks.MESSAGES.Music_playNoteBlankTooltip);
},
onchange: function(changeEvent) {
if (changeEvent.blockId == this.id && changeEvent.element == 'field' &&
Expand Down Expand Up @@ -162,8 +138,7 @@ Blockly.Blocks['music_play_phrase'] = {
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(Music.Blocks.HUE);
this.setTooltip(MUSIC_DUMMY_TOOLTIP);
this.setHelpUrl(MUSIC_DUMMY_HELPURL);
this.setTooltip(Music.Blocks.MESSAGES.Music_playPhraseTooltip);
},
onchange: function(changeEvent) {
if (changeEvent.blockId == this.id && changeEvent.element == 'field' &&
Expand Down Expand Up @@ -243,8 +218,7 @@ Blockly.Blocks['music_play_note_with_duration'] = {
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(Music.Blocks.HUE);
this.setTooltip(MUSIC_DUMMY_TOOLTIP);
this.setHelpUrl(MUSIC_DUMMY_HELPURL);
this.setTooltip(Music.Blocks.MESSAGES.Music_playNoteWithDurationTooltip);
},
onchange: function(changeEvent) {
if (changeEvent.blockId == this.id && changeEvent.element == 'field' &&
Expand Down

0 comments on commit 05a1724

Please sign in to comment.