-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcripto.js
More file actions
35 lines (29 loc) · 1.46 KB
/
Copy pathcripto.js
File metadata and controls
35 lines (29 loc) · 1.46 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
var textoInicial = document.querySelector(".textarea1");
var botoncriptografar = document.querySelector("#cifrar");
var botonDescripto = document.querySelector("#decifrar");
var resultadoFinal = document.querySelector(".textarea2");
var copiar = document.querySelector("#boton-copy");
var copiado = document.querySelector("#senhal")
//FUNCION ENCRIPTAR
botoncriptografar.addEventListener("click",function(){
const frase = textoInicial.value.toLowerCase().replace(/[,.;:?!@#$%¨&*-=_"'()<>`~{}!!!!!]/gi,"");
const nuevoTexto = frase.replace(/e/g, "enter").replace(/i/g, "imes").replace(/a/g, "ai").replace(/o/g, "ober").replace(/u/g, "ufat")//no colocar ";"
resultadoFinal.textContent = nuevoTexto;
console.log("encriptar")
})
//FUNCION DESENCRIPTAR
botonDescripto.addEventListener("click",function(){
const frase = textoInicial.value;
const nuevoTexto = frase.replace(/enter/g, "e").replace(/imes/g, "i").replace(/ai/g, "a").replace(/ober/g, "o").replace(/ufat/g, "u")//no colocar ";"
resultadoFinal.textContent = nuevoTexto;
console.log("dessencriptar")
})
//COPIANDO AL PORTA PAPELES
copiar.addEventListener("click", e =>{
resultadoFinal.select();//selecionando el texarea
document.execCommand("copy"); //copiando el texto
//copiado.innerHTML="COPIADO"; //cambiando de palabra a copiado
//setTimeout(()=>copiado.innerHTML="Resultado:", 300);//comando para resetear
console.log("copiado")
})
//onclick="location.href = location.href"