-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
81 lines (51 loc) · 1.98 KB
/
index.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
77
78
79
80
81
window.addEventListener("load", function () {
let textoEntrada = document.querySelector(".textoEntrada");
let textoSalida = document.querySelector(".textoSalida");
let btnEncriptar = document.querySelector("#encriptar");
let btnDesencriptar = document.querySelector("#desencriptar");
let btnCopiar = document.querySelector("#copiar");
let desactivar = document.querySelector(".sinTexto");
let activar = document.querySelector(".conTexto");
btnEncriptar.addEventListener("click", function () {
desactivar.style.display = "none";
activar.style.display = "flex";
let texto = encriptarTexto();
textoSalida.value = texto;
});
btnDesencriptar.addEventListener("click",function (){
let texto = desencriptarTexto();
textoSalida.value = texto;
})
btnCopiar.addEventListener("click", copiarClipBoard);
// funcion para encrptar texto
function encriptarTexto() {
let textoEncriptar = limpiarTexto(textoEntrada.value);
let textoEncriptado = textoEncriptar.replaceAll("e", "enter")
.replaceAll("i", "imes")
.replaceAll("a","ai")
.replaceAll("o","ober")
.replaceAll("u","ufat")
;
return textoEncriptado;
}
// funcion para desencriptar texto
function desencriptarTexto(){
let textoDesencriptar = textoEntrada.value;
let textoDesencriptado = textoDesencriptar.replaceAll("enter", "e")
.replaceAll("imes", "i")
.replaceAll("ai","a")
.replaceAll("ober","o")
.replaceAll("ufat","u")
;
return textoDesencriptado;
}
// funcion para copiar en el clipBoard
function copiarClipBoard(){
textoSalida.select();
document.execCommand("copy");
textoEntrada.value = textoSalida.value;
}
function limpiarTexto(texto){
return texto.normalize('NFD').replace(/[\u0300-\u036f]/g,"").toLowerCase();
}
});