-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcriptografar.js
More file actions
60 lines (53 loc) · 1.44 KB
/
criptografar.js
File metadata and controls
60 lines (53 loc) · 1.44 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
function criptografar() {
acao();
}
const inserirTexto = document.getElementById("input-texto");
const btnCriptografar = document.getElementById("btn-criptografar");
const btnDescriptografar = document.getElementById("btn-descriptografar");
const inputTexto = document.getElementById("btn-copy");
const copiarTexto = document.getElementById("copiar-text");
document.addEventListener("click", function (event) {
event.preventDefault();
let button = event.target.value;
if (button == "CRIPTOGRAFAR!") {
criptografador();
} else if (button == "DESCRIPTOGRAFAR!") {
descriptografar();
} else if (button == "COPIAR") {
copiar();
}
});
function criptografador() {
let valorTexto = inserirTexto.value;
let resultado = valorTexto
.replace(/e/gi, "enter")
.replace(/i/gi, "imes")
.replace(/a/gi, "ai")
.replace(/o/gi, "ober")
.replace(/u/gi, "ufat");
copiarTexto.value = resultado;
}
function descriptografar() {
let textoValor = inserirTexto.value;
let resultado = textoValor
.replace(/enter/gi, "e")
.replace(/imes/gi, "i")
.replace(/ai/gi, "a")
.replace(/ober/gi, "o")
.replace(/ufat/gi, "u");
copiarTexto.value = resultado;
}
function copiar() {
var content = copiarTexto.value;
if (content != "") {
navigator.clipboard
.writeText(content)
.then(() => {
alert("texto");
})
.catch((erro) => {
alert("regra invalida");
});
} else {
}
}