-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrip.js
72 lines (64 loc) · 2.22 KB
/
scrip.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
//--Elementos a usar
const txtOriginal = document.querySelector('.texto_izquierda');
const mensajeFinal = document.querySelector('.texto_derecha');
const btnCopiarTxt = document.querySelector('.copiar_txt');
//--Encriptador
function botonEncriptar() {
const txtEncriptado = encriptar(txtOriginal.value);
mensajeFinal.value = txtEncriptado;
txtOriginal.value = '';
mensajeFinal.style.backgroundImage = 'none';
}
function encriptar(texto) {
texto = texto.toLowerCase();
let mensaje = "";
if (texto === "" ) {
mensaje = "Por favor escriba el texto que desea encriptar";
} else {
texto = texto
.replace(/e/g, "enter")
.replace(/i/g, "imes")
.replace(/a/g, "ai")
.replace(/o/g, "ober")
.replace(/u/g, "ufat");
mensaje = texto.normalize("NFD").replace(/[$\.¿\?~!\¡@#%^&*()_|}\{[\]>\<:"`;,\u0300-\u036f']/g, "");
}
return mensaje;
}
function botonDesencriptar (){
const txtDesencriptado = Desencriptar(txtOriginal.value);
mensajeFinal.value = txtDesencriptado;
txtOriginal.value = '';
mensajeFinal.style.backgroundImage = 'none';
}
function Desencriptar (texto){
texto = texto.toLowerCase();
let mensaje = "";
if (texto === '' ) {
mensaje = "Por favor escriba el texto que desea desencriptar";
} else {
texto = texto
.replace(/enter/g, "e")
.replace(/imes/g, "i")
.replace(/ai/g, "a")
.replace(/ober/g, "o")
.replace(/ufat/g, "u");
mensaje = texto.normalize("NFD").replace(/[$\.¿\?~!\¡@#%^&*()_|}\{[\]>\<:"`;,\u0300-\u036f']/g, "");
}
return mensaje; }
async function Copiartxt() {
const input = document.querySelector('.texto_derecha');
input.select();
document.execCommand('copy');
btnCopiarTxt.classList.add("active");
await new Promise(resolve => setTimeout(resolve, 250));
btnCopiarTxt.classList.remove('active');
alert("Texto Copiado");
}
function Limpiartxt() {
document.querySelector('.texto_derecha').value = "";
let elemento = document.querySelector('.texto_derecha');
elemento.style.backgroundImage = "url('lupa.gif')";
elemento.style.backgroundRepeat = "no-repeat";
elemento.style.backgroundSize = "40%";
}