From 4bc8d77e0597781f0d497de9f90f025e8acc26b4 Mon Sep 17 00:00:00 2001 From: JeanBerly <68441010+JeanBerl@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:57:02 -0300 Subject: [PATCH 1/4] Lidando com tabelas feito --- atividade.js | 11 +++++++++++ index.html | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 atividade.js create mode 100644 index.html diff --git a/atividade.js b/atividade.js new file mode 100644 index 0000000..7ea9ba8 --- /dev/null +++ b/atividade.js @@ -0,0 +1,11 @@ +function fazTabela(){ + let texto = document.getElementById("entrada").value; + let arrayValores = texto.split(",") + let tabela = ``; + arrayValores.forEach((value) =>{ + tabela += ``; + }) + tabela += `
${value}
` + document.body.innerHTML += tabela; + console.log(tabela) +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..3e3ba3f --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + + + + E06-JS + + + +
+ + + \ No newline at end of file From 52618589e194a1dbbc5d8628f4605419f37a332a Mon Sep 17 00:00:00 2001 From: JeanBerly Date: Fri, 17 Jun 2022 10:57:53 -0300 Subject: [PATCH 2/4] getByName feito --- atividade.js | 16 ++++++++++++++++ index.html | 3 +++ 2 files changed, 19 insertions(+) diff --git a/atividade.js b/atividade.js index 7ea9ba8..0d6c446 100644 --- a/atividade.js +++ b/atividade.js @@ -8,4 +8,20 @@ function fazTabela(){ tabela += `` document.body.innerHTML += tabela; console.log(tabela) +} +// getByName(elem) +function getElementsByTagName(tag){ + let elementsWithTag = []; + recursiveSearch(document.body, tag, elementsWithTag); + return elementsWithTag; +} +function recursiveSearch(node, tag, arrayElements){ + if (node.childNodes.length != 0){ + node.childNodes.forEach((childNode) =>{ + if (childNode.tagName != undefined) recursiveSearch(childNode, tag, arrayElements); + }) + } + if (node.tagName == tag){ + arrayElements.push(node); + } } \ No newline at end of file diff --git a/index.html b/index.html index 3e3ba3f..367a821 100644 --- a/index.html +++ b/index.html @@ -16,5 +16,8 @@
+
+ +
\ No newline at end of file From b68f4bc9cc494e312d80eb2a3500f7ea49ca20d5 Mon Sep 17 00:00:00 2001 From: JeanBerly Date: Fri, 17 Jun 2022 11:29:43 -0300 Subject: [PATCH 3/4] Um texto vale mais que mil imagens... feito --- atividade.js | 10 ++++++++++ index.html | 1 + 2 files changed, 11 insertions(+) diff --git a/atividade.js b/atividade.js index 0d6c446..00245e0 100644 --- a/atividade.js +++ b/atividade.js @@ -24,4 +24,14 @@ function recursiveSearch(node, tag, arrayElements){ if (node.tagName == tag){ arrayElements.push(node); } +} +//Um texto vale mais que mil imagens +function replaceImageWithText(){ + let imagens = getElementsByTagName("IMG"); + for (let i = 0; i < imagens.length; i++) { + let parentNode = imagens[i].parentNode; + let span = document.createElement('span'); + span.appendChild(document.createTextNode(imagens[i].alt)); + parentNode.replaceChild(span, imagens[i]); + } } \ No newline at end of file diff --git a/index.html b/index.html index 367a821..3a5b052 100644 --- a/index.html +++ b/index.html @@ -19,5 +19,6 @@
+ teste \ No newline at end of file From c993a87aea9a3e767d0e838c6628e86d6c9a6628 Mon Sep 17 00:00:00 2001 From: JeanBerly <68441010+JeanBerl@users.noreply.github.com> Date: Mon, 20 Jun 2022 13:59:30 -0300 Subject: [PATCH 4/4] atualiza funcao do Lidando com tabelas --- atividade.js | 21 +++++++++++++++++---- index.html | 5 ++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/atividade.js b/atividade.js index 00245e0..0beef35 100644 --- a/atividade.js +++ b/atividade.js @@ -1,11 +1,24 @@ function fazTabela(){ let texto = document.getElementById("entrada").value; - let arrayValores = texto.split(",") + let arrayValores = texto.split("\n") let tabela = ``; - arrayValores.forEach((value) =>{ - tabela += ``; + arrayValores.forEach((row, index) =>{ + tabela += `` + let rowValues = row.split(","); + if (index == 0){ + rowValues.forEach((value) =>{ + tabela += `` + }); + tabela += `` + } + else{ + rowValues.forEach((value) =>{ + tabela += `` + }); + tabela += `` + } }) - tabela += `
${value}
${value}
${value}
` + tabela += `` document.body.innerHTML += tabela; console.log(tabela) } diff --git a/index.html b/index.html index 3a5b052..d419902 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,10 @@ -
+ +
+ +