-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript3.js
76 lines (68 loc) · 2.22 KB
/
script3.js
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
72
73
74
75
76
var btnEncriptar = document.querySelector(".btnEncriptar");
var btnDesencriptar = document.querySelector(".btnDesencriptar");
var btnCopiar = document.querySelector(".btnCopiar");
var munheco = document.querySelector(".contenedor-munheco");
var textoMunheco = document.querySelector(".contenedor-textos");
var cajaRecuperado = document.querySelector(".contenedor-resultado");
var resultado = document.querySelector(".texto-resultado");
var btnCopiar = document.querySelector(".btnCopiar");
var textoInput = document.querySelector(".texto-1");
var btnBorrar = document.querySelector(".btnBorrar");
var minusculas = ("abcdefghijklmnopqrstuvwxyz");
var mayusculas = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
btnEncriptar.onclick = encriptar;
btnDesencriptar.onclick =desencriptarTexto;
btnCopiar.onclick = copiar;
btnBorrar.onclick = borrar;
textoInput.focus();
function encriptar(){
ocultarMunheco();
resultado.textContent = encriptarTexto();
}
function recuperarTexto(){
var area = document.querySelector(".texto-1");
return area.value;
}
function ocultarMunheco(){
munheco.classList.add("ocultar");
textoMunheco.classList.add("ocultar");
}
function encriptarTexto(){
var mensaje = recuperarTexto();
var mensajeEncriptado = mensaje
.replaceAll("e","enter")
.replaceAll("i","imes")
.replaceAll("o","ober")
.replaceAll("a","ai")
.replaceAll("u","ufat");
resultado.value = mensajeEncriptado;
}
function desencriptarTexto(){
ocultarMunheco();
var mensajeEncriptado = recuperarTexto();
var mensaje = mensajeEncriptado
.replaceAll("enter","e")
.replaceAll("imes","i")
.replaceAll("ober","o")
.replaceAll("ai","a")
.replaceAll("ufat","u");
resultado.value = mensaje;
}
function copiar(){
var textoResultado = resultado.value;
navigator.clipboard.writeText(textoResultado);
Swal.fire({
position: 'top-center',
icon: 'success',
title: 'YEEY! Mensaje Copiado!',
showConfirmButton: false,
timer: 1500
})
}
function borrar(){
textoInput.value="";
resultado.value="";
munheco.classList.remove("ocultar")
textoMunheco.classList.remove("ocultar");
textoInput.focus();
}