Lint in block definitions

This commit is contained in:
Rachel Fenichel 2018-05-02 15:58:36 -07:00
parent d656eafad0
commit ab5d4e7b9d
13 changed files with 442 additions and 462 deletions

View file

@ -66,24 +66,25 @@ Blockly.Blocks['dropdown_whenbroadcast'] = {
*/ */
init: function() { init: function() {
this.appendDummyInput() this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu([ .appendField(new Blockly.FieldIconMenu(
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_blue.svg', [
value: 'blue', width: 48, height: 48, alt: 'Blue'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_blue.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_green.svg', value: 'blue', width: 48, height: 48, alt: 'Blue'},
value: 'green', width: 48, height: 48, alt: 'Green'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_green.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_coral.svg', value: 'green', width: 48, height: 48, alt: 'Green'},
value: 'coral', width: 48, height: 48, alt: 'Coral'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_coral.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_magenta.svg', value: 'coral', width: 48, height: 48, alt: 'Coral'},
value: 'magenta', width: 48, height: 48, alt: 'Magenta'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_magenta.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_orange.svg', value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
value: 'orange', width: 48, height: 48, alt: 'Orange'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_orange.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_purple.svg', value: 'orange', width: 48, height: 48, alt: 'Orange'},
value: 'purple', width: 48, height: 48, alt: 'Purple'} {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_when-broadcast-received_purple.svg',
]), 'CHOICE'); value: 'purple', width: 48, height: 48, alt: 'Purple'}
]), 'CHOICE');
this.setOutput(true); this.setOutput(true);
this.setColour(Blockly.Colours.event.primary, this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary, Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary Blockly.Colours.event.tertiary
); );
} }
}; };
@ -127,24 +128,25 @@ Blockly.Blocks['dropdown_broadcast'] = {
*/ */
init: function() { init: function() {
this.appendDummyInput() this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu([ .appendField(new Blockly.FieldIconMenu(
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_blue.svg', [
value: 'blue', width: 48, height: 48, alt: 'Blue'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_blue.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_green.svg', value: 'blue', width: 48, height: 48, alt: 'Blue'},
value: 'green', width: 48, height: 48, alt: 'Green'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_green.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_coral.svg', value: 'green', width: 48, height: 48, alt: 'Green'},
value: 'coral', width: 48, height: 48, alt: 'Coral'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_coral.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_magenta.svg', value: 'coral', width: 48, height: 48, alt: 'Coral'},
value: 'magenta', width: 48, height: 48, alt: 'Magenta'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_magenta.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_orange.svg', value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
value: 'orange', width: 48, height: 48, alt: 'Orange'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_orange.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_purple.svg', value: 'orange', width: 48, height: 48, alt: 'Orange'},
value: 'purple', width: 48, height: 48, alt: 'Purple'} {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/event_broadcast_purple.svg',
]), 'CHOICE'); value: 'purple', width: 48, height: 48, alt: 'Purple'}
]), 'CHOICE');
this.setOutput(true); this.setOutput(true);
this.setColour(Blockly.Colours.event.primary, this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary, Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary Blockly.Colours.event.tertiary
); );
} }
}; };

View file

