-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (40 loc) · 1.2 KB
/
Copy pathscript.js
File metadata and controls
40 lines (40 loc) · 1.2 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
var vocalesEncriptar = {
"a":"ai", "e":"enter", "i":"imes", "o":"ober", "u":"ufat"
};
var vocalesDesencriptar = {
"ai":"a", "enter":"e", "imes":"i", "ober":"o", "ufat":"u"
};
function Encriptar(){
let texto = document.getElementById("texto").value;
var nuevotexto = texto.replace(/[aeiou]/g, function(match){
return vocalesEncriptar[match]
});
document.getElementById("copy").value = nuevotexto;
}
function Desencriptar(){
let texto = document.getElementById("texto").value;
var nuevotexto = texto.replace(/ai|enter|imes|ober|ufat/g, function(match){
return vocalesDesencriptar[match];
})
document.getElementById("copy").value = nuevotexto;
}
function ValidarTexto(){
var verificador = false;
let texto = document.getElementById("texto").value;
acentos = /[áéíóúÁÉÍÓÚ]/;
mayus = /[A-Z]/;
if(acentos.test(texto) || mayus.test(texto)){
verificador = true;
}
if(verificador == false){
Encriptar();
}
else{
alert("Evite usar acentos o mayúsculas en el texto");
}
}
function CopiarTexto(){
var oTextarea = document.getElementById("copy");
oTextarea.select();
document.execCommand("copy");
}