-
Notifications
You must be signed in to change notification settings - Fork 3
/
CustomBlocks.js
214 lines (198 loc) · 6.21 KB
/
CustomBlocks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
Blockly.Blocks['validate'] = {
init: function() {
this.appendValueInput("ar")
.setCheck("Array")
.appendField("text list");
this.appendValueInput("ar2")
.setCheck("Array")
.appendField("matching list");
this.setOutput("Boolean");
this.setColour(260);
this.setTooltip("vaildates that the strings are matching");
this.setHelpUrl("help.html#validate");
}
};
Blockly.Blocks['if_enter'] = {
init: function() {
this.appendStatementInput("NAME")
.setCheck(null)
.appendField("if enter");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(210);
this.setTooltip("returns true when the 'ENTER' button is pressed");
this.setHelpUrl("help.html#if_enter");
}
};
Blockly.Blocks['contains'] = {
init: function() {
this.appendDummyInput()
.appendField("contains")
.appendField(new Blockly.FieldTextInput("default"), "NAME");
this.setOutput(true, null);
this.setColour(210);
this.setTooltip("returns true if the attached block contains the 'default' string.");
this.setHelpUrl("help.html#contains");
}
};
Blockly.Blocks['socket_setup'] = {
init: function() {
this.appendStatementInput("socket_set_up")
.setCheck(null)
.appendField("bot setup");
this.setColour(15);
this.setTooltip("sets up sockets");
this.setHelpUrl("help.html#socket_setup");
}
};
Blockly.Blocks['initalizer'] = {
init: function() {
this.appendDummyInput()
.appendField("initialize varibles");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(100);
this.setTooltip("");
this.setHelpUrl("help.html#initialize_variables");
}
};
Blockly.Blocks['input'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput(""), "intromessage")
.appendField("introduction ");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setTooltip("sends first message to user");
this.setHelpUrl("help.html#input");
}
};
Blockly.Blocks['get_user_response'] = {
init: function() {
this.appendDummyInput()
.appendField("get user response");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(330);
this.setTooltip("");
this.setHelpUrl("help.html#get_user_resopnse");
}
};
Blockly.Blocks['response'] = {
init: function() {
this.appendDummyInput()
.appendField("response")
.appendField(new Blockly.FieldTextInput("default"), "userResponse");
this.setPreviousStatement(true, null);
this.setNextStatement(true, "String");
this.setColour(160);
this.setTooltip("");
this.setHelpUrl("help.html#response");
}
};
Blockly.Blocks['userresponsevarable'] = {
init: function() {
this.appendValueInput("User Response")
.setCheck("String")
.appendField("check user response");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setTooltip("");
this.setHelpUrl("help.html#check_user_response");
}
};
Blockly.Blocks['question_block'] = {
init: function() {
this.appendDummyInput()
.appendField("question")
.appendField(new Blockly.FieldTextInput(""), "Question they want to ask");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setTooltip("sends next question to user");
this.setHelpUrl("help.html#question_block");
}
};
Blockly.Blocks['send'] = {
init: function() {
this.appendDummyInput()
.appendField("send")
.appendField(new Blockly.FieldTextInput("URL"), "NAME");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("help.html#send");
}
};
Blockly.Blocks['end_sockets'] = {
init: function() {
this.appendDummyInput()
.appendField("end");
this.setPreviousStatement(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("help.html#end_sockets");
}
};
Blockly.Blocks['http_get'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("url for http GET request"), "url");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("Type URL you are requesting");
this.setHelpUrl("help.html#http_get");
}
};
Blockly.Blocks['http_put'] = {
init: function() {
this.appendValueInput("data")
.setCheck("String")
.appendField(new Blockly.FieldTextInput("the url for http PUT request"), "url");
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("Type the URL that you are sending the data to");
this.setHelpUrl("help.html#http_put");
}
};
Blockly.Blocks['language'] = {
init: function() {
this.appendValueInput("UseriNPUT")
.setCheck("String")
.appendField("language settings")
.appendField(new Blockly.FieldDropdown([["English","English"], ["Chinese","Chinese"], ["French","French"], ["German","German"], ["Russian","Russian"], ["Korean","Korean"], ["Janpan","Janpan"]]), "Lan");
this.setOutput(true, "required language mode");
this.setColour(330);
this.setTooltip("changes the language of the chatbot");
this.setHelpUrl("help.html#language");
}
};
// Blockly.Blocks['search_function'] = {
// init: function() {
// this.appendValueInput("User Input")
// .setCheck("String")
// .appendField("search with")
// .appendField(new Blockly.FieldDropdown([["Google","Google"], ["Bing","Bing"], ["Yahoo","Yahoo"]]), "NAME");
// this.setPreviousStatement(true, null);
// this.setNextStatement(true, null);
// this.setColour(230);
// this.setTooltip("searches the web with the selected search engine");
// this.setHelpUrl("help.html#search_function");
// }
// };
Blockly.Blocks['user_info_save'] = {
init: function() {
this.appendDummyInput()
.appendField("variable save ");
this.setOutput(true, "String");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("help.html#user_info_save");
}
};