Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bolso.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">

<script type="text/javascript" src="main.js"></script>
<title>E06</title>
</head>
<body>
<header class="row">
<div class="col-12">
<h1>E10</h1>
</div>
</header>
<div class="row">
<div class="col-4">
<h2>Tabela</h2>
<textarea rows="15" cols="43"></textarea>
</br>
<button class="btn btn-dark" onclick="resultado();">RESULTADO</button>
<table >
<tr>
<td></td>
</tr>
</table>
</div>
<div class="col-4">
<h2>GetName</h2>
<textarea rows="5" cols="43"></textarea>
</br>
<button class="btn btn-dark" onclick="getByName();">RESULTADO</button>
</div>
<div id="div1" class="col-4">
<h2>Esconder imagens</h2>
<img src="bolso.jpg" alt="bozo"></img>
<img src="lula.jpg" alt="lula"></img>
<button class="btn btn-dark" onclick="transformaImg();">ESCONDER</button>
</div>
</div>
</body>
</html>
Binary file added lula.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function transformaImg(){
//Remover as imagens
var pai = document.getElementById("div1");
var filho = document.getElementsByTagName("img");
while(filho.length > 0){
console.log(filho.length);
pai.removeChild(filho[0]);
}

//descrição da imagem 1
var QuebraLinha = document.createElement("br");
var criaElem = document.createElement("p");
var node = document.createTextNode("Bozo");
criaElem.appendChild(node);
criaElem.appendChild(QuebraLinha);
var elem = document.getElementsByTagName("div");
elem[0].appendChild(criaElem);

//descrição da imagem 2
QuebraLinha = document.createElement("br");
criaElem = document.createElement("p");
node = document.createTextNode("lula");
criaElem.appendChild(node);
criaElem.appendChild(QuebraLinha);
elem = document.getElementsByTagName("div");
elem[0].appendChild(criaElem);
}

function transformaTexto(texto){
var vetorTexto=[];
var lines = texto.split('\n');
for(i=0; i < lines.length; i++){
vetorTexto[i] = lines[i].split(',');
}
return vetorTexto;
}

function resultado(){
var tbl = document.getElementsByTagName("table")[0];
var text = document.getElementsByTagName("textarea")[0].value;
var Tabela = transformaTexto(text);
while(tbl.childNodes.length>0){
tbl.removeChild(tbl.childNodes[0]);
}
for(i = 0; i < Tabela.length;i++){
var li = document.createElement("tr");
for( w = 0; w < Tabela[i].length; w++){
var colunas = document.createElement("td");
var value = document.createTextNode(Tabela[i][w]);
colunas.appendChild(value);
li.appendChild(colunas);
}
tbl.appendChild(li);

}
}

function getByName(elem)
{
var array = []
busca(document.body, elem.toUpperCase(), array)
return array
}

function busca(node, tag, arrayElements)
{
for (var filho of node.childNodes)
{
if (filho.childNodes.length != 0)
{
busca(filho, tag, arrayElements)
}
if (filho.tagName == tag)
{
arrayElements.push(filho)
}
}
return arrayElements
}
27 changes: 27 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
*{
margin: auto;
padding: 10px;
}

header{
display: block;
position: center;
background-color: aliceblue;
}


h1{
color: rgb(226, 143, 222);
position: center;
display: block;
}

h2{
position: center;
}

img{
height: 200px;
width: 200px;
}