mattebot / Polypad

Issue Tracker for Polypad
https://polypad.io
6 stars 1 forks source link

Lorem Ipsum generator #4

Open rasheqrahman opened 2 years ago

rasheqrahman commented 2 years ago

I am trying to find the Lorem Ipsum generator. Where is it?

mpurham commented 2 years ago

Hi @rasheqrahman down below is an example of the lorem ispum script

/*
    name: Lorem Ipsum
    description: Generates Lorem Ipsum text
    author: Marcell
    tags: generate,lorem,ipsum,text
*/

function main(input) {
    const words = ["Non", "ullamco", "ad", "nulla", "laboris", "amet", "dolore", "deserunt", "non", "enim", "ea", "ipsum", "ex", "labore", "deserunt", "irure", "qui", "eiusmod", "enim", "aute", "eiusmod", "cillum", "ad", "et", "in", "laboris", "reprehenderit", "ea", "mollit", "anim", "mollit", "veniam", "cillum", "magna", "officia", "nulla", "irure", "exercitation", "commodo", "aliquip", "ad", "anim", "culpa", "exercitation", "labore", "in", "velit", "Lorem", "deserunt", "excepteur", "amet", "Lorem", "fugiat", "qui", "anim", "est", "occaecat", "ex", "amet", "culpa", "exercitation", "elit", "reprehenderit", "enim", "adipisicing", "sit", "exercitation", "dolore", "adipisicing", "amet", "proident", "duis", "Lorem", "minim", "cupidatat", "commodo", "amet", "reprehenderit", "mollit", "dolore", "quis", "laboris", "ipsum", "ipsum", "aute", "veniam", "nisi", "culpa", "aliqua", "laborum", "cupidatat", "labore", "excepteur", "nostrud", "nulla", "dolore", "elit", "magna", "labore", "dolore"];

    let sentence = "";

    for (let i = 0; i < 100; i++) {
        const pos = Math.floor(Math.random() * (words.length - 1));
        sentence += words[pos] + " ";
    }

    sentence = sentence.charAt(0).toUpperCase() + sentence.slice(1).trim() + ".";

    input.text = sentence;
}

If you would like to have the ability to generate paragraphs you could add an additional loop. Hope the above helps