@ -37,30 +37,31 @@ Blockly.Blocks['dropdown_wedo_setcolor'] = {
*/ */
init: function() { init: function() {
this.appendDummyInput() this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu([ .appendField(new Blockly.FieldIconMenu(
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_mystery.svg', [
value: 'mystery', width: 48, height: 48, alt: 'Mystery'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_mystery.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_yellow.svg', value: 'mystery', width: 48, height: 48, alt: 'Mystery'},
value: 'yellow', width: 48, height: 48, alt: 'Yellow'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_yellow.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_orange.svg', value: 'yellow', width: 48, height: 48, alt: 'Yellow'},
value: 'orange', width: 48, height: 48, alt: 'Orange'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_orange.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_coral.svg', value: 'orange', width: 48, height: 48, alt: 'Orange'},
value: 'coral', width: 48, height: 48, alt: 'Coral'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_coral.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_magenta.svg', value: 'coral', width: 48, height: 48, alt: 'Coral'},
value: 'magenta', width: 48, height: 48, alt: 'Magenta'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_magenta.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_purple.svg', value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
value: 'purple', width: 48, height: 48, alt: 'Purple'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_purple.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_blue.svg', value: 'purple', width: 48, height: 48, alt: 'Purple'},
value: 'blue', width: 48, height: 48, alt: 'Blue'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_blue.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_green.svg', value: 'blue', width: 48, height: 48, alt: 'Blue'},
value: 'green', width: 48, height: 48, alt: 'Green'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_green.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_white.svg', value: 'green', width: 48, height: 48, alt: 'Green'},
value: 'white', width: 48, height: 48, alt: 'White'} {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_white.svg',
]), 'CHOICE'); value: 'white', width: 48, height: 48, alt: 'White'}
]), 'CHOICE');
this.setOutput(true); this.setOutput(true);
this.setColour(Blockly.Colours.looks.primary, this.setColour(Blockly.Colours.looks.primary,
Blockly.Colours.looks.secondary, Blockly.Colours.looks.secondary,
Blockly.Colours.looks.tertiary Blockly.Colours.looks.tertiary
); );
} }
}; };
@ -173,18 +174,19 @@ Blockly.Blocks['dropdown_wedo_motorspeed'] = {
*/ */
init: function() { init: function() {
this.appendDummyInput() this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu([ .appendField(new Blockly.FieldIconMenu(
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_slow.svg', [
value: 'slow', width: 48, height: 48, alt: 'Slow'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_slow.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_med.svg', value: 'slow', width: 48, height: 48, alt: 'Slow'},
value: 'medium', width: 48, height: 48, alt: 'Medium'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_med.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_fast.svg', value: 'medium', width: 48, height: 48, alt: 'Medium'},
value: 'fast', width: 48, height: 48, alt: 'Fast'} {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_fast.svg',
]), 'CHOICE'); value: 'fast', width: 48, height: 48, alt: 'Fast'}
]), 'CHOICE');
this.setOutput(true); this.setOutput(true);
this.setColour(Blockly.Colours.motion.primary, this.setColour(Blockly.Colours.motion.primary,
Blockly.Colours.motion.secondary, Blockly.Colours.motion.secondary,
Blockly.Colours.motion.tertiary Blockly.Colours.motion.tertiary
); );
} }
}; };
@ -229,25 +231,26 @@ Blockly.Blocks['dropdown_wedo_whentilt'] = {
*/ */
init: function() { init: function() {
this.appendDummyInput() this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu([ .appendField(new Blockly.FieldIconMenu(
{type: 'placeholder', width: 48, height: 48}, [
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-forward.svg', {type: 'placeholder', width: 48, height: 48},
value: 'forward', width: 48, height: 48, alt: 'Tilt forward'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-forward.svg',
{type: 'placeholder', width: 48, height: 48}, value: 'forward', width: 48, height: 48, alt: 'Tilt forward'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-left.svg', {type: 'placeholder', width: 48, height: 48},
value: 'left', width: 48, height: 48, alt: 'Tilt left'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-left.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt.svg', value: 'left', width: 48, height: 48, alt: 'Tilt left'},
value: 'any', width: 48, height: 48, alt: 'Tilt any'}, {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt.svg',
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-right.svg', value: 'any', width: 48, height: 48, alt: 'Tilt any'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-right.svg',
value: 'right', width: 48, height: 48, alt: 'Tilt right'}, value: 'right', width: 48, height: 48, alt: 'Tilt right'},
{type: 'placeholder', width: 48, height: 48}, {type: 'placeholder', width: 48, height: 48},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-backward.svg', {src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_when-tilt-backward.svg',
value: 'backward', width: 48, height: 48, alt: 'Tilt backward'} value: 'backward', width: 48, height: 48, alt: 'Tilt backward'}
]), 'CHOICE'); ]), 'CHOICE');
this.setOutput(true); this.setOutput(true);
this.setColour(Blockly.Colours.event.primary, this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary, Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary Blockly.Colours.event.tertiary
); );
} }
}; };

