-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
62 lines (50 loc) · 1.85 KB
/
Copy pathscript.js
File metadata and controls
62 lines (50 loc) · 1.85 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
const textArea = document.querySelector(".text-area");
const mensaje = document.querySelector(".mensaje");
const informacionMensaje = document.querySelector('.informacion-mensaje');
const btnCopiar = document.querySelector('.btn-copiar');
function copiar(){
let mensaje = document.querySelector(".mensaje");
mensaje.select();
document.execCommand('copy');
mensaje.setSelectionRange(0, 0);
btnCopiar.style.display = "none";
mensaje.value = "";
mensaje.style.backgroundImage = "";
informacionMensaje.style.display = "block";
textArea.focus();
}
function btnEncriptar(){
const textoEncriptado = encriptar(textArea.value);
mensaje.value = textoEncriptado;
textArea.value = "";
mensaje.style.backgroundImage = "none";
informacionMensaje.style.display = "none";
btnCopiar.style.display = "block";
}
function btnDesencriptar(){
const textoDesencriptado = desencriptar(textArea.value);
mensaje.value = textoDesencriptado;
textArea.value = "";
mensaje.style.backgroundImage = "none";
informacionMensaje.style.display = "none";
btnCopiar.style.display = "block";
}
function encriptar(texto){
let matrizcodigo = [["e","enter"], ["i","imes"], ["a","ai"], ["o","ober"], ["u","ufat"]]
texto =texto.toLowerCase();
for(let i=0;i<matrizcodigo.length;i++){
if(texto.includes(matrizcodigo[i][0]))
texto = texto.replaceAll(matrizcodigo[i][0],matrizcodigo[i][1]);
}
return texto;
}
function desencriptar(texto){
let matrizcodigo = [["e","enter"], ["i","imes"], ["a","ai"], ["o","ober"], ["u","ufat"]]
texto =texto.toLowerCase();
for(let i=0;i<matrizcodigo.length;i++){
if(texto.includes(matrizcodigo[i][1]))
texto = texto.replaceAll(matrizcodigo[i][1],matrizcodigo[i][0]);
}
return texto;
}
//console.log(matrizCodigo);