-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
102 lines (93 loc) · 2.88 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { cambiarTema } from "./tema.js";
var entrada = document.querySelector("#campo-entrada");
var encriptar = document.querySelector("#encriptar");
var desencriptar = document.querySelector("#desencriptar");
var encriptado = document.querySelector("#campo-encriptado");
var copiar = document.querySelector("#copiar");
var mensajene = document.querySelector(".mensaje-vacio");
var msgc = document.querySelector("#mensaje-copiado")
function mostrarTextoEncriptado(){
var strcampo = entrada.value;
var resultadoEnc = strcampo.toLowerCase().replace(/[aeiou]/gi, function(match) {
switch(match) {
case "a":
return "ai";
case "e":
return "enter";
case "i":
return "imes";
case "o":
return "ober";
case "u":
return "ufat";
}
}).toLowerCase().replace(/[áéíóú]/gi, function(match) {
switch(match) {
case "á":
return "ai";
case "é":
return "enter";
case "í":
return "imes";
case "ó":
return "ober";
case "ú":
return "ufat";
}
}).replace(/[^\w\s.,()¿?¡!]/g, "");
if(strcampo != ""){
encriptado.value = resultadoEnc;
entrada.value = "";
mensajene.style.display = "none";
copiar.style.display = "block";
}else{
encriptado.value = "";
mensajene.style.display = "flex";
copiar.style.display = "none";
}
}
function mostrartextoOriginal(){
var strcampoE = entrada.value;
var resultOrigin = strcampoE.replace(/ai|enter|imes|ober|ufat/gi, function(match){
switch(match) {
case "ai":
return "a";
case "enter":
return "e";
case "imes":
return "i";
case "ober":
return "o";
case "ufat":
return "u";
}
});
if(strcampoE != ""){
encriptado.value = resultOrigin;
entrada.value = "";
mensajene.style.display = "none";
copiar.style.display = "block";
}else{
encriptado.value = "";
mensajene.style.display = "flex";
copiar.style.display = "none";
}
}
function copiarTexto(){
var txta = document.createElement("input");
txta.setAttribute("value", encriptado.value);
document.body.appendChild(txta);
txta.select();
document.execCommand("copy");
document.body.removeChild(txta);
msgc.style.height = "32px";
msgc.style.visibility = "visible";
setTimeout(ocultarmsgc, 1000);
}
function ocultarmsgc(){
msgc.style.height = "0px";
msgc.style.visibility = "hidden";
}
encriptar.onclick = mostrarTextoEncriptado;
desencriptar.onclick = mostrartextoOriginal;
copiar.onclick = copiarTexto;