-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
92 lines (87 loc) · 3.46 KB
/
Copy pathjavascript.js
File metadata and controls
92 lines (87 loc) · 3.46 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
function encriptar(){
let inputIngresar = document.getElementById("inputIngresar").value;
let mensaje = document.getElementById("parrafoMensaje");
let imgBusqueda = document.getElementById("imgBusqueda");
let textoCifrado = inputIngresar
.replace(/e/gi, "enter")
.replace(/i/gi, "imes")
.replace(/a/gi, "ai")
.replace(/o/gi, "ober")
.replace(/u/gi, "ufat");
if (document.getElementById("inputIngresar").value.length !=0){
document.getElementById("inputIngresar").value = textoCifrado;
mensaje.textContent = "Listo! texto encriptado con exito!.";
imgBusqueda.src = "./imagenes/encriptado.jpg";
}else {
imgBusqueda.src = "./imagenes/busqueda.png";
mensaje.textContent = "Ingresa tu texto y oprime el boton de encriptar o desencriptar.";
document.getElementById("ocultar").style.display = "block";
Swal.fire({
title: 'Ingresa por lo menos una letra',
html: 'Autocierre <b></b> milliseconds.',
timer: 2000,
timerProgressBar: true,
didOpen: () => {
Swal.showLoading()
const b = Swal.getHtmlContainer().querySelector('b')
timerInterval = setInterval(() => {
b.textContent = Swal.getTimerLeft()
}, 100)
},
willClose: () => {
clearInterval(timerInterval)
}
}).then((result) => {
/* Read more about handling dismissals below */
if (result.dismiss === Swal.DismissReason.timer) {
console.log('I was closed by the timer')
}
})
}
}
function desencriptar(){
let mensaje = document.getElementById("parrafoMensaje");
let inputIngresar = document.getElementById("inputIngresar").value;
let imgBusqueda = document.getElementById("imgBusqueda");
let textoCifrado = inputIngresar
.replace(/enter/gi, "e")
.replace(/imes/gi, "i")
.replace(/ai/gi, "a")
.replace(/ober/gi, "o")
.replace(/ufat/gi, "u");
if(document.getElementById("inputIngresar").value.length != 0){
document.getElementById("inputIngresar").value = textoCifrado;
mensaje.textContent = "Ahora tienes el texto desencriptado.";
imgBusqueda.src = "./imagenes/desencriptado.png";
} else{
imgBusqueda.src = "./imagenes/busqueda.png";
mensaje.textContent = "Ingresa tu texto y oprime el boton de encriptar o desencriptar.";
document.getElementById("ocultar").style.display = "block";
Swal.fire({
title: 'Ingresa por lo menos una letra',
html: 'Autocierre <b></b> milliseconds.',
timer: 2000,
timerProgressBar: true,
didOpen: () => {
Swal.showLoading()
const b = Swal.getHtmlContainer().querySelector('b')
timerInterval = setInterval(() => {
b.textContent = Swal.getTimerLeft()
}, 100)
},
willClose: () => {
clearInterval(timerInterval)
}
}).then((result) => {
/* Read more about handling dismissals below */
if (result.dismiss === Swal.DismissReason.timer) {
console.log('I was closed by the timer')
}
})
}
}
function copiarTexto(){
let inputIngresar = document.getElementById("inputIngresar");
inputIngresar.select();
document.execCommand('copy');
}