Skip to content
This repository was archived by the owner on Jul 24, 2019. It is now read-only.

Commit b0acb94

Browse files
McSamMcSam
authored andcommitted
search feature
1 parent 5fd47c7 commit b0acb94

File tree

21 files changed

+429
-81
lines changed

21 files changed

+429
-81
lines changed

src/scratch/blocks/Advanced/Functions/procedures_callnoreturn.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ Blockly.Blocks.procedures_callnoreturn = {
77
this.argumentVarModels = [];
88
this.previousDisabledState = false;
99

10-
this.jsonInit({
10+
this.jsonInit(this.definition());
11+
},
12+
/**
13+
* Block definitions describe how a block looks and behaves, including the text,
14+
* the colour, the shape, and what other blocks it can connect to. We've separated
15+
* the block definition from the init function so we can search through it.
16+
* https://developers.google.com/blockly/guides/create-custom-blocks/define-blocks
17+
*/
18+
definition() {
19+
return {
1120
message0: '%1 %2',
1221
args0 : [
1322
{
@@ -25,7 +34,20 @@ Blockly.Blocks.procedures_callnoreturn = {
2534
colourTertiary : Blockly.Colours.BinaryProcedures.colourTertiary,
2635
previousStatement: null,
2736
nextStatement : null,
28-
});
37+
tooltip : translate('Function with no return value tooltip'),
38+
category : translate('functions'),
39+
};
40+
},
41+
/**
42+
* Meta returns an object with with properties that contain human readable strings,
43+
* these strings are used in the flyout help content, as well as used for searching
44+
* for specific blocks.
45+
*/
46+
meta() {
47+
return {
48+
'display_name': translate('Function With no Return name'),
49+
'description' : translate('Function with no return value description'),
50+
};
2951
},
3052
/**
3153
* Procedure calls cannot exist without the corresponding procedure

src/scratch/blocks/Advanced/Functions/procedures_defnoreturn.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,20 @@ Blockly.Blocks.procedures_defnoreturn = {
77
this.arguments = [];
88
this.argumentVarModels = [];
99

10-
this.jsonInit({
10+
this.jsonInit(this.definition());
11+
12+
// Enforce unique procedure names
13+
const nameField = this.getField('NAME');
14+
nameField.setValidator(Blockly.Procedures.rename);
15+
16+
// Render a ➕-icon for adding parameters
17+
const fieldImage = new Blockly.FieldImage(plusIconLight, 24, 24, '+', () => this.onAddClick());
18+
this.appendDummyInput('ADD_ICON').appendField(fieldImage);
19+
20+
this.setStatements(true);
21+
},
22+
definition() {
23+
return {
1124
message0: translate('function %1 %2'),
1225
args0 : [
1326
{
@@ -24,17 +37,15 @@ Blockly.Blocks.procedures_defnoreturn = {
2437
colour : Blockly.Colours.BinaryProcedures.colour,
2538
colourSecondary: Blockly.Colours.BinaryProcedures.colourSecondary,
2639
colourTertiary : Blockly.Colours.BinaryProcedures.colourTertiary,
27-
});
28-
29-
// Enforce unique procedure names
30-
const nameField = this.getField('NAME');
31-
nameField.setValidator(Blockly.Procedures.rename);
32-
33-
// Render a ➕-icon for adding parameters
34-
const fieldImage = new Blockly.FieldImage(plusIconLight, 24, 24, '+', () => this.onAddClick());
35-
this.appendDummyInput('ADD_ICON').appendField(fieldImage);
36-
37-
this.setStatements(true);
40+
tooltip : translate('function with no return tooltip'),
41+
category : translate('functions'),
42+
};
43+
},
44+
meta() {
45+
return {
46+
'display_name': translate('Function with no return value'),
47+
'description' : translate('Function with no return value description'),
48+
};
3849
},
3950
/**
4051
* Sets the block colour and updates this procedure's caller blocks

src/scratch/blocks/Binary/After Purchase/after_purchase.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { translate } from '../../../../utils/lang/i18n';
44

55
Blockly.Blocks.after_purchase = {
66
init() {
7-
this.jsonInit({
7+
this.jsonInit(this.definition());
8+
},
9+
definition(){
10+
return {
811
message0: translate('%1 (4) Get your trade result and trade again %2'),
912
message1: '%1',
1013
args0 : [
@@ -32,7 +35,14 @@ Blockly.Blocks.after_purchase = {
3235
tooltip : translate(
3336
'Get the previous trade information and result, then trade again (Runs on trade finish)'
3437
),
35-
});
38+
category: translate('after-purchase'),
39+
};
40+
},
41+
meta(){
42+
return {
43+
'display_name': 'After Purchase',
44+
'description' : 'After Purchase Description',
45+
};
3646
},
3747
onchange(event) {
3848
setBlockTextColor(this);

src/scratch/blocks/Binary/Before Purchase/before_purchase.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { translate } from '../../../../utils/lang/i18n';
44

55
Blockly.Blocks.before_purchase = {
66
init() {
7-
this.jsonInit({
7+
this.jsonInit(this.definition());
8+
},
9+
definition() {
10+
return {
811
message0: translate('%1 (2) Watch and purchase your contract %2'),
912
message1: '%1',
1013
args0 : [
@@ -30,7 +33,14 @@ Blockly.Blocks.before_purchase = {
3033
colourSecondary: Blockly.Colours.Binary.colourSecondary,
3134
colourTertiary : Blockly.Colours.Binary.colourTertiary,
3235
tooltip : translate('Watch the tick stream and purchase the desired contract (Runs on tick update)'),
33-
});
36+
category : translate('before-purchase'),
37+
};
38+
},
39+
meta(){
40+
return {
41+
'display_name': translate('Before Purchase'),
42+
'description' : translate('Before Purchase Description'),
43+
};
3444
},
3545
onchange(event) {
3646
setBlockTextColor(this);

src/scratch/blocks/Binary/During Purchase/during_purchase.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { translate } from '../../../../utils/lang/i18n';
44

55
Blockly.Blocks.during_purchase = {
66
init() {
7-
this.jsonInit({
7+
this.jsonInit(this.definition());
8+
},
9+
definition(){
10+
return {
811
message0: translate('%1 (3) Watch and sell your purchased contract %2'),
912
message1: '%1',
1013
args0 : [
@@ -32,7 +35,14 @@ Blockly.Blocks.during_purchase = {
3235
tooltip : translate(
3336
'Watch the purchased contract info and sell at market if available (Runs on contract update)'
3437
),
35-
});
38+
category: translate('during-purchase'),
39+
};
40+
},
41+
meta(){
42+
return {
43+
'display_name': translate('During Purchase'),
44+
'description' : translate('During Purchase Description'),
45+
};
3646
},
3747
onchange(event) {
3848
setBlockTextColor(this);

src/scratch/blocks/Binary/Indicators/bb_statement.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { translate } from '../../../../utils/lang/i18n';
44

55
Blockly.Blocks.bb_statement = {
66
init() {
7-
this.jsonInit({
7+
this.jsonInit(this.definition());
8+
},
9+
definition(){
10+
return {
811
message0: translate('set %1 to Bollinger Bands %2 %3'),
912
message1: '%1',
1013
args0 : [
@@ -35,7 +38,14 @@ Blockly.Blocks.bb_statement = {
3538
tooltip : translate('Calculates Bollinger Bands (BB) from a list with a period'),
3639
previousStatement: null,
3740
nextStatement : null,
38-
});
41+
category : translate('indicators'),
42+
};
43+
},
44+
meta(){
45+
return {
46+
'display_name': translate('BB Statement'),
47+
'descriptionL': translate('BB Statement Description'),
48+
};
3949
},
4050
onchange(event) {
4151
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

src/scratch/blocks/Binary/Tick Analysis/last_digit.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ import { translate } from '../../../../utils/lang/i18n';
22

33
Blockly.Blocks.last_digit = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0 : translate('Last Digit'),
710
output : 'Number',
811
outputShape : Blockly.OUTPUT_SHAPE_ROUND,
912
colour : Blockly.Colours.Binary.colour,
1013
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1114
colourTertiary : Blockly.Colours.Binary.colourTertiary,
1215
tooltip : translate('Returns the last digit of the latest tick'),
13-
});
16+
category : translate('tick-analysis'),
17+
};
18+
},
19+
meta(){
20+
return {
21+
'display_name': translate('Last Digit'),
22+
'description' : translate('Last Digit Description'),
23+
};
1424
},
1525
onchange(event) {
1626
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {

src/scratch/blocks/Binary/Tools/Candle/ohlc_values_in_list.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { translate } from '../../../../../utils/lang/i18n';
33

44
Blockly.Blocks.ohlc_values_in_list = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
},
8+
definition(){
9+
return {
710
message0: translate('Make a list of %1 values from candles list %2'),
811
args0 : [
912
{
@@ -22,7 +25,14 @@ Blockly.Blocks.ohlc_values_in_list = {
2225
colourSecondary: Blockly.Colours.Binary.colourSecondary,
2326
colourTertiary : Blockly.Colours.Binary.colourTertiary,
2427
tooltip : translate('Returns a list of the selected candle values'),
25-
});
28+
category : translate('candle'),
29+
};
30+
},
31+
meta(){
32+
return {
33+
'display_name': translate('Selected Candle list value'),
34+
'description' : translate('Selected Candle list value description'),
35+
};
2636
},
2737
};
2838

src/scratch/blocks/Binary/Tools/Misc./notify.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { translate } from '../../../../../utils/lang/i18n';
33

44
Blockly.Blocks.notify = {
55
init() {
6-
this.jsonInit({
6+
this.jsonInit(this.definition());
7+
},
8+
definition(){
9+
return {
710
message0: translate('Notify %1 with sound: %2 %3'),
811
args0 : [
912
{
@@ -28,7 +31,14 @@ Blockly.Blocks.notify = {
2831
previousStatement: null,
2932
nextStatement : null,
3033
tooltip : translate('Creates a notification'),
31-
});
34+
cateogry : translate('misc'),
35+
};
36+
},
37+
meta(){
38+
return {
39+
'display_name': translate('Pop out notify'),
40+
'description' : translate('Pop out notify description'),
41+
};
3242
},
3343
};
3444

src/scratch/blocks/Binary/Tools/Time/epoch.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ import { translate } from '../../../../../utils/lang/i18n';
22

33
Blockly.Blocks.epoch = {
44
init() {
5-
this.jsonInit({
5+
this.jsonInit(this.definition());
6+
},
7+
definition(){
8+
return {
69
message0 : translate('Seconds Since Epoch'),
710
output : 'Number',
811
outputShape : Blockly.OUTPUT_SHAPE_ROUND,
912
colour : Blockly.Colours.Binary.colour,
1013
colourSecondary: Blockly.Colours.Binary.colourSecondary,
1114
colourTertiary : Blockly.Colours.Binary.colourTertiary,
1215
tooltip : translate('Returns the epoch time (seconds since epoch)'),
13-
});
16+
category : translate('time'),
17+
};
18+
},
19+
meta(){
20+
return {
21+
'display_name': translate('Second Since Epoch'),
22+
'description' : translate('Seconds Since Epoch Decription'),
23+
};
1424
},
1525
};
1626

0 commit comments

Comments
 (0)