-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
104 lines (86 loc) · 3.24 KB
/
script.js
File metadata and controls
104 lines (86 loc) · 3.24 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
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
re = new RegExp("^[a-z/s ]+$");
function apareceConteudo() {
document.querySelector("#texto2").value = "";
document.querySelector("#texto2").classList.remove("background");
document.querySelector("#gif").classList.remove("z-index");
document.querySelector(".enter").classList.remove("z-index");
document.querySelector(".nomsg").classList.remove("z-index");
}
function apareceTexto(novoTexto) {
document.querySelector("#texto2").classList.add("background");
document.querySelector("#gif").classList.add("z-index");
document.querySelector(".enter").classList.add("z-index");
document.querySelector(".nomsg").classList.add("z-index");
document.querySelector("#texto2").value = novoTexto;
document.querySelector("#texto").value = "";
document.querySelector("#texto").focus();
event.preventDefault();
}
function invalidaMensagem() {
document
.querySelector("#texto")
.setCustomValidity("Não use letras maiúsculas ou acentos");
}
function apagaAviso() {
document.querySelector("#texto").setCustomValidity("");
}
function apareceInvalido() {
document.querySelector(".invalido").style.opacity = "60%";
}
function apagaInvalido() {
document.querySelector(".invalido").style.opacity = "0%";
}
function apareceCopiado() {
document.querySelector(".valido").style.opacity = "60%";
}
function apagaCopiado() {
document.querySelector(".valido").style.opacity = "0%";
}
document.querySelector("#encript").addEventListener("click", () => {
texto = document.querySelector("#texto").value;
if (texto.match(re)) {
let novoTexto = texto.replace(/e/g, "enter");
novoTexto = novoTexto.replace(/i/g, "imes");
novoTexto = novoTexto.replace(/a/g, "ai");
novoTexto = novoTexto.replace(/o/g, "ober");
novoTexto = novoTexto.replace(/u/g, "ufat");
apareceTexto(novoTexto);
} else if (!texto.match(re) && texto !== "") {
invalidaMensagem();
setTimeout(apagaAviso, 1200);
}
});
document.querySelector("#descript").addEventListener("click", () => {
texto = document.querySelector("#texto").value;
if (texto.match(re)) {
let novoTexto = texto.replace(/enter/g, "e");
novoTexto = novoTexto.replace(/imes/g, "i");
novoTexto = novoTexto.replace(/ai/g, "a");
novoTexto = novoTexto.replace(/ober/g, "o");
novoTexto = novoTexto.replace(/ufat/g, "u");
apareceTexto(novoTexto);
} else if (!texto.match(re) && texto !== "") {
invalidaMensagem();
setTimeout(apagaAviso, 2000);
}
});
document.querySelector("#copiar").addEventListener("click", () => {
textoCopiado = document.querySelector("#texto2").value;
if (textoCopiado == "") {
apareceInvalido();
setTimeout(apagaInvalido, 1500);
}
if (textoCopiado != "") {
textoCopiado = document.querySelector("#texto2").select();
document.execCommand("copy");
apareceCopiado();
setTimeout(apagaCopiado, 1500);
apareceConteudo();
document.querySelector("#texto").focus();
}
});
document.querySelector("#limpar").addEventListener("click", () => {
apareceConteudo();
document.querySelector("#texto").value = "";
document.querySelector("#texto").focus();
});