-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
146 lines (122 loc) · 4.43 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
function validadorCPF(){
var input = document.getElementById('floatingInput').value;
if(input.length == 0){
alert("Por favor, insira seu CPF!");
var protocolo = document.getElementById("protocolo1").innerHTML;
if(protocolo != " "){
protocolo = " ";
document.getElementById("protocolo1").innerHTML = protocolo;
}
}
else if(input.length > 0 && input.length < 11){
alert("Digite um CPF válido!");
var protocolo = document.getElementById("protocolo1").innerHTML;
if(protocolo != " "){
protocolo = " ";
document.getElementById("protocolo1").innerHTML = protocolo;
}
}
if(input.length == 11){
geradorProtocolo()
radioEscolhido();
geradorData();
desfazRadio();
limparInput();
}
}
function geradorProtocolo(){
var protocolo = document.getElementById("protocolo1").innerHTML;
if(protocolo != " "){
protocolo = " ";
document.getElementById("protocolo1").innerHTML = protocolo;
}
var data = new Date();
var protocoloNum = (" 0" + data.getDate()).substr(-2)+(" 0" + (data.getMonth() + 1)).substr(-2)+data.getFullYear()+Math.floor(1000 + Math.random() * 9000);
stringProto = protocolo + protocoloNum;
if(document.getElementById("flexRadioDefault1").checked == true){
document.getElementById("protocolo1").innerHTML = stringProto;
}
else if(document.getElementById("flexRadioDefault2").checked == true){
document.getElementById("protocolo1").innerHTML = stringProto;
}
if(document.getElementById("flexRadioDefault1").checked == false && document.getElementById("flexRadioDefault2").checked == false){
alert("Por favor, escolha o tipo de atendimento!");
}
}
function generateRan(){
var max = 500;
var random = [];
for(var i = 0;i<max ; i++){
var temp = Math.floor(Math.random()*max);
if(random.indexOf(temp) == -1){
random.push(temp);
}
else{
i--;
}
return temp;
}
}
function radioEscolhido(){
var senha = document.getElementById('nSenha').innerHTML;
if(document.getElementById("flexRadioDefault1").checked == true){
senha = 'CN' + generateRan();
document.getElementById('nSenha').innerHTML = senha;
}
else if(document.getElementById("flexRadioDefault2").checked == true){
senha = 'AA' + generateRan();
document.getElementById('nSenha').innerHTML = senha;
}
limparInput();
}
function desfazRadio(){
if(document.getElementById("flexRadioDefault1").checked == true){
document.getElementById("flexRadioDefault1").checked = false;
}
else if(document.getElementById("flexRadioDefault2").checked == true){
document.getElementById("flexRadioDefault2").checked = false;
}
}
function dataAtualFormatada(){
let data = new Date(),
dia = data.getDate().toString().padStart(2, '0'),
mes = (data.getMonth()+1).toString().padStart(2, '0'),
ano = data.getFullYear();
return `${dia}/${mes}/${ano}`;
}
function horaAtualFormatada(){
let horario = new Date(),
hora = horario.getHours().toString().padStart(2, '0'),
minutos = horario.getMinutes().toString().padStart(2, '0'),
segundos = horario.getSeconds().toString().padStart(2, '0');
return `${hora}:${minutos}:${segundos}`;
}
function geradorData(){
var data = new Date();
/*var dia = data.getDay();
var mes = data.getMonth();
var ano = data.getFullYear();*/
var hora = data.getHours();
var min = data.getMinutes();
var second = data.getSeconds();
/*var str_data = dia + '/' + (mes+1) + '/' + ano;*/
//var str_hora = hora + ':' + min + ':' + second;
var stringHora = document.getElementById("hora").innerHTML;
if(stringHora != " "){
stringHora = " ";
stringHora = dataAtualFormatada() + ' ' + horaAtualFormatada();
if(document.getElementById("flexRadioDefault1").checked == true){
document.getElementById("hora").innerHTML = stringHora;
}
else if(document.getElementById('flexRadioDefault2').checked == true){
document.getElementById("hora").innerHTML = stringHora;
}
}
}
function limparInput(){
var input = document.getElementById('floatingInput').value;
if(input != ""){
input = "";
document.getElementById('floatingInput').value = input;
}
}