-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunciones.js
134 lines (107 loc) · 3.07 KB
/
funciones.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var textoEncriptado = ""
var tituloAside = document.getElementById("tituloAsideAtras");
function encriptarTexto(){
var textArea = document.getElementById("area").value;
if(textoEncriptado != textArea || textoEncriptado == ""){
if(textArea.trim() != ""){
rotarAside();
traspasarTexto(agregarEncriptado(textArea));
textoEncriptado = agregarEncriptado(textArea)
tituloAside.innerHTML = "Mensaje Encriptado:"
}else{
swal("Un momento!","Debes ingresar el mensaje a encriptar.","error");
area.focus()
}
}else{
swal("Un momento!","Este mensaje ya fue encriptado", "warning");
}
}
function desencriptarTexto(){
var textArea = document.getElementById("area").value;
if(textArea.trim() != ""){
rotarAside();
traspasarTexto(quitarEncriptado(textArea));
tituloAside.innerHTML = "Mensaje Desencriptado:"
}else{
swal("Un momento!", "debes ingresar el mensaje a desencriptar.", "warning");
area.focus()
}
}
function agregarEncriptado(texto){
var textos = "";
for(var i = 0; i < texto.length; i++){
if(texto[i] == "a"){
textos += "ai";
}
else if(texto[i] == "e"){
textos += "enter";
}
else if(texto[i] == "i"){
textos += "imes";
}
else if(texto[i] == "o"){
textos += "ober";
}
else if(texto[i] == "u"){
textos += "ufat";
}
else{
textos += texto[i];
}
}
return textos.toLowerCase();
}
function quitarEncriptado(texto){
var textos = "";
for(var i = 0; i < texto.length; i++){
if(texto[i] == "a"){
textos += "a";
i = i+1;
}
else if(texto[i] == "e"){
textos += "e";
i += 4;
}
else if(texto[i] == "i"){
textos += "i";
i+= 3;
}
else if(texto[i] == "o"){
textos += "o";
i+=3;
}
else if(texto[i] == "u"){
textos += "u";
i+=3;
}
else{
textos += texto[i];
}
}
return textos.toLowerCase();
}
function rotarAside(){
var contenedor = document.querySelector(".munieco-contenedor");
contenedor.style.transform="rotateY(180deg)"
}
function volverAside(){
var contenedor = document.querySelector(".munieco-contenedor");
contenedor.style.transform="rotateY(0deg)"
copiar.value = "Copiar";
}
function traspasarTexto(texto){
var textoAsideAtras = document.querySelector(".p-atras")
textoAsideAtras.innerHTML = texto;
}
function copiarTexto(){
var textoAsideAtras = document.querySelector(".p-atras");
var textArea = document.getElementById("area");
textArea.value = textoAsideAtras.innerHTML;
navigator.clipboard.writeText(textoAsideAtras.innerHTML);
copiar.value = "Copiado!";
copiar.style.color="darkturquoise";
swal("Mensaje copiado!", "El mensaje fue copiado y está listo para desencriptar.", "success");
}
function limpiarArea(){
document.getElementById("area").value = "";
}