-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
51 lines (42 loc) · 1.73 KB
/
Copy pathscripts.js
File metadata and controls
51 lines (42 loc) · 1.73 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
const textoEntrada = document.querySelector(".texto-entrada");
const textoSalida = document.querySelector(".texto-salida");
const image = document.querySelector(".imagen-salida");
const infoSalida = document.querySelector(".ingresar-texto");
function botonEncriptar(){
const textoEncriptado = encriptar(textoEntrada.value);
textoSalida.value = textoEncriptado.replace(/[^a-zA-Z ]/g, '');
image.style.display = "none";
infoSalida.style.display = "none";
textoEntrada.value = "";
}
function encriptar(stringEncriptada){
let matrizCodigo = [["e", "enter"], ["i", "imes"], ["a", "ai"], ["o", "ober"], ["u", "ufat"]];
stringEncriptada = stringEncriptada.toLowerCase();
for(let i = 0; i < matrizCodigo.length; i++){
if(stringEncriptada.includes(matrizCodigo[i][0])){
stringEncriptada = stringEncriptada.replaceAll(matrizCodigo[i][0], matrizCodigo[i][1]);
}
}
return stringEncriptada;
}
function botonDesencriptar(){
const textoEncriptado = desencriptar(textoEntrada.value);
textoSalida.value = textoEncriptado.replace(/[^a-zA-Z ]/g, '');
image.style.display = "none";
infoSalida.style.display = "none";
textoEntrada.value = "";
}
function desencriptar(stringDesencriptada){
let matrizCodigo = [["e", "enter"], ["i", "imes"], ["a", "ai"], ["o", "ober"], ["u", "ufat"]];
stringDesencriptada = stringDesencriptada.toLowerCase();
for(let i = 0; i < matrizCodigo.length; i++){
if(stringDesencriptada.includes(matrizCodigo[i][1])){
stringDesencriptada = stringDesencriptada.replaceAll(matrizCodigo[i][1], matrizCodigo[i][0]);
}
}
return stringDesencriptada;
}
function copiar(){
textoSalida.select();
document.execCommand('copy');
}