MFBarreto commited on
Commit
bd9e5fe
·
verified ·
1 Parent(s): 4e2f352

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +950 -19
  3. prompts.txt +0 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Https Enzostvs Deepsite Hf Space
3
- emoji: 🐨
4
- colorFrom: red
5
- colorTo: red
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: https-enzostvs-deepsite-hf-space
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,950 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Urna Eletrônica</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ @keyframes blink {
11
+ 0% { opacity: 1; }
12
+ 50% { opacity: 0.5; }
13
+ 100% { opacity: 1; }
14
+ }
15
+ .blink {
16
+ animation: blink 1s infinite;
17
+ }
18
+ .urna-screen {
19
+ background-color: #e0e0e0;
20
+ border-radius: 10px;
21
+ box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
22
+ }
23
+ .urna-key {
24
+ background-color: #333;
25
+ color: white;
26
+ border-radius: 50%;
27
+ width: 60px;
28
+ height: 60px;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ font-weight: bold;
33
+ cursor: pointer;
34
+ user-select: none;
35
+ box-shadow: 0 4px 0 #111;
36
+ }
37
+ .urna-key:active {
38
+ transform: translateY(2px);
39
+ box-shadow: 0 2px 0 #111;
40
+ }
41
+ .urna-key-white {
42
+ background-color: white;
43
+ color: #333;
44
+ }
45
+ .urna-key-orange {
46
+ background-color: #ff8c00;
47
+ }
48
+ .urna-key-green {
49
+ background-color: #4CAF50;
50
+ }
51
+ .screen-text {
52
+ font-family: 'Courier New', monospace;
53
+ }
54
+ .candidate-photo {
55
+ border: 3px solid #333;
56
+ background-color: #fff;
57
+ }
58
+ .progress-bar {
59
+ height: 20px;
60
+ background-color: #e0e0e0;
61
+ border-radius: 10px;
62
+ overflow: hidden;
63
+ }
64
+ .progress-fill {
65
+ height: 100%;
66
+ background-color: #4CAF50;
67
+ transition: width 0.3s;
68
+ }
69
+ </style>
70
+ </head>
71
+ <body class="bg-gray-100 min-h-screen">
72
+ <div class="container mx-auto px-4 py-8">
73
+ <!-- Admin Panel (hidden by default) -->
74
+ <div id="adminPanel" class="hidden bg-white rounded-lg shadow-lg p-6 mb-8">
75
+ <h2 class="text-2xl font-bold mb-6 text-center">Painel de Administração</h2>
76
+
77
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
78
+ <!-- Voter Registration -->
79
+ <div class="bg-gray-50 p-4 rounded-lg">
80
+ <h3 class="text-lg font-semibold mb-4">Cadastrar Eleitor</h3>
81
+ <div class="space-y-4">
82
+ <div>
83
+ <label class="block text-sm font-medium text-gray-700">Matrícula</label>
84
+ <input type="text" id="voterId" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
85
+ </div>
86
+ <div>
87
+ <label class="block text-sm font-medium text-gray-700">Nome</label>
88
+ <input type="text" id="voterName" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
89
+ </div>
90
+ <div>
91
+ <label class="block text-sm font-medium text-gray-700">Senha</label>
92
+ <input type="password" id="voterPassword" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
93
+ </div>
94
+ <button onclick="registerVoter()" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
95
+ Cadastrar Eleitor
96
+ </button>
97
+ </div>
98
+ </div>
99
+
100
+ <!-- Position Management -->
101
+ <div class="bg-gray-50 p-4 rounded-lg">
102
+ <h3 class="text-lg font-semibold mb-4">Gerenciar Cargos</h3>
103
+ <div class="space-y-4">
104
+ <div>
105
+ <label class="block text-sm font-medium text-gray-700">Nome do Cargo</label>
106
+ <input type="text" id="positionName" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
107
+ </div>
108
+ <div>
109
+ <label class="block text-sm font-medium text-gray-700">Número (até 3 dígitos)</label>
110
+ <input type="number" min="1" max="999" id="positionNumber" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
111
+ </div>
112
+ <button onclick="addPosition()" class="w-full bg-green-600 text-white py-2 px-4 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2">
113
+ Adicionar Cargo
114
+ </button>
115
+ </div>
116
+ </div>
117
+
118
+ <!-- Candidate Registration -->
119
+ <div class="bg-gray-50 p-4 rounded-lg">
120
+ <h3 class="text-lg font-semibold mb-4">Cadastrar Candidato</h3>
121
+ <div class="space-y-4">
122
+ <div>
123
+ <label class="block text-sm font-medium text-gray-700">Cargo</label>
124
+ <select id="candidatePosition" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
125
+ <!-- Options will be added dynamically -->
126
+ </select>
127
+ </div>
128
+ <div>
129
+ <label class="block text-sm font-medium text-gray-700">Número do Candidato</label>
130
+ <input type="number" min="1" max="999" id="candidateNumber" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
131
+ </div>
132
+ <div>
133
+ <label class="block text-sm font-medium text-gray-700">Nome do Candidato</label>
134
+ <input type="text" id="candidateName" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
135
+ </div>
136
+ <div>
137
+ <label class="block text-sm font-medium text-gray-700">Foto (URL)</label>
138
+ <input type="text" id="candidatePhoto" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="https://exemplo.com/foto.jpg">
139
+ </div>
140
+ <button onclick="registerCandidate()" class="w-full bg-purple-600 text-white py-2 px-4 rounded-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2">
141
+ Cadastrar Candidato
142
+ </button>
143
+ </div>
144
+ </div>
145
+
146
+ <!-- Election Control -->
147
+ <div class="bg-gray-50 p-4 rounded-lg">
148
+ <h3 class="text-lg font-semibold mb-4">Controle da Eleição</h3>
149
+ <div class="space-y-4">
150
+ <div class="flex space-x-4">
151
+ <button onclick="startElection()" class="flex-1 bg-green-600 text-white py-2 px-4 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2">
152
+ Iniciar Eleição
153
+ </button>
154
+ <button onclick="endElection()" class="flex-1 bg-red-600 text-white py-2 px-4 rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2">
155
+ Encerrar Eleição
156
+ </button>
157
+ </div>
158
+ <div>
159
+ <button onclick="showResults()" class="w-full bg-yellow-600 text-white py-2 px-4 rounded-md hover:bg-yellow-700 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2">
160
+ Mostrar Resultados
161
+ </button>
162
+ </div>
163
+ </div>
164
+ </div>
165
+ </div>
166
+
167
+ <!-- Admin Login -->
168
+ <div id="adminLogin" class="mt-8 bg-gray-50 p-4 rounded-lg max-w-md mx-auto">
169
+ <h3 class="text-lg font-semibold mb-4">Acesso do Administrador</h3>
170
+ <div class="space-y-4">
171
+ <div>
172
+ <label class="block text-sm font-medium text-gray-700">Senha do Administrador</label>
173
+ <input type="password" id="adminPassword" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
174
+ </div>
175
+ <button onclick="loginAdmin()" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
176
+ Acessar Painel
177
+ </button>
178
+ </div>
179
+ </div>
180
+ </div>
181
+
182
+ <!-- Voter Login -->
183
+ <div id="voterLogin" class="bg-white rounded-lg shadow-lg p-6 mb-8 max-w-md mx-auto">
184
+ <h2 class="text-2xl font-bold mb-6 text-center">Login do Eleitor</h2>
185
+ <div class="space-y-4">
186
+ <div>
187
+ <label class="block text-sm font-medium text-gray-700">Matrícula</label>
188
+ <input type="text" id="loginVoterId" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
189
+ </div>
190
+ <div>
191
+ <label class="block text-sm font-medium text-gray-700">Senha</label>
192
+ <input type="password" id="loginVoterPassword" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
193
+ </div>
194
+ <button onclick="loginVoter()" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
195
+ Acessar Urna
196
+ </button>
197
+ <button onclick="showAdminPanel()" class="w-full bg-gray-600 text-white py-2 px-4 rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2">
198
+ Acesso Administrativo
199
+ </button>
200
+ </div>
201
+ </div>
202
+
203
+ <!-- Voting Machine -->
204
+ <div id="votingMachine" class="hidden bg-gray-800 rounded-lg shadow-xl p-6 max-w-4xl mx-auto">
205
+ <div class="flex flex-col md:flex-row gap-6">
206
+ <!-- Screen -->
207
+ <div class="flex-1">
208
+ <div class="urna-screen p-4 h-96 mb-4">
209
+ <div id="screenContent" class="h-full flex flex-col">
210
+ <!-- Content will be dynamically updated -->
211
+ <div class="flex-1 flex items-center justify-center">
212
+ <p class="text-xl font-bold">Bem-vindo à Urna Eletrônica</p>
213
+ </div>
214
+ </div>
215
+ </div>
216
+ <div class="flex justify-between items-center bg-gray-700 text-white p-2 rounded">
217
+ <div id="currentPosition" class="font-bold">Selecione um cargo</div>
218
+ <div id="typedNumbers" class="text-xl font-mono">_ _ _</div>
219
+ </div>
220
+ </div>
221
+
222
+ <!-- Keyboard -->
223
+ <div class="w-full md:w-64">
224
+ <div class="grid grid-cols-3 gap-3 mb-3">
225
+ <div class="urna-key" onclick="pressKey(1)">1</div>
226
+ <div class="urna-key" onclick="pressKey(2)">2</div>
227
+ <div class="urna-key" onclick="pressKey(3)">3</div>
228
+ <div class="urna-key" onclick="pressKey(4)">4</div>
229
+ <div class="urna-key" onclick="pressKey(5)">5</div>
230
+ <div class="urna-key" onclick="pressKey(6)">6</div>
231
+ <div class="urna-key" onclick="pressKey(7)">7</div>
232
+ <div class="urna-key" onclick="pressKey(8)">8</div>
233
+ <div class="urna-key" onclick="pressKey(9)">9</div>
234
+ <div class="urna-key urna-key-white" onclick="pressKey(0)">0</div>
235
+ <div class="urna-key urna-key-white" onclick="clearNumbers()">
236
+ <i class="fas fa-backspace"></i>
237
+ </div>
238
+ </div>
239
+ <div class="grid grid-cols-2 gap-3">
240
+ <div class="urna-key urna-key-orange" onclick="blankVote()">BRANCO</div>
241
+ <div class="urna-key urna-key-green" onclick="confirmVote()">CONFIRMA</div>
242
+ <div class="urna-key urna-key-white" onclick="correctVote()">CORRIGE</div>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </div>
247
+
248
+ <!-- Results Panel -->
249
+ <div id="resultsPanel" class="hidden bg-white rounded-lg shadow-lg p-6 mb-8">
250
+ <h2 class="text-2xl font-bold mb-6 text-center">Resultados da Eleição</h2>
251
+
252
+ <div id="resultsContent" class="space-y-8">
253
+ <!-- Results will be added dynamically -->
254
+ </div>
255
+
256
+ <div class="mt-8">
257
+ <button onclick="hideResults()" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
258
+ Voltar
259
+ </button>
260
+ </div>
261
+ </div>
262
+ </div>
263
+
264
+ <script>
265
+ // Database simulation
266
+ let voters = [];
267
+ let positions = [];
268
+ let candidates = [];
269
+ let votes = [];
270
+ let electionActive = false;
271
+ let currentUser = null;
272
+ let isAdmin = false;
273
+
274
+ // Voting machine state
275
+ let currentPositionIndex = 0;
276
+ let typedNumbers = [];
277
+ let votedPositions = [];
278
+
279
+ // Admin password (in a real app, this should be hashed and stored securely)
280
+ const ADMIN_PASSWORD = "admin123";
281
+
282
+ // Initialize with some sample data
283
+ function initializeSampleData() {
284
+ if (localStorage.getItem('electionInitialized')) return;
285
+
286
+ // Sample positions
287
+ positions = [
288
+ { id: 1, name: "Presidente", number: 100 },
289
+ { id: 2, name: "Vice-Presidente", number: 200 },
290
+ { id: 3, name: "1º Secretário", number: 300 },
291
+ { id: 4, name: "2º Secretário", number: 400 },
292
+ { id: 5, name: "Tesoureiro", number: 500 },
293
+ { id: 6, name: "Secretário Executivo", number: 600 },
294
+ { id: 7, name: "1º Titular", number: 700 },
295
+ { id: 8, name: "2º Titular", number: 800 },
296
+ { id: 9, name: "3º Titular", number: 900 },
297
+ { id: 10, name: "1º Suplente", number: 110 },
298
+ { id: 11, name: "2º Suplente", number: 220 },
299
+ { id: 12, name: "3º Suplente", number: 330 }
300
+ ];
301
+
302
+ // Sample candidates
303
+ candidates = [
304
+ { id: 1, positionId: 1, number: 101, name: "João Silva", photo: "https://randomuser.me/api/portraits/men/1.jpg" },
305
+ { id: 2, positionId: 1, number: 102, name: "Maria Souza", photo: "https://randomuser.me/api/portraits/women/1.jpg" },
306
+ { id: 3, positionId: 2, number: 201, name: "Carlos Oliveira", photo: "https://randomuser.me/api/portraits/men/2.jpg" },
307
+ { id: 4, positionId: 2, number: 202, name: "Ana Santos", photo: "https://randomuser.me/api/portraits/women/2.jpg" }
308
+ ];
309
+
310
+ // Sample voters
311
+ voters = [
312
+ { id: "1001", name: "Eleitor Exemplo 1", password: "123456", voted: false },
313
+ { id: "1002", name: "Eleitor Exemplo 2", password: "123456", voted: false }
314
+ ];
315
+
316
+ localStorage.setItem('electionInitialized', 'true');
317
+ saveData();
318
+ }
319
+
320
+ // Load data from localStorage
321
+ function loadData() {
322
+ const savedVoters = localStorage.getItem('voters');
323
+ const savedPositions = localStorage.getItem('positions');
324
+ const savedCandidates = localStorage.getItem('candidates');
325
+ const savedVotes = localStorage.getItem('votes');
326
+ const savedElectionActive = localStorage.getItem('electionActive');
327
+
328
+ if (savedVoters) voters = JSON.parse(savedVoters);
329
+ if (savedPositions) positions = JSON.parse(savedPositions);
330
+ if (savedCandidates) candidates = JSON.parse(savedCandidates);
331
+ if (savedVotes) votes = JSON.parse(savedVotes);
332
+ if (savedElectionActive) electionActive = savedElectionActive === 'true';
333
+ }
334
+
335
+ // Save data to localStorage
336
+ function saveData() {
337
+ localStorage.setItem('voters', JSON.stringify(voters));
338
+ localStorage.setItem('positions', JSON.stringify(positions));
339
+ localStorage.setItem('candidates', JSON.stringify(candidates));
340
+ localStorage.setItem('votes', JSON.stringify(votes));
341
+ localStorage.setItem('electionActive', electionActive);
342
+ }
343
+
344
+ // Register a new voter
345
+ function registerVoter() {
346
+ const voterId = document.getElementById('voterId').value;
347
+ const voterName = document.getElementById('voterName').value;
348
+ const voterPassword = document.getElementById('voterPassword').value;
349
+
350
+ if (!voterId || !voterName || !voterPassword) {
351
+ alert("Por favor, preencha todos os campos!");
352
+ return;
353
+ }
354
+
355
+ if (voters.some(v => v.id === voterId)) {
356
+ alert("Já existe um eleitor com esta matrícula!");
357
+ return;
358
+ }
359
+
360
+ voters.push({
361
+ id: voterId,
362
+ name: voterName,
363
+ password: voterPassword,
364
+ voted: false
365
+ });
366
+
367
+ saveData();
368
+ alert("Eleitor cadastrado com sucesso!");
369
+ document.getElementById('voterId').value = '';
370
+ document.getElementById('voterName').value = '';
371
+ document.getElementById('voterPassword').value = '';
372
+ }
373
+
374
+ // Add a new position
375
+ function addPosition() {
376
+ const positionName = document.getElementById('positionName').value;
377
+ const positionNumber = parseInt(document.getElementById('positionNumber').value);
378
+
379
+ if (!positionName || isNaN(positionNumber)) {
380
+ alert("Por favor, preencha todos os campos corretamente!");
381
+ return;
382
+ }
383
+
384
+ if (positionNumber < 1 || positionNumber > 999) {
385
+ alert("O número do cargo deve ter até 3 dígitos (1-999)!");
386
+ return;
387
+ }
388
+
389
+ if (positions.some(p => p.number === positionNumber)) {
390
+ alert("Já existe um cargo com este número!");
391
+ return;
392
+ }
393
+
394
+ const newId = positions.length > 0 ? Math.max(...positions.map(p => p.id)) + 1 : 1;
395
+
396
+ positions.push({
397
+ id: newId,
398
+ name: positionName,
399
+ number: positionNumber
400
+ });
401
+
402
+ saveData();
403
+ alert("Cargo adicionado com sucesso!");
404
+ document.getElementById('positionName').value = '';
405
+ document.getElementById('positionNumber').value = '';
406
+ updatePositionSelects();
407
+ }
408
+
409
+ // Register a new candidate
410
+ function registerCandidate() {
411
+ const positionId = parseInt(document.getElementById('candidatePosition').value);
412
+ const candidateNumber = parseInt(document.getElementById('candidateNumber').value);
413
+ const candidateName = document.getElementById('candidateName').value;
414
+ const candidatePhoto = document.getElementById('candidatePhoto').value;
415
+
416
+ if (isNaN(positionId) || isNaN(candidateNumber) || !candidateName) {
417
+ alert("Por favor, preencha todos os campos obrigatórios!");
418
+ return;
419
+ }
420
+
421
+ if (candidateNumber < 1 || candidateNumber > 999) {
422
+ alert("O número do candidato deve ter até 3 dígitos (1-999)!");
423
+ return;
424
+ }
425
+
426
+ const position = positions.find(p => p.id === positionId);
427
+ if (!position) {
428
+ alert("Cargo inválido!");
429
+ return;
430
+ }
431
+
432
+ // Check if candidate number matches position number (first digit)
433
+ if (Math.floor(candidateNumber / 100) !== Math.floor(position.number / 100)) {
434
+ alert(`O número do candidato deve começar com ${Math.floor(position.number / 100)} para este cargo!`);
435
+ return;
436
+ }
437
+
438
+ if (candidates.some(c => c.positionId === positionId && c.number === candidateNumber)) {
439
+ alert("Já existe um candidato com este número para este cargo!");
440
+ return;
441
+ }
442
+
443
+ const newId = candidates.length > 0 ? Math.max(...candidates.map(c => c.id)) + 1 : 1;
444
+
445
+ candidates.push({
446
+ id: newId,
447
+ positionId: positionId,
448
+ number: candidateNumber,
449
+ name: candidateName,
450
+ photo: candidatePhoto || "https://via.placeholder.com/150?text=Sem+Foto"
451
+ });
452
+
453
+ saveData();
454
+ alert("Candidato cadastrado com sucesso!");
455
+ document.getElementById('candidateNumber').value = '';
456
+ document.getElementById('candidateName').value = '';
457
+ document.getElementById('candidatePhoto').value = '';
458
+ }
459
+
460
+ // Update position selects in forms
461
+ function updatePositionSelects() {
462
+ const positionSelect = document.getElementById('candidatePosition');
463
+ positionSelect.innerHTML = '';
464
+
465
+ positions.forEach(position => {
466
+ const option = document.createElement('option');
467
+ option.value = position.id;
468
+ option.textContent = `${position.number} - ${position.name}`;
469
+ positionSelect.appendChild(option);
470
+ });
471
+ }
472
+
473
+ // Start election
474
+ function startElection() {
475
+ if (electionActive) {
476
+ alert("A eleição já está em andamento!");
477
+ return;
478
+ }
479
+
480
+ if (positions.length === 0) {
481
+ alert("Não há cargos cadastrados para iniciar a eleição!");
482
+ return;
483
+ }
484
+
485
+ electionActive = true;
486
+ saveData();
487
+ alert("Eleição iniciada com sucesso!");
488
+ }
489
+
490
+ // End election
491
+ function endElection() {
492
+ if (!electionActive) {
493
+ alert("Não há eleição em andamento!");
494
+ return;
495
+ }
496
+
497
+ electionActive = false;
498
+ saveData();
499
+ alert("Eleição encerrada com sucesso!");
500
+ }
501
+
502
+ // Show admin panel
503
+ function showAdminPanel() {
504
+ document.getElementById('voterLogin').classList.add('hidden');
505
+ document.getElementById('adminPanel').classList.remove('hidden');
506
+ document.getElementById('adminLogin').classList.remove('hidden');
507
+ document.getElementById('votingMachine').classList.add('hidden');
508
+ document.getElementById('resultsPanel').classList.add('hidden');
509
+ }
510
+
511
+ // Admin login
512
+ function loginAdmin() {
513
+ const password = document.getElementById('adminPassword').value;
514
+
515
+ if (password === ADMIN_PASSWORD) {
516
+ isAdmin = true;
517
+ document.getElementById('adminLogin').classList.add('hidden');
518
+ updatePositionSelects();
519
+ alert("Acesso administrativo concedido!");
520
+ } else {
521
+ alert("Senha incorreta!");
522
+ }
523
+
524
+ document.getElementById('adminPassword').value = '';
525
+ }
526
+
527
+ // Voter login
528
+ function loginVoter() {
529
+ const voterId = document.getElementById('loginVoterId').value;
530
+ const voterPassword = document.getElementById('loginVoterPassword').value;
531
+
532
+ const voter = voters.find(v => v.id === voterId && v.password === voterPassword);
533
+
534
+ if (!voter) {
535
+ alert("Matrícula ou senha incorretos!");
536
+ return;
537
+ }
538
+
539
+ if (!electionActive) {
540
+ alert("Não há eleição em andamento no momento!");
541
+ return;
542
+ }
543
+
544
+ if (voter.voted) {
545
+ alert("Este eleitor já votou!");
546
+ return;
547
+ }
548
+
549
+ currentUser = voter;
550
+ document.getElementById('voterLogin').classList.add('hidden');
551
+ document.getElementById('votingMachine').classList.remove('hidden');
552
+
553
+ // Start voting process
554
+ currentPositionIndex = 0;
555
+ typedNumbers = [];
556
+ votedPositions = [];
557
+ updateScreen();
558
+ }
559
+
560
+ // Press key on voting machine
561
+ function pressKey(number) {
562
+ if (typedNumbers.length < 3) {
563
+ typedNumbers.push(number);
564
+ updateScreen();
565
+ }
566
+ }
567
+
568
+ // Clear typed numbers
569
+ function clearNumbers() {
570
+ typedNumbers = [];
571
+ updateScreen();
572
+ }
573
+
574
+ // Blank vote
575
+ function blankVote() {
576
+ if (typedNumbers.length > 0) {
577
+ if (!confirm("Deseja realmente votar em BRANCO? Os números digitados serão descartados.")) {
578
+ return;
579
+ }
580
+ }
581
+
582
+ registerVote(null);
583
+ }
584
+
585
+ // Confirm vote
586
+ function confirmVote() {
587
+ if (typedNumbers.length === 0) {
588
+ alert("Digite um número antes de confirmar!");
589
+ return;
590
+ }
591
+
592
+ const candidateNumber = parseInt(typedNumbers.join(''));
593
+ const position = positions[currentPositionIndex];
594
+
595
+ // Find candidate for this position with this number
596
+ const candidate = candidates.find(c =>
597
+ c.positionId === position.id && c.number === candidateNumber
598
+ );
599
+
600
+ if (!candidate) {
601
+ if (!confirm(`Nenhum candidato encontrado com o número ${candidateNumber}. Deseja votar NULO?`)) {
602
+ return;
603
+ }
604
+ }
605
+
606
+ registerVote(candidateNumber);
607
+ }
608
+
609
+ // Correct vote
610
+ function correctVote() {
611
+ typedNumbers = [];
612
+ updateScreen();
613
+ }
614
+
615
+ // Register vote
616
+ function registerVote(candidateNumber) {
617
+ const position = positions[currentPositionIndex];
618
+
619
+ votes.push({
620
+ positionId: position.id,
621
+ voterId: currentUser.id,
622
+ candidateNumber: candidateNumber,
623
+ timestamp: new Date().toISOString()
624
+ });
625
+
626
+ votedPositions.push(position.id);
627
+
628
+ // Move to next position or finish voting
629
+ currentPositionIndex++;
630
+ typedNumbers = [];
631
+
632
+ if (currentPositionIndex >= positions.length) {
633
+ finishVoting();
634
+ } else {
635
+ // Skip positions that have already been voted (in case of multiple positions with same number)
636
+ while (currentPositionIndex < positions.length &&
637
+ votedPositions.includes(positions[currentPositionIndex].id)) {
638
+ currentPositionIndex++;
639
+ }
640
+
641
+ if (currentPositionIndex >= positions.length) {
642
+ finishVoting();
643
+ } else {
644
+ updateScreen();
645
+ }
646
+ }
647
+ }
648
+
649
+ // Finish voting process
650
+ function finishVoting() {
651
+ // Mark voter as voted
652
+ const voterIndex = voters.findIndex(v => v.id === currentUser.id);
653
+ if (voterIndex !== -1) {
654
+ voters[voterIndex].voted = true;
655
+ saveData();
656
+ }
657
+
658
+ // Show confirmation
659
+ document.getElementById('screenContent').innerHTML = `
660
+ <div class="h-full flex flex-col items-center justify-center text-center">
661
+ <div class="text-2xl font-bold mb-4">VOTO CONFIRMADO</div>
662
+ <div class="text-lg mb-6">Obrigado por votar!</div>
663
+ <div class="text-sm">Sua participação é fundamental para a democracia.</div>
664
+ </div>
665
+ `;
666
+
667
+ // Return to login after 5 seconds
668
+ setTimeout(() => {
669
+ document.getElementById('votingMachine').classList.add('hidden');
670
+ document.getElementById('voterLogin').classList.remove('hidden');
671
+ document.getElementById('loginVoterId').value = '';
672
+ document.getElementById('loginVoterPassword').value = '';
673
+ currentUser = null;
674
+ }, 5000);
675
+ }
676
+
677
+ // Update voting machine screen
678
+ function updateScreen() {
679
+ const position = positions[currentPositionIndex];
680
+ const typedNumberStr = typedNumbers.join('');
681
+
682
+ // Update typed numbers display
683
+ const typedDisplay = document.getElementById('typedNumbers');
684
+ typedDisplay.innerHTML = '';
685
+
686
+ for (let i = 0; i < 3; i++) {
687
+ const digit = document.createElement('span');
688
+ digit.className = 'inline-block w-6 text-center';
689
+ digit.textContent = typedNumbers[i] !== undefined ? typedNumbers[i] : '_';
690
+
691
+ if (i === typedNumbers.length) {
692
+ digit.classList.add('blink');
693
+ }
694
+
695
+ typedDisplay.appendChild(digit);
696
+ }
697
+
698
+ // Update current position display
699
+ document.getElementById('currentPosition').textContent = position
700
+ ? `${position.number} - ${position.name}`
701
+ : "Selecione um cargo";
702
+
703
+ // Update screen content
704
+ const screenContent = document.getElementById('screenContent');
705
+
706
+ if (!position) {
707
+ screenContent.innerHTML = `
708
+ <div class="h-full flex items-center justify-center">
709
+ <p class="text-xl font-bold">Nenhum cargo disponível</p>
710
+ </div>
711
+ `;
712
+ return;
713
+ }
714
+
715
+ if (typedNumbers.length === 0) {
716
+ // Show position info
717
+ screenContent.innerHTML = `
718
+ <div class="h-full flex flex-col">
719
+ <div class="text-center py-2 bg-blue-800 text-white font-bold">
720
+ ${position.number} - ${position.name}
721
+ </div>
722
+ <div class="flex-1 flex items-center justify-center">
723
+ <div class="text-center">
724
+ <div class="text-xl font-bold mb-2">Digite o número</div>
725
+ <div class="text-lg">do candidato e confirme</div>
726
+ </div>
727
+ </div>
728
+ </div>
729
+ `;
730
+ } else {
731
+ // Show candidate info
732
+ const candidateNumber = parseInt(typedNumberStr.padEnd(3, '0'));
733
+ const candidate = candidates.find(c =>
734
+ c.positionId === position.id && c.number === candidateNumber
735
+ );
736
+
737
+ if (candidate) {
738
+ // Show candidate info
739
+ screenContent.innerHTML = `
740
+ <div class="h-full flex flex-col">
741
+ <div class="text-center py-2 bg-blue-800 text-white font-bold">
742
+ ${position.number} - ${position.name}
743
+ </div>
744
+ <div class="flex-1 flex flex-col md:flex-row items-center justify-center p-4">
745
+ <div class="candidate-photo w-24 h-24 md:w-32 md:h-32 mb-4 md:mb-0 md:mr-6 flex items-center justify-center overflow-hidden">
746
+ <img src="${candidate.photo}" alt="Foto" class="w-full h-full object-cover">
747
+ </div>
748
+ <div class="text-center md:text-left">
749
+ <div class="text-xl font-bold">${candidate.name}</div>
750
+ <div class="text-lg">${candidate.number}</div>
751
+ <div class="mt-2 text-sm">Confirme seu voto</div>
752
+ </div>
753
+ </div>
754
+ </div>
755
+ `;
756
+ } else {
757
+ // Show number with no candidate
758
+ screenContent.innerHTML = `
759
+ <div class="h-full flex flex-col">
760
+ <div class="text-center py-2 bg-blue-800 text-white font-bold">
761
+ ${position.number} - ${position.name}
762
+ </div>
763
+ <div class="flex-1 flex flex-col items-center justify-center p-4">
764
+ <div class="text-4xl font-bold mb-4">${typedNumberStr}</div>
765
+ <div class="text-lg">Nenhum candidato encontrado</div>
766
+ <div class="mt-2 text-sm">Voto NULO - Confirme se deseja</div>
767
+ </div>
768
+ </div>
769
+ `;
770
+ }
771
+ }
772
+ }
773
+
774
+ // Show election results
775
+ function showResults() {
776
+ if (!isAdmin) {
777
+ alert("Acesso restrito ao administrador!");
778
+ return;
779
+ }
780
+
781
+ document.getElementById('adminPanel').classList.add('hidden');
782
+ document.getElementById('resultsPanel').classList.remove('hidden');
783
+
784
+ const resultsContent = document.getElementById('resultsContent');
785
+ resultsContent.innerHTML = '';
786
+
787
+ if (votes.length === 0) {
788
+ resultsContent.innerHTML = '<p class="text-center">Nenhum voto registrado ainda.</p>';
789
+ return;
790
+ }
791
+
792
+ // Calculate results for each position
793
+ positions.forEach(position => {
794
+ const positionVotes = votes.filter(v => v.positionId === position.id);
795
+ const totalVotes = positionVotes.length;
796
+
797
+ if (totalVotes === 0) return;
798
+
799
+ // Group votes by candidate
800
+ const voteCounts = {};
801
+ let blankVotes = 0;
802
+ let nullVotes = 0;
803
+
804
+ positionVotes.forEach(vote => {
805
+ if (vote.candidateNumber === null) {
806
+ blankVotes++;
807
+ } else {
808
+ const candidate = candidates.find(c =>
809
+ c.positionId === position.id && c.number === vote.candidateNumber
810
+ );
811
+
812
+ if (candidate) {
813
+ voteCounts[candidate.number] = (voteCounts[candidate.number] || 0) + 1;
814
+ } else {
815
+ nullVotes++;
816
+ }
817
+ }
818
+ });
819
+
820
+ // Create results card
821
+ const card = document.createElement('div');
822
+ card.className = 'bg-gray-50 p-4 rounded-lg';
823
+
824
+ // Position title
825
+ const title = document.createElement('h3');
826
+ title.className = 'text-lg font-semibold mb-2';
827
+ title.textContent = `${position.number} - ${position.name}`;
828
+ card.appendChild(title);
829
+
830
+ // Total votes
831
+ const totalText = document.createElement('p');
832
+ totalText.className = 'text-sm text-gray-600 mb-3';
833
+ totalText.textContent = `Total de votos: ${totalVotes}`;
834
+ card.appendChild(totalText);
835
+
836
+ // Blank and null votes
837
+ const blankNullDiv = document.createElement('div');
838
+ blankNullDiv.className = 'grid grid-cols-2 gap-4 mb-4';
839
+
840
+ const blankDiv = document.createElement('div');
841
+ blankDiv.className = 'bg-white p-2 rounded';
842
+ blankDiv.innerHTML = `
843
+ <div class="font-medium">Votos em Branco</div>
844
+ <div class="flex items-center mt-1">
845
+ <div class="w-16 font-bold">${blankVotes}</div>
846
+ <div class="flex-1">
847
+ <div class="progress-bar">
848
+ <div class="progress-fill" style="width: ${(blankVotes / totalVotes) * 100}%"></div>
849
+ </div>
850
+ </div>
851
+ <div class="w-16 text-right">${Math.round((blankVotes / totalVotes) * 100)}%</div>
852
+ </div>
853
+ `;
854
+ blankNullDiv.appendChild(blankDiv);
855
+
856
+ const nullDiv = document.createElement('div');
857
+ nullDiv.className = 'bg-white p-2 rounded';
858
+ nullDiv.innerHTML = `
859
+ <div class="font-medium">Votos Nulos</div>
860
+ <div class="flex items-center mt-1">
861
+ <div class="w-16 font-bold">${nullVotes}</div>
862
+ <div class="flex-1">
863
+ <div class="progress-bar">
864
+ <div class="progress-fill" style="width: ${(nullVotes / totalVotes) * 100}%"></div>
865
+ </div>
866
+ </div>
867
+ <div class="w-16 text-right">${Math.round((nullVotes / totalVotes) * 100)}%</div>
868
+ </div>
869
+ `;
870
+ blankNullDiv.appendChild(nullDiv);
871
+
872
+ card.appendChild(blankNullDiv);
873
+
874
+ // Candidates results
875
+ const candidatesResults = document.createElement('div');
876
+ candidatesResults.className = 'space-y-2';
877
+
878
+ // Get candidates sorted by votes
879
+ const positionCandidates = candidates.filter(c => c.positionId === position.id);
880
+ const sortedCandidates = [...positionCandidates].sort((a, b) => {
881
+ return (voteCounts[b.number] || 0) - (voteCounts[a.number] || 0);
882
+ });
883
+
884
+ sortedCandidates.forEach(candidate => {
885
+ const candidateVotes = voteCounts[candidate.number] || 0;
886
+ const percentage = (candidateVotes / totalVotes) * 100;
887
+
888
+ const candidateDiv = document.createElement('div');
889
+ candidateDiv.className = 'bg-white p-3 rounded-lg';
890
+ candidateDiv.innerHTML = `
891
+ <div class="flex items-center">
892
+ <div class="w-12 h-12 rounded-full overflow-hidden mr-3">
893
+ <img src="${candidate.photo}" alt="Foto" class="w-full h-full object-cover">
894
+ </div>
895
+ <div class="flex-1">
896
+ <div class="font-bold">${candidate.name}</div>
897
+ <div class="text-sm text-gray-600">${candidate.number}</div>
898
+ </div>
899
+ <div class="text-right">
900
+ <div class="font-bold">${candidateVotes} votos</div>
901
+ <div class="text-sm">${Math.round(percentage)}%</div>
902
+ </div>
903
+ </div>
904
+ <div class="mt-2">
905
+ <div class="progress-bar">
906
+ <div class="progress-fill" style="width: ${percentage}%"></div>
907
+ </div>
908
+ </div>
909
+ `;
910
+
911
+ // Highlight elected candidate (if majority)
912
+ if (candidateVotes > totalVotes / 2) {
913
+ candidateDiv.classList.add('border-2', 'border-green-500');
914
+ const electedBadge = document.createElement('div');
915
+ electedBadge.className = 'text-xs font-bold text-green-600 mt-1';
916
+ electedBadge.textContent = 'ELEITO(A)';
917
+ candidateDiv.appendChild(electedBadge);
918
+ }
919
+
920
+ candidatesResults.appendChild(candidateDiv);
921
+ });
922
+
923
+ card.appendChild(candidatesResults);
924
+ resultsContent.appendChild(card);
925
+ });
926
+ }
927
+
928
+ // Hide results panel
929
+ function hideResults() {
930
+ document.getElementById('resultsPanel').classList.add('hidden');
931
+ document.getElementById('adminPanel').classList.remove('hidden');
932
+ }
933
+
934
+ // Initialize app
935
+ function init() {
936
+ initializeSampleData();
937
+ loadData();
938
+
939
+ // Check if admin is already logged in (for demo purposes)
940
+ // In a real app, this would be handled with proper session management
941
+ if (window.location.hash === '#admin') {
942
+ showAdminPanel();
943
+ }
944
+ }
945
+
946
+ // Start the app when page loads
947
+ window.onload = init;
948
+ </script>
949
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=MFBarreto/https-enzostvs-deepsite-hf-space" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
950
+ </html>
prompts.txt ADDED
File without changes