Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (57 loc) · 1.84 KB
/
Copy pathscript.js
File metadata and controls
71 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
let campoResultado= document.getElementById("resultado")
let carinha = document.getElementById("carinha")
let outputtitulo= document.getElementById("outputtitulo")
let outputp= document.getElementById("outputp")
let botaoCopiar = document.getElementById("copiar");
function pegarValor(campo){
return document.getElementById(campo).value;
}
function decriptar(){
let texto = pegarValor("entrada");
let resultado = texto.replace(/ai/gi,"a")
.replace(/enter/gi,"e")
.replace(/imes/gi,"i")
.replace(/ober/gi,"o")
.replace(/ufat/gi,"u")
campoResultado.style.display ="flex";
outputtitulo.style.display ="none";
outputp.style.display ="none";
carinha.style.display ="none";
botaoCopiar.style.display ="flex";
campoResultado.innerHTML = resultado;
}
function encriptar(){
let texto = pegarValor("entrada");
let letras = texto.split("");
let textoEncriptado = "";
textoEncriptado += letras.map(letra=>{
switch(letra){
case "a":
return "ai";
case "e":
return "enter";
case "i":
return "imes";
case "o":
return "ober";
case "u":
return "ufat";
default:
return letra;
}
}).join("");
campoResultado.style.display ="flex";
outputtitulo.style.display ="none";
outputp.style.display ="none";
carinha.style.display ="none";
botaoCopiar.style.display ="flex";
campoResultado.innerHTML = textoEncriptado;
}
function copiar(){
navigator.clipboard.writeText(campoResultado.value);
}
botaoCopiar.onclick = copiar
let botaoDecriptar = document.getElementById("decriptar");
botaoDecriptar.onclick = decriptar
let botaoEncriptar = document.getElementById("encriptar");
botaoEncriptar.onclick = encriptar