-
Notifications
You must be signed in to change notification settings - Fork 538
Expand file tree
/
Copy pathstrings-2.js
More file actions
52 lines (51 loc) · 1.16 KB
/
strings-2.js
File metadata and controls
52 lines (51 loc) · 1.16 KB
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
class Strings2 {
getInfo() {
return {
id: 'strings2example',
name: Scratch.translate('Encoding'),
blocks: [
{
opcode: 'convert',
blockType: Scratch.BlockType.REPORTER,
text: Scratch.translate('convert [TEXT] to [FORMAT]'),
arguments: {
TEXT: {
type: Scratch.ArgumentType.STRING,
defaultValue: 'Apple'
},
FORMAT: {
type: Scratch.ArgumentType.STRING,
menu: 'FORMAT_MENU'
}
}
}
],
menus: {
FORMAT_MENU: {
acceptReporters: true,
// highlight-start
items: [
{
text: 'UPPERCASE',
value: 'up'
},
{
text: 'lowercase',
value: 'low'
}
]
// highlight-end
}
}
};
}
convert (args) {
// highlight-next-line
if (args.FORMAT === 'up') {
return args.TEXT.toString().toUpperCase();
} else {
return args.TEXT.toString().toLowerCase();
}
}
}
Scratch.extensions.register(new Strings2());