-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
60 lines (55 loc) · 1.72 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
54
55
56
57
58
59
60
const input = document.querySelector('#texto');
var crip = document.getElementById('crip');
var descrip = document.getElementById('descrip')
var saidaTexto = document.querySelector('#saidaTexto')
var saidatexto = document.querySelector('.saidatexto')
var msg = document.querySelector('.msg')
var btncopiarTexto = document.getElementById("btncopiarTexto");
//A letra "e" é convertida para "enter"
//A letra "i" é convertida para "imes"
//A letra "a" é convertida para "ai"
//A letra "o" é convertida para "ober"
//A letra "u" é convertida para "ufat"
function criptografar(event){
var n = input.value;
var newStr = n.replace(/e/g , 'enter')
.replace(/i/g , 'imes')
.replace(/a/g , 'ai')
.replace(/o/g , 'ober')
.replace(/u/g , 'ufat');
//console.log(newStr);
saidaTexto.value= newStr
verificar()
};
function descriptografar(event){
var n = input.value;
var newStr = n.replace(/enter/g , 'e')
.replace(/imes/g , 'i')
.replace(/ai/g , 'a')
.replace(/ober/g , 'o')
.replace(/ufat/g , 'u');
//console.log(newStr);
saidaTexto.value= newStr
verificar()
};
function copiarTexto() {
var textoCopiado = document.getElementById("saidaTexto");
textoCopiado.select();
textoCopiado.setSelectionRange(0, 99999)
document.execCommand("copy");
}
const verificar = () =>{
if(saidaTexto.value == ''){
msg.className="msg";
saidatexto.style.display='none'
return true
}else {
msg.className="hide";
saidatexto.style.display= 'block'
return false
};
};
crip.addEventListener("click", criptografar);
descrip.addEventListener("click", descriptografar);
btncopiarTexto.addEventListener("click", copiarTexto);
console.log('ativo')