-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
111 lines (99 loc) · 3.41 KB
/
script.js
File metadata and controls
111 lines (99 loc) · 3.41 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
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
const soloLetras ='^[a-z !ñ]+$';
function ocultar(id,visibilidad) {
var img = document.getElementById(id);
img.style.visibility = (visibilidad ? 'visible' : 'hidden');
}
function Encriptar(){
var res = "";
texto = document.getElementById('txt').value;
tutu = Comprobar(texto);
texto = tutu;
if(texto.match(soloLetras)!=null){
ocultar('img-area', false);
for(var i=0; i<texto.length; i++){
if(texto[i] != "a" && texto[i] != "e" &&
texto[i] != "i" && texto[i] != "o" &&
texto[i] != "u"){
res += texto[i];
}
if(texto[i] == "a"){
res += "ai";
}
if(texto[i] == "e"){
res += "enter";
}
if(texto[i] == "i"){
res += "imes";
}
if(texto[i] == "o"){
res += "ober";
}
if(texto[i] == "u"){
res += "ufat";
}
}
document.getElementById('txt').value = null;
document.getElementById("area").value = res;
}else{
alert("Ingrese palabras sin acentos ni carácteres especiales");
}
}
function Desencriptar(){
var res = "";
texto = document.getElementById('txt').value;
tutu = Comprobar(texto);
texto = tutu;
if(texto.match(soloLetras)!=null){
ocultar('img-area', false);
res = texto
.replaceAll("enter","e")
.replaceAll("ai","a")
.replaceAll("imes","i")
.replaceAll("ober","o")
.replaceAll("ufat","u");
document.getElementById('txt').value = "";
document.getElementById("area").value = res;
}else{
alert("Ingrese palabras sin acentos ni carácteres especiales");
}
}
function Copiar(){
var msg= "";
msg = document.getElementById("area").value;
document.getElementById('area').value ="";
navigator.clipboard.writeText(msg);
var img = document.getElementById('img-area');
img.style.visibility = "visible";
//Colocartexto(msg);
}
function esMayuscula(letra){
return letra === letra.toUpperCase();
}
function esMinuscula(letra){
return letra === letra.toLowerCase();
}
function PasarAMinuscula(texto){
texto = texto.toLowerCase();
return texto;
}
function Comprobar(texto){
var txt = "";
for(var i = 0; i < texto.length; i++){
var letraActual = texto.charAt(i);
if(esMinuscula(letraActual) == true){
txt = txt + texto.charAt(i) ;
}
if(esMayuscula(letraActual) == true){
txt = txt + PasarAMinuscula(letraActual);
}
}
return txt;
}
function Colocartexto(texto){
document.getElementById("txt").value = texto;
}
function Especiales(texto){
var caracter = "";
for(var i in texto){
}
}