-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lorem Ipsum Generator.js
105 lines (93 loc) · 4.65 KB
/
Lorem Ipsum Generator.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
class LoremIpsumGenerator {
getInfo() {
return {
id: 'loremipsumgenerator',
name: 'Lorem Ipsum Generator',
blocks: [
{
opcode: 'generateLoremIpsumParagraphs',
blockType: 'reporter',
text: 'generate Lorem Ipsum paragraphs [numOfParagraphs]',
arguments: {
numOfParagraphs: {
type: 'number',
defaultValue: 1
}
}
},
{
opcode: 'generateLoremIpsumWords',
blockType: 'reporter',
text: 'generate Lorem Ipsum words [numOfWords]',
arguments: {
numOfWords: {
type: 'number',
defaultValue: 10
}
}
}
]
};
}
generateLoremIpsumParagraphs(args) {
const numOfParagraphs = Math.max(1, Math.min(args.numOfParagraphs, 10));
const paragraphs = [];
for (let i = 0; i < numOfParagraphs; i++) {
paragraphs.push(this.generateLoremIpsumParagraph());
}
return paragraphs.join('\n\n');
}
generateLoremIpsumParagraph() {
const sentences = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Praesent luctus odio at facilisis fringilla.',
'Morbi fringilla neque ut lacus pellentesque, in finibus est eleifend.',
'Nunc ultricies massa a felis dignissim, a facilisis elit dapibus.',
'Sed ullamcorper mauris ac cursus gravida.',
'Proin a mauris vitae nisi tempus fermentum.',
'Fusce vestibulum semper lectus, sit amet viverra purus efficitur at.',
'Integer sit amet leo nec mauris facilisis ultrices.',
'Vestibulum rhoncus erat sed efficitur aliquam.',
'Maecenas tincidunt ligula a eleifend congue.',
'Nam ac felis sed arcu laoreet consectetur.',
'Vivamus ut orci et mauris posuere pretium sed at tortor.',
'Nullam ac ante vitae odio fermentum scelerisque.',
'Suspendisse potenti. In ac elit eget sapien varius tristique.',
'Vestibulum sed velit ultricies, rutrum ipsum id, venenatis mauris.'
];
const paragraphLength = Math.floor(Math.random() * 4) + 3; // Random paragraph length between 3 and 6 sentences
const paragraphSentences = [];
for (let i = 0; i < paragraphLength; i++) {
const randomIndex = Math.floor(Math.random() * sentences.length);
paragraphSentences.push(sentences[randomIndex]);
}
return paragraphSentences.join(' ');
}
generateLoremIpsumWords(args) {
const numOfWords = Math.max(1, Math.min(args.numOfWords, 100));
const words = [
'Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit',
'Praesent', 'luctus', 'odio', 'at', 'facilisis', 'fringilla',
'Morbi', 'fringilla', 'neque', 'ut', 'lacus', 'pellentesque', 'in', 'finibus', 'est', 'eleifend',
'Nunc', 'ultricies', 'massa', 'a', 'felis', 'dignissim', 'a', 'facilisis', 'elit', 'dapibus',
'Sed', 'ullamcorper', 'mauris', 'ac', 'cursus', 'gravida',
'Proin', 'a', 'mauris', 'vitae', 'nisi', 'tempus', 'fermentum',
'Fusce', 'vestibulum', 'semper', 'lectus', 'sit', 'amet', 'viverra', 'purus', 'efficitur', 'at',
'Integer', 'sit', 'amet', 'leo', 'nec', 'mauris', 'facilisis', 'ultrices',
'Vestibulum', 'rhoncus', 'erat', 'sed', 'efficitur', 'aliquam',
'Maecenas', 'tincidunt', 'ligula', 'a', 'eleifend', 'congue',
'Nam', 'ac', 'felis', 'sed', 'arcu', 'laoreet', 'consectetur',
'Vivamus', 'ut', 'orci', 'et', 'mauris', 'posuere', 'pretium', 'sed', 'at', 'tortor',
'Nullam', 'ac', 'ante', 'vitae', 'odio', 'fermentum', 'scelerisque',
'Suspendisse', 'potenti', 'In', 'ac', 'elit', 'eget', 'sapien', 'varius', 'tristique',
'Vestibulum', 'sed', 'velit', 'ultricies', 'rutrum', 'ipsum', 'id', 'venenatis', 'mauris'
];
const loremIpsumWords = [];
for (let i = 0; i < numOfWords; i++) {
const randomIndex = Math.floor(Math.random() * words.length);
loremIpsumWords.push(words[randomIndex]);
}
return loremIpsumWords.join(' ');
}
}
Scratch.extensions.register(new LoremIpsumGenerator());