-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
104 lines (89 loc) · 3.21 KB
/
script.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
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
101
102
103
104
/*La letra "e" es convertida para "enter"
La letra "i" es convertida para "imes"
La letra "a" es convertida para "ai"
La letra "o" es convertida para "ober"
La letra "u" es convertida para "ufat"*/
function encripta() {
dato = document.getElementById("valor-init");
texto = dato.value;
arr = Array.from(texto)
if (arr.length >= 1) {
i = 0
while (i <= arr.length) {
if (arr[i] == "a") {
arr[i] = "ai";
}
if (arr[i] == "e") {
arr[i] = "enter";
}
if (arr[i] == "i") {
arr[i] = "imes";
}
if (arr[i] == "o") {
arr[i] = "ober";
}
if (arr[i] == "u") {
arr[i] = "ufat";
}
else {
i++;
}
}
text = arr.join("");
newDiv = document.createElement("div");
newDiv.classList.add("resulta-fin");
newDiv.setAttribute("id", "final")
newElement = document.createElement("textarea");
newElement.setAttribute("readonly","readonly");
newElement.setAttribute("id", "text-copy")
newElement.classList.add("text-sale");
newElement.textContent = text;
newButton = document.createElement("input");
newButton.setAttribute("type", "button");
newButton.setAttribute("value", "Copiar");
newButton.setAttribute("onclick", "copy()")
newButton.classList.add("boton");
document.getElementById("presentacion").style.display = "none";
portada = document.getElementById("valor-sale").appendChild(newDiv);
portada.appendChild(newElement);
portada.appendChild(newButton);
document.getElementById("valor-init").value = "";
}
else {
document.getElementById("final").style.display = "none";
document.getElementById("presentacion").style.display = "initial";
}
}
function desencripta() {
dato = document.getElementById("valor-init");
texto = dato.value;
var textf = texto.replace(/ai/igm, "a")
var textf = textf.replace(/enter/igm, "e")
var textf = textf.replace(/imes/igm, "i")
var textf = textf.replace(/ober/igm, "o")
var textf = textf.replace(/ufat/igm, "u")
text = textf;
newDiv = document.createElement("div");
newDiv.classList.add("resulta-fin");
newDiv.setAttribute("id", "final")
newElement = document.createElement("textarea");
newElement.setAttribute("id", "text-copy")
newElement.setAttribute("readonly","readonly");
newElement.classList.add("text-sale");
newElement.textContent = text;
newButton = document.createElement("input");
newButton.setAttribute("type", "button");
newButton.setAttribute("value", "Copiar");
newButton.setAttribute("onclick", "copy()")
newButton.classList.add("boton");
document.getElementById("presentacion").style.display = "none";
portada = document.getElementById("valor-sale").appendChild(newDiv);
portada.appendChild(newElement);
portada.appendChild(newButton);
}
function copy() {
let copia = document.getElementById("text-copy");
copia.select();
document.execCommand("copy");
location.reload();
}