View file

@ -208,8 +208,8 @@ Blockly.Blocks['control_stop'] = {
.appendField(stopDropdown, 'STOP_OPTION'); .appendField(stopDropdown, 'STOP_OPTION');
this.setCategory(Blockly.Categories.control); this.setCategory(Blockly.Categories.control);
this.setColour(Blockly.Colours.control.primary, this.setColour(Blockly.Colours.control.primary,
Blockly.Colours.control.secondary, Blockly.Colours.control.secondary,
Blockly.Colours.control.tertiary Blockly.Colours.control.tertiary
); );
this.setPreviousStatement(true); this.setPreviousStatement(true);
}, },
@ -402,20 +402,19 @@ Blockly.Blocks['control_create_clone_of_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "CLONE_OPTION",
"name": "CLONE_OPTION", "options": [
"options": [ ['myself', '_myself_']
['myself', '_myself_'] ]
] }
} ],
], "extensions": ["colours_control", "output_string"]
"extensions": ["colours_control", "output_string"] });
});
} }
}; };

View file

@ -478,7 +478,7 @@ Blockly.Constants.Data.CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN = {
option.callback = option.callback =
Blockly.Constants.Data.VARIABLE_OPTION_CALLBACK_FACTORY(this, Blockly.Constants.Data.VARIABLE_OPTION_CALLBACK_FACTORY(this,
option.text); option.text);
options.push(option); options.push(option);
} }
} else { } else {
@ -500,7 +500,7 @@ Blockly.Constants.Data.CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN = {
}; };
Blockly.Extensions.registerMixin('contextMenu_getVariableBlock', Blockly.Extensions.registerMixin('contextMenu_getVariableBlock',
Blockly.Constants.Data.CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN); Blockly.Constants.Data.CUSTOM_CONTEXT_MENU_GET_VARIABLE_MIXIN);
/** /**
* Callback factory for dropdown menu options associated with a variable getter * Callback factory for dropdown menu options associated with a variable getter

View file

@ -117,7 +117,7 @@ Blockly.Blocks['event_whenbackdropswitchesto'] = {
"type": "field_dropdown", "type": "field_dropdown",
"name": "BACKDROP", "name": "BACKDROP",
"options": [ "options": [
['backdrop1', 'BACKDROP1'] ['backdrop1', 'BACKDROP1']
] ]
} }
], ],
@ -140,7 +140,7 @@ Blockly.Blocks['event_whengreaterthan'] = {
"type": "field_dropdown", "type": "field_dropdown",
"name": "WHENGREATERTHANMENU", "name": "WHENGREATERTHANMENU",
"options": [ "options": [
['timer', 'TIMER'] ['timer', 'TIMER']
] ]
}, },
{ {
@ -160,22 +160,21 @@ Blockly.Blocks['event_broadcast_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_variable",
"type": "field_variable", "name": "BROADCAST_OPTION",
"name": "BROADCAST_OPTION", "variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
"variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE], "variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME }
} ],
], "colour": Blockly.Colours.event.secondary,
"colour": Blockly.Colours.event.secondary, "colourSecondary": Blockly.Colours.event.secondary,
"colourSecondary": Blockly.Colours.event.secondary, "colourTertiary": Blockly.Colours.event.tertiary,
"colourTertiary": Blockly.Colours.event.tertiary, "extensions": ["output_string"]
"extensions": ["output_string"] });
});
} }
}; };

View file

@ -190,23 +190,22 @@ Blockly.Blocks['extension_wedo_tilt_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "TILT",
"name": "TILT", "options": [
"options": [ ['Any', 'Any'],
['Any', 'Any'], ['Whirl', 'Whirl'],
['Whirl', 'Whirl'], ['South', 'South'],
['South', 'South'], ['Back in time', 'Back in time']
['Back in time', 'Back in time'] ]
] }
} ],
], "extensions": ["colours_more", "output_string"]
"extensions": ["colours_more", "output_string"] });
});
} }
}; };

View file

@ -122,12 +122,11 @@ Blockly.Blocks['looks_show'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.LOOKS_SHOW,
"message0": Blockly.Msg.LOOKS_SHOW, "category": Blockly.Categories.looks,
"category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"]
"extensions": ["colours_looks", "shape_statement"] });
});
} }
}; };
@ -137,12 +136,11 @@ Blockly.Blocks['looks_hide'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.LOOKS_HIDE,
"message0": Blockly.Msg.LOOKS_HIDE, "category": Blockly.Categories.looks,
"category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"]
"extensions": ["colours_looks", "shape_statement"] });
});
} }
}; };
@ -154,12 +152,11 @@ Blockly.Blocks['looks_hideallsprites'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.LOOKS_HIDEALLSPRITES,
"message0": Blockly.Msg.LOOKS_HIDEALLSPRITES, "category": Blockly.Categories.looks,
"category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"]
"extensions": ["colours_looks", "shape_statement"] });
});
} }
}; };
@ -355,24 +352,23 @@ Blockly.Blocks['looks_costume'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "COSTUME",
"name": "COSTUME", "options": [
"options": [ ['costume1', 'COSTUME1'],
['costume1', 'COSTUME1'], ['costume2', 'COSTUME2']
['costume2', 'COSTUME2'] ]
] }
} ],
], "colour": Blockly.Colours.looks.secondary,
"colour": Blockly.Colours.looks.secondary, "colourSecondary": Blockly.Colours.looks.secondary,
"colourSecondary": Blockly.Colours.looks.secondary, "colourTertiary": Blockly.Colours.looks.tertiary,
"colourTertiary": Blockly.Colours.looks.tertiary, "extensions": ["output_string"]
"extensions": ["output_string"] });
});
} }
}; };
@ -402,12 +398,11 @@ Blockly.Blocks['looks_nextcostume'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.LOOKS_NEXTCOSTUME,
"message0": Blockly.Msg.LOOKS_NEXTCOSTUME, "category": Blockly.Categories.looks,
"category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"]
"extensions": ["colours_looks", "shape_statement"] });
});
} }
}; };
@ -445,7 +440,7 @@ Blockly.Blocks['looks_backdrops'] = {
"type": "field_dropdown", "type": "field_dropdown",
"name": "BACKDROP", "name": "BACKDROP",
"options": [ "options": [
['backdrop1', 'BACKDROP1'] ['backdrop1', 'BACKDROP1']
] ]
} }
], ],
@ -463,22 +458,21 @@ Blockly.Blocks['looks_gotofrontback'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.LOOKS_GOTOFRONTBACK,
"message0": Blockly.Msg.LOOKS_GOTOFRONTBACK, "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "FRONT_BACK",
"name": "FRONT_BACK", "options": [
"options": [ [Blockly.Msg.LOOKS_GOTOFRONTBACK_FRONT, 'front'],
[Blockly.Msg.LOOKS_GOTOFRONTBACK_FRONT, 'front'], [Blockly.Msg.LOOKS_GOTOFRONTBACK_BACK, 'back']
[Blockly.Msg.LOOKS_GOTOFRONTBACK_BACK, 'back'] ]
] }
} ],
], "category": Blockly.Categories.looks,
"category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"]
"extensions": ["colours_looks", "shape_statement"] });
});
} }
}; };
@ -586,11 +580,10 @@ Blockly.Blocks['looks_nextbackdrop'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.LOOKS_NEXTBACKDROP,
"message0": Blockly.Msg.LOOKS_NEXTBACKDROP, "category": Blockly.Categories.looks,
"category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"]
"extensions": ["colours_looks", "shape_statement"] });
});
} }
}; };

View file

@ -126,23 +126,22 @@ Blockly.Blocks['motion_pointtowards_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "TOWARDS",
"name": "TOWARDS", "options": [
"options": [ [Blockly.Msg.MOTION_POINTTOWARDS_POINTER, '_mouse_']
[Blockly.Msg.MOTION_POINTTOWARDS_POINTER, '_mouse_'] ]
] }
} ],
], "colour": Blockly.Colours.motion.secondary,
"colour": Blockly.Colours.motion.secondary, "colourSecondary": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary, "colourTertiary": Blockly.Colours.motion.tertiary,
"colourTertiary": Blockly.Colours.motion.tertiary, "extensions": ["output_string"]
"extensions": ["output_string"] });
});
} }
}; };
@ -172,24 +171,23 @@ Blockly.Blocks['motion_goto_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "TO",
"name": "TO", "options": [
"options": [ [Blockly.Msg.MOTION_GOTO_POINTER, '_mouse_'],
[Blockly.Msg.MOTION_GOTO_POINTER, '_mouse_'], [Blockly.Msg.MOTION_GOTO_RANDOM, '_random_']
[Blockly.Msg.MOTION_GOTO_RANDOM, '_random_'] ]
] }
} ],
], "colour": Blockly.Colours.motion.secondary,
"colour": Blockly.Colours.motion.secondary, "colourSecondary": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary, "colourTertiary": Blockly.Colours.motion.tertiary,
"colourTertiary": Blockly.Colours.motion.tertiary, "extensions": ["output_string"]
"extensions": ["output_string"] });
});
} }
}; };

View file

@ -34,22 +34,21 @@ Blockly.Blocks['operator_add'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_ADD,
"message0": Blockly.Msg.OPERATORS_ADD, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "NUM1"
"name": "NUM1" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "NUM2"
"name": "NUM2" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -59,22 +58,21 @@ Blockly.Blocks['operator_subtract'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_SUBTRACT,
"message0": Blockly.Msg.OPERATORS_SUBTRACT, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "NUM1"
"name": "NUM1" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "NUM2"
"name": "NUM2" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -84,22 +82,21 @@ Blockly.Blocks['operator_multiply'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_MULTIPLY,
"message0": Blockly.Msg.OPERATORS_MULTIPLY, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "NUM1"
"name": "NUM1" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "NUM2"
"name": "NUM2" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -109,22 +106,21 @@ Blockly.Blocks['operator_divide'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_DIVIDE,
"message0": Blockly.Msg.OPERATORS_DIVIDE, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "NUM1"
"name": "NUM1" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "NUM2"
"name": "NUM2" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -134,22 +130,21 @@ Blockly.Blocks['operator_random'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_RANDOM,
"message0": Blockly.Msg.OPERATORS_RANDOM, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "FROM"
"name": "FROM" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "TO"
"name": "TO" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -372,22 +367,21 @@ Blockly.Blocks['operator_contains'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_CONTAINS,
"message0": Blockly.Msg.OPERATORS_CONTAINS, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "STRING1"
"name": "STRING1" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "STRING2"
"name": "STRING2" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_boolean"]
"extensions": ["colours_operators", "output_boolean"] });
});
} }
}; };
@ -397,22 +391,21 @@ Blockly.Blocks['operator_mod'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_MOD,
"message0": Blockly.Msg.OPERATORS_MOD, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "NUM1"
"name": "NUM1" },
}, {
{ "type": "input_value",
"type": "input_value", "name": "NUM2"
"name": "NUM2" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -422,18 +415,17 @@ Blockly.Blocks['operator_round'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_ROUND,
"message0": Blockly.Msg.OPERATORS_ROUND, "args0": [
"args0": [ {
{ "type": "input_value",
"type": "input_value", "name": "NUM"
"name": "NUM" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };
@ -443,37 +435,36 @@ Blockly.Blocks['operator_mathop'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": Blockly.Msg.OPERATORS_MATHOP,
"message0": Blockly.Msg.OPERATORS_MATHOP, "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "OPERATOR",
"name": "OPERATOR", "options": [
"options": [ [Blockly.Msg.OPERATORS_MATHOP_ABS, 'abs'],
[Blockly.Msg.OPERATORS_MATHOP_ABS, 'abs'], [Blockly.Msg.OPERATORS_MATHOP_FLOOR, 'floor'],
[Blockly.Msg.OPERATORS_MATHOP_FLOOR, 'floor'], [Blockly.Msg.OPERATORS_MATHOP_CEILING, 'ceiling'],
[Blockly.Msg.OPERATORS_MATHOP_CEILING, 'ceiling'], [Blockly.Msg.OPERATORS_MATHOP_SQRT, 'sqrt'],
[Blockly.Msg.OPERATORS_MATHOP_SQRT, 'sqrt'], [Blockly.Msg.OPERATORS_MATHOP_SIN, 'sin'],
[Blockly.Msg.OPERATORS_MATHOP_SIN, 'sin'], [Blockly.Msg.OPERATORS_MATHOP_COS, 'cos'],
[Blockly.Msg.OPERATORS_MATHOP_COS, 'cos'], [Blockly.Msg.OPERATORS_MATHOP_TAN, 'tan'],
[Blockly.Msg.OPERATORS_MATHOP_TAN, 'tan'], [Blockly.Msg.OPERATORS_MATHOP_ASIN, 'asin'],
[Blockly.Msg.OPERATORS_MATHOP_ASIN, 'asin'], [Blockly.Msg.OPERATORS_MATHOP_ACOS, 'acos'],
[Blockly.Msg.OPERATORS_MATHOP_ACOS, 'acos'], [Blockly.Msg.OPERATORS_MATHOP_ATAN, 'atan'],
[Blockly.Msg.OPERATORS_MATHOP_ATAN, 'atan'], [Blockly.Msg.OPERATORS_MATHOP_LN, 'ln'],
[Blockly.Msg.OPERATORS_MATHOP_LN, 'ln'], [Blockly.Msg.OPERATORS_MATHOP_LOG, 'log'],
[Blockly.Msg.OPERATORS_MATHOP_LOG, 'log'], [Blockly.Msg.OPERATORS_MATHOP_EEXP, 'e ^'],
[Blockly.Msg.OPERATORS_MATHOP_EEXP, 'e ^'], [Blockly.Msg.OPERATORS_MATHOP_10EXP, '10 ^']
[Blockly.Msg.OPERATORS_MATHOP_10EXP, '10 ^'] ]
] },
}, {
{ "type": "input_value",
"type": "input_value", "name": "NUM"
"name": "NUM" }
} ],
], "category": Blockly.Categories.operators,
"category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"]
"extensions": ["colours_operators", "output_number"] });
});
} }
}; };

View file

@ -200,7 +200,7 @@ Blockly.ScratchBlocks.ProcedureUtils.removeAllInputs_ = function() {
*/ */
Blockly.ScratchBlocks.ProcedureUtils.createAllInputs_ = function(connectionMap) { Blockly.ScratchBlocks.ProcedureUtils.createAllInputs_ = function(connectionMap) {
// Split the proc into components, by %n, %b, and %s (ignoring escaped). // Split the proc into components, by %n, %b, and %s (ignoring escaped).
var procComponents = this.procCode_.split(/(?=[^\\]\%[nbs])/); var procComponents = this.procCode_.split(/(?=[^\\]%[nbs])/);
procComponents = procComponents.map(function(c) { procComponents = procComponents.map(function(c) {
return c.trim(); // Strip whitespace. return c.trim(); // Strip whitespace.
}); });

View file

@ -54,21 +54,20 @@ Blockly.Blocks['sensing_touchingobjectmenu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "TOUCHINGOBJECTMENU",
"name": "TOUCHINGOBJECTMENU", "options": [
"options": [ [Blockly.Msg.SENSING_TOUCHINGOBJECT_POINTER, '_mouse_'],
[Blockly.Msg.SENSING_TOUCHINGOBJECT_POINTER, '_mouse_'], [Blockly.Msg.SENSING_TOUCHINGOBJECT_EDGE, '_edge_']
[Blockly.Msg.SENSING_TOUCHINGOBJECT_EDGE, '_edge_'] ]
] }
} ],
], "extensions": ["colours_sensing", "output_string"]
"extensions": ["colours_sensing", "output_string"] });
});
} }
}; };
@ -142,20 +141,19 @@ Blockly.Blocks['sensing_distancetomenu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "DISTANCETOMENU",
"name": "DISTANCETOMENU", "options": [
"options": [ [Blockly.Msg.SENSING_DISTANCETO_POINTER, '_mouse_']
[Blockly.Msg.SENSING_DISTANCETO_POINTER, '_mouse_'] ]
] }
} ],
], "extensions": ["colours_sensing", "output_string"]
"extensions": ["colours_sensing", "output_string"] });
});
} }
}; };
@ -409,21 +407,20 @@ Blockly.Blocks['sensing_of_object_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "OBJECT",
"name": "OBJECT", "options": [
"options": [ ['Sprite1', 'Sprite1'],
['Sprite1', 'Sprite1'], ['Stage', '_stage_']
['Stage', '_stage_'] ]
] }
} ],
], "extensions": ["colours_sensing", "output_string"]
"extensions": ["colours_sensing", "output_string"] });
});
} }
}; };

