-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
77 lines (63 loc) · 3.18 KB
/
Copy pathscript.js
File metadata and controls
77 lines (63 loc) · 3.18 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
function limpiarInput(){
document.getElementById("input-encriptador").value = "";
}
function ocultar(){
document.getElementById("textoencrip").style.display = "none";
document.getElementById("boton-copiar").style.display = "none";
}
document.querySelector("#input-encriptador");
var inputEncriptar = document.querySelector("#input-encriptador");
var textoEncriptado = document.querySelector("#textoencrip");
var botonEncriptar = document.querySelector("#boton-encrip");
var botonDesencriptar = document.querySelector("#boton-desencriptar");
var botonCopiar = document.querySelector("#boton-copiar");
function encriptar(){
var minisculas = /^[a-zñ\s]+$/g;
var mensaje = inputEncriptar.value;
if(mensaje == ""){
alert("Ingresa el mensaje a encriptar");
}
else if(mensaje.match(minisculas) == null){
alert("Solo se admiten caracteres en miniscula y sin acentos");
limpiarInput();
inputEncriptar.focus();
}
else{
var mensaje = inputEncriptar.value;
var mensajeEncriptado = mensaje
.replaceAll("e","enter")
.replaceAll("i","imes")
.replaceAll("o","ober")
.replaceAll("a","ai")
.replaceAll("u","ufat");
textoEncriptado.value = mensajeEncriptado;
document.getElementById("imagen-muneco").style.display = "none";
document.getElementById("aviso2").style.display = "none";
document.getElementById("aviso3").style.display = "none";
document.getElementById("textoencrip").style.display = "show";
document.getElementById("textoencrip").style.display = "inherit";
document.getElementById("boton-copiar").style.display = "show";
document.getElementById("boton-copiar").style.display = "inherit";
document.getElementById("textoencrip").innerHTML = encriptarTexto;
}
}
function desencriptar(){
var mensaje = inputEncriptar.value;
var mensajeEncriptado = mensaje
.replaceAll("enter","e")
.replaceAll("imes","i")
.replaceAll("ober","o")
.replaceAll("ai","a")
.replaceAll("ufat","u");
textoEncriptado.value = mensajeEncriptado;
}
botonEncriptar.onclick = encriptar;
botonDesencriptar.onclick = desencriptar;
botonCopiar.onclick = copiar;
ocultar();
function copiar(){
var content = document.getElementById('textoencrip');
content.select();
var successful = document.execCommand('copy');
alert("Mensaje encriptado copiado");
}