-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
72 lines (60 loc) · 2.36 KB
/
javascript.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
function encriptar(txtEncriptar){
txtEncriptar= textAencriptar.value.toLowerCase();
txtcifrado = txtEncriptar.replace(/e/igm,"enter");
txtcifrado = txtcifrado.replace(/o/igm,"ober");
txtcifrado = txtcifrado.replace(/i/igm,"imes");
txtcifrado = txtcifrado.replace(/a/igm,"ai");
txtcifrado = txtcifrado.replace(/u/igm,"ufat");
return txtcifrado;
}
function desEncriptar(){
txtDescripto= textAencriptar.value.toLowerCase();
txtCifrado=txtDescripto.replace(/ufat/igm,"u");
txtCifrado=txtCifrado.replace(/ai/igm,"a");
txtCifrado=txtCifrado.replace(/imes/igm,"i");
txtCifrado=txtCifrado.replace(/ober/igm,"o");
txtCifrado=txtCifrado.replace(/enter/igm,"e");
return txtCifrado;
}
const textAencriptar = document.querySelector(".textoEncriptar");
const textSalida = document.querySelector(".textoDesencriptar");
const anuncioSalida = document.querySelector(".mensaje");
const bnEncriptar = document.querySelector(".bnEncriptar");
const bnDescriptar = document.querySelector(".buttonDscriptar");
const bnCopiar = document.querySelector(".bnCopiar");
const bnClear = document.querySelector(".clear");
bnEncriptar.addEventListener("click",(e) => {
if(textAencriptar.value==""){
alert("NO ESCRIBISTE NINGUN TEXTO");
}else{
let txtFinal = encriptar(textAencriptar.value);
alert("Texto Encriptado")
textAencriptar.value= "";
anuncioSalida.value = "← TEXTO ENCRIPTADO";
textSalida.value= txtFinal;
}
});
bnDescriptar.addEventListener("click",(e) => {
if(textAencriptar.value==""){
alert("NO ESCRIBISTE NINGUN TEXTO");
}else{
desEncriptar();
alert("Texto DesEncriptado")
textSalida.value=txtCifrado;
textAencriptar.value= "";
anuncioSalida.value = "← TEXTO DesENCRIPTADO";
}
});
bnCopiar.addEventListener("click",(e) => {
if(textSalida.value==""){
anuncioSalida.value = "← CAJA VACIA";
}else{
textSalida.select();
navigator.clipboard.writeText(textSalida.value)
anuncioSalida.value = "← TEXTO COPIADO";
}
});
bnClear.addEventListener("click",(e) =>{
textSalida.value="";
anuncioSalida.value="";
})