-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
53 lines (53 loc) · 2.26 KB
/
main.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
const encryptfn = () => {
var msg = document.getElementById("text-area-input").value.toLowerCase();
if (msg !== "") {
msgFilter = msg.replace(/[^a-zA-Z 0-9.]+/g, " ");
var textEncrypt = msgFilter
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.replaceAll("e", "enter")
.replaceAll("i", "imes")
.replaceAll("o", "ober")
.replaceAll("a", "ai")
.replaceAll("u", "ufat");
document.getElementById("text-area-output").innerHTML = textEncrypt;
document.getElementById("no-message").style = "display:none";
document.getElementById("enter-message").style = "display:none";
document.getElementById("copy").style = "display:inline";
document.getElementById("text-area-input").value = "";
} else {
alert("Ingresa texto para continuar");
document.getElementById("text-area-input").focus();
document.getElementById("copy").style = "display:none";
document.getElementById("no-message").style = "display:inline-block";
document.getElementById("enter-message").style = "display:inline-block";
}
};
const decryptfn = () => {
var msg = document.getElementById("text-area-input").value.toLowerCase();
if (msg !== "") {
msgFilter = msg.replace(/[^a-zA-Z 0-9.]+/g, " ");
var textDecrypt = msgFilter
.toLowerCase()
.replaceAll("enter", "e")
.replaceAll("imes", "i")
.replaceAll("ober", "o")
.replaceAll("ai", "a")
.replaceAll("ufat", "u");
document.getElementById("text-area-output").innerHTML = textDecrypt;
document.getElementById("no-message").style = "display:none";
document.getElementById("enter-message").style = "display:none";
document.getElementById("copy").style = "display:inline";
document.getElementById("text-area-input").value = "";
} else {
alert("Ingresa texto para continuar");
document.getElementById("text-area-input").focus();
document.getElementById("copy").style = "display:none";
document.getElementById("no-message").style = "display:inline-block";
document.getElementById("enter-message").style = "display:inline-block";
}
};
const copytext = () => {
var copy = document.getElementById("text-area-output");
navigator.clipboard.writeText(copy.innerHTML);
};