-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (60 loc) · 1.88 KB
/
script.js
File metadata and controls
67 lines (60 loc) · 1.88 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
var input = document.querySelector("#input-texto")
input.focus()
var button = document.querySelector("#btn-cripto")
var buttonDecripta = document.querySelector("#btn-descripto")
var buttonVal = document.querySelector("#msg")
var copyButton = document.querySelector("#btn-copy")
function limpaTela(){
input.value = ""
input.focus()
}
function cripto(){
var texto = input.value
var textoDecripto = texto.replace(/e/gi,"enter").replace(/i/gi,"imes").replace(/a/gi,"ai").replace(/o/gi,"ober").replace(/u/gi, "ufat")
buttonVal.value = textoDecripto
input.value = ""
}
function validarMaiuscula(){
var i=0
var contator = 0
var caracter = ""
var texto = input.value
if(texto == ""){
alert("Diigte um texto para ser criptografado")
input.focus()
}else{
while (i <= texto.length - 1){
caracter = texto.charAt(i)
if ((caracter == caracter.toUpperCase() && caracter != " ") || caracter == caracter.match(/[áâãàéêíóõôúç]/)) {
contator++
}
i++
}
}
if (contator > 0){
alert("Digite apenas letras minúscula, sem acentuação")
limpaTela()
}else(
cripto()
)
}
function decripta(){
var msgCripto = input.value
if(msgCripto != "" ){
var textoDecripto = msgCripto.replace(/enter/gi,"e").replace(/imes/gi,"i").replace(/ai/gi,"a").replace(/ober/gi,"o").replace(/ufat/gi, "u")
alert(textoDecripto)
limpaTela()
}else{
alert("Diigte um texto para ser descriptografado")
input.focus()
}
}
function copiar(){
var texto = buttonVal
texto.select()
document.execCommand("copy")
texto.value = ""
}
button.onclick = validarMaiuscula
buttonDecripta.onclick = decripta
copyButton.addEventListener("click", copiar)