Created
September 15, 2021 00:43
-
-
Save ErickPetru/2a4c5315c0befc40daae989dd8c03ff5 to your computer and use it in GitHub Desktop.
Calcula a tabuada do valor informado no Suplemento e exibe no documento Word aberto.
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: Tabuada com For | |
description: >- | |
Calcula a tabuada do valor informado no Suplemento e exibe no documento Word | |
aberto. | |
host: WORD | |
api_set: {} | |
script: | |
content: "const calculate = document.getElementById(\"calculate\") as HTMLButtonElement;\r\nconst field = document.getElementById(\"field\") as HTMLInputElement;\r\n\r\ncalculate.addEventListener(\"click\", () => {\r\n Word.run(async (context) => {\r\n const body = context.document.body;\r\n body.clear();\r\n\r\n const n = parseFloat(field.value);\r\n\r\n if (isNaN(n)) {\r\n body.insertText(\"Somente números são aceitos!\", \"Start\");\r\n return;\r\n }\r\n\r\n for (let i = 0; i <= 10; i++) {\r\n body.insertText(`${n} × ${i} = ${n * i}`, \"End\");\r\n body.insertBreak(\"Line\", \"End\")\r\n }\r\n });\r\n});\r\n" | |
language: typescript | |
template: | |
content: "<input id=\"field\" placeholder=\"Informe um número\">\r\n<button id=\"calculate\">Tabuada</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