Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
- <link
- rel="stylesheet"
- href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
- integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
- crossorigin="anonymous"
- />
- <style>
- #text-container {
- margin: 20px;
- padding: 20px;
- background-color: #f2f2f2;
- border-radius: 10px;
- text-align: center;
- font-size: 1.2em;
- }
- </style>
- <br><br>
- <title>Gerador de Texto</title>
- </head>
- <body>
- <div class="container">
- <h1 class="text-center">Gerador de Texto</h1>
- <div class="form-group">
- <label for="num-paragraphs">Número de Parágrafos:</label>
- <input
- type="number"
- class="form-control"
- id="num-paragraphs"
- value="1"
- />
- </div>
- <button
- type="button"
- class="btn btn-primary mb-2"
- id="generate-btn"
- onclick="generateText()"
- >
- Gerar Texto
- </button>
- <button
- type="button"
- class="btn btn-secondary mb-2"
- id="copy-btn"
- onclick="copyText()"
- disabled
- >
- Copiar para Área de Transferência
- </button>
- <div id="text-container"></div>
- </div>
- <script>
- const textContainer = document.getElementById("text-container");
- const numParagraphsInput = document.getElementById("num-paragraphs");
- const generateBtn = document.getElementById("generate-btn");
- const copyBtn = document.getElementById("copy-btn");
- const loremIpsum =
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla paratur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
- function generateText() {
- textContainer.innerHTML = "";
- let numParagraphs = numParagraphsInput.value;
- for (let i = 0; i < numParagraphs; i++) {
- let p = document.createElement("p");
- p.innerHTML = loremIpsum;
- textContainer.appendChild(p);
- }
- copyBtn.disabled = false;
- }
- function copyText() {
- let text = textContainer.innerText;
- navigator.clipboard.writeText(text);
- alert("Texto copiado com sucesso!");
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement