Created
September 9, 2021 18:54
-
-
Save ErickPetru/664cdf65c4277cffc3b2a808b8b1da38 to your computer and use it in GitHub Desktop.
Exibe, no documento Word aberto, todos os números pares existentes dentro do intervalo numérico especificado pelo usuário.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pares no Intervalo Especificado | |
description: >- | |
Exibe, no documento Word aberto, todos os números pares existentes dentro do | |
intervalo numérico especificado pelo usuário. | |
host: WORD | |
api_set: {} | |
script: | |
content: "const field1 = document.getElementById(\"field1\") as HTMLInputElement;\r\nconst field2 = document.getElementById(\"field2\") as HTMLInputElement;\r\nconst show = document.getElementById(\"show\") as HTMLButtonElement;\r\n\r\nshow.addEventListener(\"click\", () => {\r\n Word.run(async (context) => {\r\n const body = context.document.body;\r\n body.clear();\r\n\r\n const n1 = parseFloat(field1.value);\r\n const n2 = parseFloat(field2.value);\r\n\r\n if (isNaN(n1) || isNaN(n2)) {\r\n body.insertText(\"Informe dois números válidos!\", \"Start\");\r\n return;\r\n }\r\n\r\n for (let i = n1; i <= n2; i++) {\r\n if (i % 2 == 0) {\r\n body.insertText(`${i}`, \"End\");\r\n body.insertBreak(\"Line\", \"End\");\r\n }\r\n }\r\n });\r\n});\r\n" | |
language: typescript | |
template: | |
content: "<input id=\"field1\" placeholder=\"Número inicial\">\r\n<input id=\"field2\" placeholder=\"Número final\">\r\n<button id=\"show\">Exibir Pares no Intervalo</button>" | |
language: html | |
style: | |
content: '' | |
language: css | |
libraries: |- | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/client/core.min.js | |
@types/core-js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment