From 6ddf7b4079d376a131283c26897eef2875be7b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=98=CE=B1=CE=BB=CE=B7=CF=83?= <104565512+Thalesed@users.noreply.github.com> Date: Fri, 5 May 2023 08:59:52 -0300 Subject: [PATCH 1/3] Add files via upload --- index.html | 25 +++++++++++++++++++ main.js | 29 ++++++++++++++++++++++ style.css | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 index.html create mode 100644 main.js create mode 100644 style.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..406d612 --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + + Teste de Árvore DOM + + + + + +

Teste

+
+ + + +
+ +
+ +
+ +
+ + + \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..ad0c7ca --- /dev/null +++ b/main.js @@ -0,0 +1,29 @@ +function convertToTable() { + // Obter o texto do CSV a partir do campo de texto + const csvText = document.getElementById("csv-text").value; + + // Analisar o CSV para obter uma matriz de dados + const data = Papa.parse(csvText).data; + + // Criar a tabela HTML + const table = document.createElement("table"); + const tbody = document.createElement("tbody"); + + // Adicionar as linhas da tabela + for (let i = 0; i < data.length; i++) { + const row = document.createElement("tr"); + + for (let j = 0; j < data[i].length; j++) { + const cell = document.createElement("td"); + cell.textContent = data[i][j]; + row.appendChild(cell); + } + + tbody.appendChild(row); + } + + // Adicionar a tabela ao contêiner + table.appendChild(tbody); + document.getElementById("table-container").appendChild(table); + } + \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..8568984 --- /dev/null +++ b/style.css @@ -0,0 +1,70 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + text-align: center; + background-color: #c0bcbc; + } + + h1 { + font-size: 36px; + font-weight: bold; + margin-bottom: 20px; + text-decoration: underline; +} + + form { + display: flex; + flex-direction: column; + align-items: center; + margin-top: 30px; + } + + label { + font-size: 1.2rem; + } + + textarea { + width: 20%; + height: 150px; + margin-top: 10px; + padding: 10px; + font-size: 1.2rem; + border-radius: 5px; + border: 1px solid #ccc; + background-color: rgb(226, 221, 221); + } + + button { + margin-top: 10px; + padding: 10px; + font-size: 1.2rem; + background-color: #4CAF50; + color: white; + border: none; + border-radius: 5px; + cursor: pointer; + } + + button:hover { + background-color: #3e8e41; + } + + table { + margin: 0 auto; + border-collapse: collapse; + margin-top: 30px; + width: 20%; + } + + td, th { + padding: 8px; + text-align: left; + border-bottom: 1px solid #ddd; + } + + th { + background-color: #4CAF50; + color: white; + } + \ No newline at end of file From a642ff76fe7f7d588109ab1020e63f1ee63da214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=98=CE=B1=CE=BB=CE=B7=CF=83?= <104565512+Thalesed@users.noreply.github.com> Date: Fri, 5 May 2023 09:01:39 -0300 Subject: [PATCH 2/3] Add files via upload --- ex2.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ex2.js diff --git a/ex2.js b/ex2.js new file mode 100644 index 0000000..ea5b735 --- /dev/null +++ b/ex2.js @@ -0,0 +1,13 @@ +function getElementsByTagName(tag) { + const elements = document.getElementsByTagName("*"); + const filteredElements = []; + + for (let i = 0; i < elements.length; i++) { + if (elements[i].tagName === tag.toUpperCase()) { + filteredElements.push(elements[i]); + } + } + + return filteredElements; + } + \ No newline at end of file From 3d635769201af79d7c77785020d2c106ad203270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=98=CE=B1=CE=BB=CE=B7=CF=83?= <104565512+Thalesed@users.noreply.github.com> Date: Fri, 5 May 2023 09:02:51 -0300 Subject: [PATCH 3/3] Add files via upload --- ex3.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ex3.js diff --git a/ex3.js b/ex3.js new file mode 100644 index 0000000..e725aec --- /dev/null +++ b/ex3.js @@ -0,0 +1,13 @@ +// Seleciona todos os elementos da página +const images = document.getElementsByTagName("img"); + +// Itera sobre todas as imagens +for (let i = 0; i < images.length; i++) { + // Cria um novo elemento contendo o texto de descrição da imagem + const altText = images[i].getAttribute("alt"); + const span = document.createElement("span"); + span.textContent = altText; + + // Substitui a imagem pelo novo elemento + images[i].parentNode.replaceChild(span, images[i]); +}