-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (55 loc) · 2.07 KB
/
app.js
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
function getTextAndShow() {
//Obtener texto
var inputText = document.getElementById('Input').value;
console.log(inputText);
//encriptar texto
let encryptedText = encryptText(inputText);
console.log(encryptedText);
//ocultar imagen
document.getElementById("Imagen").style.display = "none";
document.getElementById("textoEncriptado").style.display = "flex";
//mostrar texto
document.getElementById("texto-encriptado").innerHTML = encryptedText;
}
function encryptText(text) {
var encryptedText = text
.replace(/e/g, "enter")
.replace(/i/g, "imes")
.replace(/a/g, "ai")
.replace(/o/g, "ober")
.replace(/u/g, "ufat");
return encryptedText;
}
function decryptText(text) {
var decryptedText = text
.replace(/enter/g, "e")
.replace(/imes/g, "i")
.replace(/ai/g, "a")
.replace(/ober/g, "o")
.replace(/ufat/g, "u");
return decryptedText;
}
function getTextAndDecrypt(){
var inputText = document.getElementById('Input').value;
console.log(inputText);
let decryptedText = decryptText(inputText);
document.getElementById("Imagen").style.display = "none";
document.getElementById("textoEncriptado").style.display = "flex";
//mostrar texto
document.getElementById("texto-encriptado").innerHTML = decryptedText;
}
function copyText() {
var inputText = document.getElementById('texto-encriptado').innerText;
var tempInput = document.createElement('textarea');
tempInput.value = inputText;
document.body.appendChild(tempInput);
// Selecciona el texto y lo copia al portapapeles
tempInput.select();
tempInput.setSelectionRange(0, 99999); // Para dispositivos móviles
document.execCommand('copy');
// Elimina el elemento temporal
document.body.removeChild(tempInput);
// Opcional: Muestra una alerta indicando que el texto se ha copiado
alert("Texto copiado al portapapeles");
}
document.getElementById("textoEncriptado").style.display = "none";