-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
69 lines (58 loc) · 2.56 KB
/
Copy pathscript.js
File metadata and controls
69 lines (58 loc) · 2.56 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
// Función para encriptar el texto
function encriptar() {
let texto = document.getElementById("input-text").value;
if (validarTexto(texto)) {
let textoCifrado = texto
.replace(/e/g, "enter")
.replace(/i/g, "imes")
.replace(/a/g, "ai")
.replace(/o/g, "ober")
.replace(/u/g, "ufat");
// Ocultar la imagen y el texto inicial
document.querySelector(".right-panel img").style.display = "none";
document.querySelector(".right-panel .message-title").style.display = "none";
document.querySelector(".right-panel .message-subtitle").style.display = "none";
// Mostrar el texto encriptado y el botón de copiar
let outputArea = document.querySelector(".right-panel .output-text");
outputArea.style.display = "block";
outputArea.textContent = textoCifrado;
document.querySelector(".right-panel .copy-btn").style.display = "inline-block";
} else {
alert("El texto solo debe contener letras minúsculas y sin acentos.");
}
}
// Función para desencriptar el texto
function desencriptar() {
let texto = document.getElementById("input-text").value;
if (validarTexto(texto)) {
let textoDescifrado = texto
.replace(/enter/g, "e")
.replace(/imes/g, "i")
.replace(/ai/g, "a")
.replace(/ober/g, "o")
.replace(/ufat/g, "u");
// Ocultar la imagen y el texto inicial
document.querySelector(".right-panel img").style.display = "none";
document.querySelector(".right-panel .message-title").style.display = "none";
document.querySelector(".right-panel .message-subtitle").style.display = "none";
// Mostrar el texto desencriptado y el botón de copiar
let outputArea = document.querySelector(".right-panel .output-text");
outputArea.style.display = "block";
outputArea.textContent = textoDescifrado;
document.querySelector(".right-panel .copy-btn").style.display = "inline-block";
} else {
alert("El texto solo debe contener letras minúsculas y sin acentos.");
}
}
// Función para copiar el texto al portapapeles
function copiarTexto() {
let texto = document.querySelector(".right-panel .output-text").textContent;
navigator.clipboard.writeText(texto).then(() => {
alert("Texto copiado al portapapeles.");
});
}
// Función para validar el texto (solo minúsculas y sin caracteres especiales)
function validarTexto(texto) {
let regex = /^[a-z\s]*$/;
return regex.test(texto);
}