View file

@ -33,32 +33,31 @@ Blockly.Blocks['sound_sounds_menu'] = {
* @this Blockly.Block * @this Blockly.Block
*/ */
init: function() { init: function() {
this.jsonInit( this.jsonInit({
{ "message0": "%1",
"message0": "%1", "args0": [
"args0": [ {
{ "type": "field_dropdown",
"type": "field_dropdown", "name": "SOUND_MENU",
"name": "SOUND_MENU", "options": [
"options": [ ['1', '0'],
['1', '0'], ['2', '1'],
['2', '1'], ['3', '2'],
['3', '2'], ['4', '3'],
['4', '3'], ['5', '4'],
['5', '4'], ['6', '5'],
['6', '5'], ['7', '6'],
['7', '6'], ['8', '7'],
['8', '7'], ['9', '8'],
['9', '8'], ['10', '9']
['10', '9'] ]
] }
} ],
], "colour": Blockly.Colours.sounds.secondary,
"colour": Blockly.Colours.sounds.secondary, "colourSecondary": Blockly.Colours.sounds.secondary,
"colourSecondary": Blockly.Colours.sounds.secondary, "colourTertiary": Blockly.Colours.sounds.tertiary,
"colourTertiary": Blockly.Colours.sounds.tertiary, "extensions": ["output_string"]
"extensions": ["output_string"] });
});
} }
}; };

