-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
100 lines (89 loc) · 3.09 KB
/
Copy pathscript.js
File metadata and controls
100 lines (89 loc) · 3.09 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
/* ===== Loader =====*/
window.addEventListener('load', () => {
const contenedorLoader = document.querySelector('.container--loader');
contenedorLoader.style.opacity = 0;
contenedorLoader.style.visibility = 'hidden';
})
function focus() {
let input = document.getElementById("input-texto");
input.focus();
}
function value() {
let input = document.getElementById("input-texto");
input.value = "";
}
function encriptar() {
let texto = document.getElementById("input-texto").value;
let txt_cifrado = texto.replace(/e/gm, "enter");
txt_cifrado = txt_cifrado.replace(/o/gm, "ober");
txt_cifrado = txt_cifrado.replace(/i/gm, "imes");
txt_cifrado = txt_cifrado.replace(/a/gm, "ai");
txt_cifrado = txt_cifrado.replace(/u/gm, "ufat");
if (/[^a-zñ ]/.test(texto)) {
Swal.fire({
icon: 'error',
iconColor: '#b9ab9c',
background: '#E3E0DE',
title: 'Oops...',
confirmButtonColor: '#b9ab9c',
text: 'Solo se permiten letras minusculas y sin acento',
});
}
else if (texto.length === 0) {
Swal.fire({
icon: 'error',
iconColor: '#b9ab9c',
background: '#E3E0DE',
title: 'Oops...',
confirmButtonColor: '#b9ab9c',
text: 'El campo de texto está vacio, escriba el texto que desea encriptar',
});
}
else {
document.getElementById("texto1-contder").style.display = "none";
document.getElementById("texto2-contder").style.display = "none";
document.getElementById("output-texto").style.display = "inline-block";
document.getElementById("output-texto").innerHTML = txt_cifrado;
value();
}
}
function desencriptar() {
let texto = document.getElementById("input-texto").value;
let txt_cifrado = texto.replace(/enter/gm, "e");
txt_cifrado = txt_cifrado.replace(/ober/gm, "o");
txt_cifrado = txt_cifrado.replace(/imes/gm, "i");
txt_cifrado = txt_cifrado.replace(/ai/gm, "a");
txt_cifrado = txt_cifrado.replace(/ufat/gm, "u");
if (texto.length === 0) {
Swal.fire({
icon: 'error',
iconColor: '#b9ab9c',
background: '#E3E0DE',
title: 'Oops...',
confirmButtonColor: '#b9ab9c',
text: 'El campo de texto está vacio, escriba el texto que desea desencriptar',
});
}
else {
document.getElementById("texto1-contder").style.display = "none";
document.getElementById("texto2-contder").style.display = "none";
document.getElementById("output-texto").style.display = "inline-block";
document.getElementById("output-texto").innerHTML = txt_cifrado;
value();
}
}
function copiar() {
let contenido = document.querySelector("#output-texto");
contenido.select();
document.execCommand("copy");
Swal.fire({
icon: 'success',
iconColor: '#b9ab9c',
background: '#E3E0DE',
title: '¡Bien!',
confirmButtonColor: '#b9ab9c',
text: 'Texto copiado correctamente',
});
}
focus();
value();