-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
72 lines (55 loc) · 2.43 KB
/
script.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
const inputTexto = document.querySelector(".input-text");
const mensaje = document.querySelector(".input-text-area");
var img = document.querySelector(".Muneco");
var botonCopiar = document.querySelector(".BotonCopiar");
botonCopiar.style.visibility = "hidden";
var ningumMensajeEncontrado = document.querySelector(".NingunMensajeEncontrado");
ningumMensajeEncontrado.style.visibility = "visible";
var textoDeseaDesencriptar = document.querySelector(".TextoDeseaDesencriptar");
textoDeseaDesencriptar.style.visibility = "visible";
function btnencriptar(){
const textoEncriptado = encriptar(inputTexto.value);
mensaje.value = textoEncriptado;
img.style.visibility = "hidden";
ningumMensajeEncontrado.style.visibility = "hidden";
textoDeseaDesencriptar.style.visibility = "hidden";
botonCopiar.style.visibility = "visible";
}
function encriptar(stringParaEncriptar){
let matrizCodigo = [["e","enter"],["i","imes"],["a","ai"],["o","ober"],["u","ufat"]]
stringParaEncriptar = stringParaEncriptar.toLowerCase();
for(let i = 0; i< matrizCodigo.length; i++){
if(stringParaEncriptar.includes(matrizCodigo[i][0])){
stringParaEncriptar = stringParaEncriptar.replaceAll(matrizCodigo[i][0],
matrizCodigo[i][1]);
}
}
return stringParaEncriptar;
}
function btnDesencriptar(){
var textoDesencriptado = desencriptar(inputTexto.value)
mensaje.value = textoDesencriptado;
img.style.visibility = "hidden";
ningumMensajeEncontrado.style.visibility = "hidden";
textoDeseaDesencriptar.style.visibility = "hidden";
botonCopiar.style.visibility = "visible";
}
function desencriptar(stringParaDesencriptar){
let matrizCodigo = [["enter","e"],["imes","i"],["ai","a"],["ober","o"],["ufat","u"]]
for(let i = 0; i< matrizCodigo.length; i++){
if(stringParaDesencriptar.includes(matrizCodigo[i][0])){
stringParaDesencriptar = stringParaDesencriptar.replaceAll(matrizCodigo[i][0],
matrizCodigo[i][1]);
}
}
return stringParaDesencriptar;
}
function btnCopiar() {
var btnMensaje = document.getElementById("input-text-area").value;
document.getElementById("input-text").value = btnMensaje;
mensaje.value = "";
botonCopiar.style.visibility = "hidden";
img.style.visibility = "visible";
ningumMensajeEncontrado.style.visibility = "visible";
textoDeseaDesencriptar.style.visibility = "visible";
}