View file

@ -223,10 +223,10 @@ Blockly.ScratchBlocks.VerticalExtensions.SCRATCH_EXTENSION = function() {
Blockly.ScratchBlocks.VerticalExtensions.registerAll = function() { Blockly.ScratchBlocks.VerticalExtensions.registerAll = function() {
var categoryNames = var categoryNames =
['control', 'data', 'data_lists', 'sounds', 'motion', 'looks', 'event', ['control', 'data', 'data_lists', 'sounds', 'motion', 'looks', 'event',
'sensing', 'pen', 'operators', 'more']; 'sensing', 'pen', 'operators', 'more'];
// Register functions for all category colours. // Register functions for all category colours.
for (var i = 0; i < categoryNames.length; i++) { for (var i = 0; i < categoryNames.length; i++) {
name = categoryNames[i]; var name = categoryNames[i];
Blockly.Extensions.register('colours_' + name, Blockly.Extensions.register('colours_' + name,
Blockly.ScratchBlocks.VerticalExtensions.colourHelper(name)); Blockly.ScratchBlocks.VerticalExtensions.colourHelper(name));
} }
@ -259,7 +259,7 @@ Blockly.ScratchBlocks.VerticalExtensions.registerAll = function() {
// Extension blocks have slightly different block rendering. // Extension blocks have slightly different block rendering.
Blockly.Extensions.register('scratch_extension', Blockly.Extensions.register('scratch_extension',
Blockly.ScratchBlocks.VerticalExtensions.SCRATCH_EXTENSION); Blockly.ScratchBlocks.VerticalExtensions.SCRATCH_EXTENSION);
}; };
Blockly.ScratchBlocks.VerticalExtensions.registerAll(); Blockly.ScratchBlocks.VerticalExtensions.registerAll();