-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
71 lines (57 loc) · 2.17 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
var resultado;
var x = document.getElementById('conteudo-caixa-1');
var y = document.getElementById('conteudo-caixa-2');
function temTexto() {
var textoInserido = document.getElementById('texto-inserido').value;
if (textoInserido == "") {
x.style.display = 'block';
y.style.display = 'none';
} else {
x.style.display = 'none';
y.style.display = 'block';
}
}
function temCaracteresEspeciais() {
textoInserido = document.getElementById('texto-inserido').value;
const pattern = /[0-9A-ZÀ-ü@´`^~'"]/;
if (textoInserido.match(pattern)) {
alert("Por favor use somente letras minúsculas e sem acento!")
document.getElementById('texto-inserido').value = "";
x.style.display = 'block';
y.style.display = 'none';
}
}
function copiaTexto() {
var textoCopiado = document.getElementById('text-caixa').textContent;
navigator.clipboard.writeText(textoCopiado);
alert("Copiado!");
document.getElementById('texto-inserido').value = "";
}
function criptografa() {
temTexto();
temCaracteresEspeciais();
textoInserido = document.getElementById('texto-inserido').value;
resultado = textoInserido.replace(/e/gi, "enter")
.replace(/i/gi, "imes")
.replace(/a/gi, "ai")
.replace(/o/gi, "ober")
.replace(/u/gi, "ufat");
document.getElementById('text-caixa').innerHTML = resultado;
}
function descriptografa() {
temTexto();
temCaracteresEspeciais();
textoInserido = document.getElementById('texto-inserido').value;
resultado = textoInserido.replace(/enter/gi, "e")
.replace(/imes/gi, "i")
.replace(/ai/gi, "a")
.replace(/ober/gi, "o")
.replace(/ufat/gi, "u");
document.getElementById('text-caixa').innerHTML = resultado;
}
var copiar = document.querySelector("#copiarTexto");
copiar.onclick = copiaTexto;
var btnCriptografa = document.querySelector("#criptografa");
btnCriptografa.onclick = criptografa;
var btnDescriptografa = document.querySelector("#descriptografa");
btnDescriptografa.onclick = descriptografa;