Epiphanio12 commited on
Commit
e7be31e
·
verified ·
1 Parent(s): c95ee65

Promote version 9708872 to main

Browse files

Promoted commit 970887206547ad132ab973d2575e3d10ae50c775 to main branch

Files changed (3) hide show
  1. admin.html +42 -51
  2. index.html +150 -254
  3. script.js +77 -126
admin.html CHANGED
@@ -3,30 +3,32 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Admin - TimeSync Commander</title>
7
- <link rel="stylesheet" href="style.css">
8
  <script src="https://cdn.tailwindcss.com"></script>
9
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
  <script src="https://unpkg.com/feather-icons"></script>
11
  </head>
12
  <body class="bg-gray-900 text-white">
13
  <div id="app" class="min-h-screen p-4 max-w-7xl mx-auto">
14
- <!-- Login Container -->
 
 
15
  <div id="login-container" class="max-w-md mx-auto mt-20">
16
  <div class="bg-gray-800 rounded-lg p-8 shadow-lg">
17
  <div class="text-center mb-6">
18
  <i data-feather="shield" class="w-12 h-12 mx-auto mb-4 text-blue-500"></i>
19
- <h1 class="text-2xl font-bold">Admin Login</h1>
20
- </div>
21
  <form id="login-form" class="space-y-4">
22
  <div>
23
- <label for="username" class="block mb-1">Username</label>
24
- <input type="text" id="username" required value="admin"
25
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
26
  </div>
27
  <div>
28
- <label for="password" class="block mb-1">Password</label>
29
- <input type="password" id="password" required value="admin"
30
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
31
  </div>
32
  <button type="submit"
@@ -34,17 +36,17 @@
34
  Login
35
  </button>
36
  </form>
37
- <div id="login-error" class="mt-4 text-red-400 hidden"></div>
38
  </div>
39
  </div>
40
 
41
  <!-- Dashboard Container -->
42
  <div id="dashboard-container" class="hidden">
43
  <header class="flex justify-between items-center mb-8">
44
- <h1 class="text-2xl font-bold">Admin Dashboard</h1>
45
  <button id="logout-button" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded transition">
46
- Logout
47
- </button>
48
  </header>
49
 
50
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
@@ -52,70 +54,70 @@
52
  <div class="dashboard-section bg-gray-800 rounded-lg p-6 lg:col-span-2">
53
  <h2 class="text-xl font-semibold mb-4 flex items-center">
54
  <i data-feather="settings" class="mr-2"></i>
55
- Main Configuration
56
- </h2>
57
 
58
  <form id="config-form" class="space-y-4">
59
  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
60
  <div>
61
- <label for="config-programa" class="block mb-1">Program Name</label>
62
- <input type="text" id="config-programa"
63
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
64
  </div>
65
  <div>
66
- <label for="config-tema" class="block mb-1">Current Theme</label>
67
- <input type="text" id="config-tema"
68
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
69
  </div>
70
  </div>
71
 
72
  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
73
  <div>
74
- <label for="config-momento" class="block mb-1">Status Text</label>
75
- <input type="text" id="config-momento"
76
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
77
  </div>
78
  <div>
79
- <label for="config-falta" class="block mb-1">Time (HH:MM:SS)</label>
80
- <input type="text" id="config-falta"
81
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
82
  </div>
83
  </div>
84
 
85
  <div>
86
- <label for="config-aviso" class="block mb-1">Warning Message</label>
87
- <textarea id="config-aviso" rows="2"
88
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2"></textarea>
89
  <button type="button" id="btn-clear-aviso"
90
  class="mt-2 bg-yellow-600 hover:bg-yellow-700 text-white px-3 py-1 rounded text-sm transition">
91
- Clear Warning
92
- </button>
93
  </div>
94
 
95
  <div class="flex items-center">
96
  <label class="inline-flex items-center">
97
  <input type="checkbox" id="ignore-external-files" class="rounded text-blue-500">
98
- <span class="ml-2">Ignore External Files (Admin Mode)</span>
99
- </label>
100
  </div>
101
 
102
  <div class="flex flex-wrap gap-2 mt-4">
103
  <button type="button" id="btn-set-ativo"
104
  class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded transition">
105
- START
106
- </button>
107
  <button type="button" id="btn-set-pausado"
108
  class="bg-yellow-600 hover:bg-yellow-700 text-white px-4 py-2 rounded transition">
109
- PAUSE
110
- </button>
111
  <button type="button" id="btn-set-inativo"
112
  class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded transition">
113
- STOP (END)
114
- </button>
115
  <button type="submit"
116
  class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded transition">
117
- Save Configuration
118
- </button>
119
  </div>
120
  </form>
121
  </div>
@@ -124,8 +126,8 @@
124
  <div class="dashboard-section bg-gray-800 rounded-lg p-6">
125
  <h2 class="text-xl font-semibold mb-4 flex items-center">
126
  <i data-feather="clock" class="mr-2"></i>
127
- Quick Time Controls
128
- </h2>
129
 
130
  <div class="grid grid-cols-2 gap-3">
131
  <button class="time-preset" data-time="00:00:00"
@@ -146,17 +148,6 @@
146
  </button>
147
  <button class="time-preset" data-time="02:00:00"
148
  class="bg-gray-700 hover:bg-gray-600 px-3 py-2 rounded transition">
149
- </button>
150
- </div>
151
- </div>
152
- </div>
153
- </div>
154
- </div>
155
-
156
- <script src="/socket.io/socket.io.js"></script>
157
- <script src="script.js"></script>
158
- <script>
159
- feather.replace();
160
- </script>
161
  </body>
162
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Admin - TimeSync Commander - Controle de Tempo</title>
7
+ <link rel="stylesheet" href="style.css">
8
  <script src="https://cdn.tailwindcss.com"></script>
9
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
  <script src="https://unpkg.com/feather-icons"></script>
11
  </head>
12
  <body class="bg-gray-900 text-white">
13
  <div id="app" class="min-h-screen p-4 max-w-7xl mx-auto">
14
+ <!--
15
+ Entrar
16
+ Container -->
17
  <div id="login-container" class="max-w-md mx-auto mt-20">
18
  <div class="bg-gray-800 rounded-lg p-8 shadow-lg">
19
  <div class="text-center mb-6">
20
  <i data-feather="shield" class="w-12 h-12 mx-auto mb-4 text-blue-500"></i>
21
+ <h1 class="text-2xl font-bold">Acesso Administrativo</h1>
22
+ </div>
23
  <form id="login-form" class="space-y-4">
24
  <div>
25
+ <label for="email" class="block mb-1">E-mail</label>
26
+ <input type="email" id="email" required
27
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
28
  </div>
29
  <div>
30
+ <label for="password" class="block mb-1">Senha</label>
31
+ <input type="password" id="password" required
32
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
33
  </div>
34
  <button type="submit"
 
36
  Login
37
  </button>
38
  </form>
39
+ <div id="login-error" class="mt-4 text-red-400 hidden"></div>
40
  </div>
41
  </div>
42
 
43
  <!-- Dashboard Container -->
44
  <div id="dashboard-container" class="hidden">
45
  <header class="flex justify-between items-center mb-8">
46
+ <h1 class="text-2xl font-bold">Painel Administrativo</h1>
47
  <button id="logout-button" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded transition">
48
+ Sair
49
+ </button>
50
  </header>
51
 
52
  <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
 
54
  <div class="dashboard-section bg-gray-800 rounded-lg p-6 lg:col-span-2">
55
  <h2 class="text-xl font-semibold mb-4 flex items-center">
56
  <i data-feather="settings" class="mr-2"></i>
57
+ Configuração Principal
58
+ </h2>
59
 
60
  <form id="config-form" class="space-y-4">
61
  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
62
  <div>
63
+ <label for="config-programa" class="block mb-1">Nome do Programa</label>
64
+ <input type="text" id="config-programa"
65
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
66
  </div>
67
  <div>
68
+ <label for="config-tema" class="block mb-1">Tema Atual</label>
69
+ <input type="text" id="config-tema"
70
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
71
  </div>
72
  </div>
73
 
74
  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
75
  <div>
76
+ <label for="config-momento" class="block mb-1">Texto de Status</label>
77
+ <input type="text" id="config-momento"
78
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
79
  </div>
80
  <div>
81
+ <label for="config-falta" class="block mb-1">Tempo (HH:MM:SS)</label>
82
+ <input type="text" id="config-falta"
83
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2">
84
  </div>
85
  </div>
86
 
87
  <div>
88
+ <label for="config-aviso" class="block mb-1">Mensagem de Aviso</label>
89
+ <textarea id="config-aviso" rows="2"
90
  class="w-full bg-gray-700 border border-gray-600 rounded px-4 py-2"></textarea>
91
  <button type="button" id="btn-clear-aviso"
92
  class="mt-2 bg-yellow-600 hover:bg-yellow-700 text-white px-3 py-1 rounded text-sm transition">
93
+ Limpar Aviso
94
+ </button>
95
  </div>
96
 
97
  <div class="flex items-center">
98
  <label class="inline-flex items-center">
99
  <input type="checkbox" id="ignore-external-files" class="rounded text-blue-500">
100
+ <span class="ml-2">Ignorar Arquivos Externos (Modo Admin)</span>
101
+ </label>
102
  </div>
103
 
104
  <div class="flex flex-wrap gap-2 mt-4">
105
  <button type="button" id="btn-set-ativo"
106
  class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded transition">
107
+ INICIAR
108
+ </button>
109
  <button type="button" id="btn-set-pausado"
110
  class="bg-yellow-600 hover:bg-yellow-700 text-white px-4 py-2 rounded transition">
111
+ PAUSAR
112
+ </button>
113
  <button type="button" id="btn-set-inativo"
114
  class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded transition">
115
+ PARAR (FINALIZAR)
116
+ </button>
117
  <button type="submit"
118
  class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded transition">
119
+ Salvar Configuração
120
+ </button>
121
  </div>
122
  </form>
123
  </div>
 
126
  <div class="dashboard-section bg-gray-800 rounded-lg p-6">
127
  <h2 class="text-xl font-semibold mb-4 flex items-center">
128
  <i data-feather="clock" class="mr-2"></i>
129
+ Controles Rápidos de Tempo
130
+ </h2>
131
 
132
  <div class="grid grid-cols-2 gap-3">
133
  <button class="time-preset" data-time="00:00:00"
 
148
  </button>
149
  <button class="time-preset" data-time="02:00:00"
150
  class="bg-gray-700 hover:bg-gray-600 px-3 py-2 rounded transition">
151
+ Set 02:00:00{"ok":false,"message":"Request timeout: The AI model took too long to respond. Please try again with a simpler prompt or try a different model."}
 
 
 
 
 
 
 
 
 
 
 
152
  </body>
153
  </html>
index.html CHANGED
@@ -1,269 +1,165 @@
1
- // Generate or retrieve user ID
2
- function getOrCreateUserId() {
3
- let userId = localStorage.getItem('timeSyncUserId');
4
- if (!userId) {
5
- userId = 'user_' + Math.random().toString(36).substr(2, 9);
6
- localStorage.setItem('timeSyncUserId', userId);
7
- }
8
- return userId;
9
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- // Connect to Socket.IO server
12
- const socket = io();
13
- const userId = getOrCreateUserId();
 
14
 
15
- // Update current time
16
- function updateCurrentTime() {
17
- const now = new Date();
18
- const timeString = now.toLocaleTimeString();
19
- const dateString = now.toLocaleDateString();
20
-
21
- document.querySelectorAll('#current-time, #current-time-mobile').forEach(el => {
22
- el.textContent = timeString;
23
- });
24
-
25
- document.querySelectorAll('#current-date, #current-date-mobile').forEach(el => {
26
- el.textContent = dateString;
27
- });
28
- }
29
 
30
- // Heartbeat function
31
- function sendHeartbeat() {
32
- socket.emit('userHeartbeat', { userId });
33
- }
34
- setInterval(sendHeartbeat, 10000);
35
 
36
- // Update timer UI
37
- function updateTemporizadorUI(data) {
38
- // Update all relevant elements
39
- document.querySelectorAll('#PROGRAMA-TITULO, #PROGRAMA-TITULO-mobile').forEach(el => {
40
- el.textContent = data.PROGRAMA || 'Event Title';
41
- });
42
-
43
- document.querySelectorAll('#TEMA, #TEMA-mobile').forEach(el => {
44
- el.textContent = data.TEMA || 'Current Theme';
45
- });
46
-
47
- document.querySelectorAll('#MOMENTO, #MOMENTO-mobile').forEach(el => {
48
- el.textContent = data.MOMENTO || 'RESTA';
49
- });
50
-
51
- document.querySelectorAll('#FALTA, #FALTA-mobile').forEach(el => {
52
- el.textContent = data.FALTA || '00:00:00';
53
- });
54
-
55
- // Handle status colors
56
- const momentoFaltaElements = document.querySelectorAll('#MOMENTO-FALTA, #MOMENTO-FALTA-mobile');
57
- momentoFaltaElements.forEach(el => {
58
- el.classList.remove('alerta-vermelho', 'alerta-amarelo', 'alerta-verde');
59
-
60
- if (data.MOMENTO === 'ATRASADO EM' || (parseInt(data.FALTA.split(':').join('')) < 0)) {
61
- el.classList.add('alerta-vermelho');
62
- } else if (data.MOMENTO === 'RESTA' && (parseInt(data.FALTA.split(':')[2]) < 900)) {
63
- el.classList.add('alerta-amarelo');
64
- } else {
65
- el.classList.add('alerta-verde');
66
- }
67
- });
68
-
69
- // Handle activation state
70
- if (data.ATIVACAO === 'INATIVO' || data.ATIVACAO === 'PAUSADO') {
71
- showTemporizadorInativoState(data.ATIVACAO === 'PAUSADO' ? 'Timer Paused' : 'Timer Inactive');
72
- } else {
73
- showTemporizadorAtivoState();
74
- }
75
- }
76
 
77
- // Show inactive state
78
- function showTemporizadorInativoState(message = 'Timer Inactive') {
79
- document.getElementById('msg-inativo-card-wrapper').style.display = 'flex';
80
- document.getElementById('inactive-message').textContent = message;
81
-
82
- // Hide elements in desktop view
83
- const desktopElements = [
84
- '#card-status-tema-container',
85
- '#cronograma-header',
86
- '#cronograma-table'
87
- ].forEach(selector => {
88
- const el = document.querySelector(selector);
89
- if (el) el.style.display = 'none';
90
- });
91
-
92
- // Hide elements in mobile view
93
- const mobileElements = [
94
- '#card-status-tema-container-mobile',
95
- '#cronograma-header-mobile',
96
- '#cronograma-table-mobile'
97
- ].forEach(selector => {
98
- const el = document.querySelector(selector);
99
- if (el) el.style.display = 'none';
100
- });
101
- }
102
 
103
- // Show active state
104
- function showTemporizadorAtivoState() {
105
- document.getElementById('msg-inativo-card-wrapper').style.display = 'none';
106
-
107
- // Show elements in desktop view
108
- const desktopElements = [
109
- '#card-status-tema-container',
110
- '#cronograma-header',
111
- '#cronograma-table'
112
- ].forEach(selector => {
113
- const el = document.querySelector(selector);
114
- if (el) el.style.display = 'block';
115
- });
116
-
117
- // Show elements in mobile view
118
- const mobileElements = [
119
- '#card-status-tema-container-mobile',
120
- '#cronograma-header-mobile',
121
- '#cronograma-table-mobile'
122
- ].forEach(selector => {
123
- const el = document.querySelector(selector);
124
- if (el) el.style.display = 'block';
125
- });
126
- }
127
 
128
- // Handle warning message
129
- function handleAviso(message) {
130
- if (!message) return;
131
-
132
- const containers = [
133
- '#card-aviso-container',
134
- '#card-aviso-container-mobile'
135
- ];
136
-
137
- containers.forEach(selector => {
138
- const container = document.querySelector(selector);
139
- if (container) {
140
- const avisoEl = container.querySelector('span');
141
- avisoEl.textContent = message;
142
-
143
- container.classList.remove('hidden');
144
- container.classList.add('show');
145
-
146
- setTimeout(() => {
147
- container.classList.remove('show');
148
- container.classList.add('hidden');
149
- }, 10000);
150
- }
151
- });
152
- }
153
 
154
- // Update schedule table
155
- function updateTabelaCronogramaUI(data) {
156
- const tableBodies = [
157
- '#tabela-cronograma-body',
158
- '#tabela-cronograma-body-mobile'
159
- ];
160
-
161
- tableBodies.forEach(selector => {
162
- const tbody = document.querySelector(selector);
163
- if (!tbody) return;
164
-
165
- tbody.innerHTML = '';
166
-
167
- if (data && data.ITENS && data.ITENS.length > 0) {
168
- data.ITENS.forEach(item => {
169
- const row = document.createElement('tr');
170
- row.dataset.momento = item.MOMENTO;
171
-
172
- row.innerHTML = `
173
- <td class="p-2">${item.INICIO || '--:--'}</td>
174
- <td class="p-2">${item.DURACAO || '--:--'}</td>
175
- <td class="p-2">${item.MOMENTO || 'Untitled'}</td>
176
- `;
177
-
178
- tbody.appendChild(row);
179
- });
180
-
181
- marcarLinhaAtivaNaTabela();
182
- } else {
183
- const row = document.createElement('tr');
184
- row.innerHTML = '<td colspan="3" class="p-2 text-center text-gray-400">No schedule available</td>';
185
- tbody.appendChild(row);
186
- }
187
- });
188
- }
189
 
190
- // Mark active row in schedule table
191
- function marcarLinhaAtivaNaTabela() {
192
- const currentTema = document.getElementById('TEMA')?.textContent;
193
- if (!currentTema) return;
194
-
195
- const rows = document.querySelectorAll('#tabela-cronograma-body tr, #tabela-cronograma-body-mobile tr');
196
- rows.forEach(row => {
197
- row.classList.remove('item-ativo');
198
- if (row.dataset.momento === currentTema) {
199
- row.classList.add('item-ativo');
200
- }
201
- });
202
- }
203
 
204
- // Fullscreen toggle
205
- document.getElementById('fullscreen-button').addEventListener('click', () => {
206
- if (!document.fullscreenElement) {
207
- document.documentElement.requestFullscreen().catch(err => {
208
- console.error('Error attempting to enable fullscreen:', err);
209
- });
210
- } else {
211
- if (document.exitFullscreen) {
212
- document.exitFullscreen();
213
- }
214
- }
215
- });
216
 
217
- // PWA installation prompt
218
- let deferredPrompt;
219
- window.addEventListener('beforeinstallprompt', (e) => {
220
- e.preventDefault();
221
- deferredPrompt = e;
222
- document.getElementById('install-app-btn').classList.remove('hidden');
223
- });
 
 
 
 
 
 
 
 
 
224
 
225
- document.getElementById('install-app-btn').addEventListener('click', async () => {
226
- if (deferredPrompt) {
227
- deferredPrompt.prompt();
228
- const { outcome } = await deferredPrompt.userChoice;
229
- if (outcome === 'accepted') {
230
- document.getElementById('install-app-btn').classList.add('hidden');
231
- }
232
- deferredPrompt = null;
233
- }
234
- });
235
 
236
- // Socket.IO event listeners
237
- socket.on('dadosAtualizados', updateTemporizadorUI);
238
- socket.on('cronogramaAtualizado', updateTabelaCronogramaUI);
239
- socket.on('onlineUsersCountUpdated', (count) => {
240
- document.querySelectorAll('#online-users-count, #online-users-count-mobile').forEach(el => {
241
- el.textContent = count;
242
- });
243
- });
244
- socket.on('encerrarTemporizador', () => {
245
- showTemporizadorInativoState('Timer Ended');
246
- });
247
 
248
- // Initialize
249
- updateCurrentTime();
250
- setInterval(updateCurrentTime, 1000);
251
- sendHeartbeat();
252
 
253
- // Error logging
254
- window.onerror = function(message, source, lineno, colno, error) {
255
- fetch('/api/log-error', {
256
- method: 'POST',
257
- headers: {
258
- 'Content-Type': 'application/json',
259
- },
260
- body: JSON.stringify({
261
- message,
262
- source,
263
- lineno,
264
- colno,
265
- error: error ? error.stack : null,
266
- userId
267
- })
268
- }).catch(err => console.error('Error logging failed:', err));
269
- };
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>TimeSync Commander - Controle de Tempo</title>
7
+ <link rel="manifest" href="/manifest.json">
8
+ <link rel="stylesheet" href="style.css">
9
+ <script src="https://cdn.tailwindcss.com"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/socket.io-client@4.7.2/dist/socket.io.min.js"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
12
+ <script src="https://unpkg.com/feather-icons"></script>
13
+ </head>
14
+ <body class="bg-gray-900 text-white">
15
+ <div id="app" class="min-h-screen">
16
+ <!-- Desktop Layout (Grid) -->
17
+ <div class="hidden md:grid md:grid-cols-4 md:grid-rows-4 md:gap-4 p-4">
18
+ <!-- Online Users Count -->
19
+ <div id="card-online-users-count" class="bg-gray-800 rounded-lg p-4 flex items-center justify-center">
20
+ <i data-feather="users" class="mr-2"></i>
21
+ <span id="online-users-count">0</span> online
22
+ </div>
23
 
24
+ <!-- Main Header -->
25
+ <div id="cabecalho-principal" class="bg-gray-800 rounded-lg p-4 col-span-2 flex items-center justify-center">
26
+ <h1 id="PROGRAMA-TITULO" class="text-2xl font-bold">Título do Evento</h1>
27
+ </div>
28
 
29
+ <!-- Clock -->
30
+ <div id="card-relogio" class="bg-gray-800 rounded-lg p-4 flex items-center justify-center">
31
+ <i data-feather="clock" class="mr-2"></i>
32
+ <span id="current-time">00:00:00</span>
33
+ </div>
 
 
 
 
 
 
 
 
 
34
 
35
+ <!-- Date -->
36
+ <div id="card-data" class="bg-gray-800 rounded-lg p-4 flex items-center justify-center">
37
+ <i data-feather="calendar" class="mr-2"></i>
38
+ <span id="current-date">01/01/2023</span>
39
+ </div>
40
 
41
+ <!-- Status -->
42
+ <div id="card-status-tema-container" class="bg-gray-800 rounded-lg p-4 col-span-4">
43
+ <div id="card-status-tema" class="text-center">
44
+ <h2 id="TEMA" class="text-xl font-semibold">Tema Atual</h2>
45
+ <div id="MOMENTO-FALTA" class="text-4xl my-2">
46
+ <span id="MOMENTO">RESTA</span> <span id="FALTA">00:00:00</span>
47
+ </div>
48
+ <div id="card-aviso-container" class="hidden bg-yellow-500 text-gray-900 rounded p-2 mt-2">
49
+ <span id="AVISO">Warning message</span>
50
+ </div>
51
+ </div>
52
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ <!-- Schedule Header -->
55
+ <div id="cronograma-header" class="bg-gray-800 rounded-lg p-4 col-span-4">
56
+ <h2 class="text-xl font-semibold">Cronograma</h2>
57
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ <!-- Schedule Table -->
60
+ <div id="cronograma-table" class="bg-gray-800 rounded-lg p-4 col-span-4 overflow-x-auto">
61
+ <table class="w-full">
62
+ <thead>
63
+ <tr class="border-b border-gray-700">
64
+ <th class="p-2 text-left">Início</th>
65
+ <th class="p-2 text-left">Duração</th>
66
+ <th class="p-2 text-left">Item</th>
67
+ </tr>
68
+ </thead>
69
+ <tbody id="tabela-cronograma-body">
70
+ <!-- Schedule items will be inserted here -->
71
+ </tbody>
72
+ </table>
73
+ </div>
74
+ </div>
 
 
 
 
 
 
 
 
75
 
76
+ <!-- Mobile Layout (Flex) -->
77
+ <div class="md:hidden flex flex-col gap-4 p-4">
78
+ <!-- Top Section -->
79
+ <div class="flex justify-between items-center">
80
+ <div id="card-online-users-count" class="bg-gray-800 rounded-lg p-3 flex items-center">
81
+ <i data-feather="users" class="mr-2"></i>
82
+ <span id="online-users-count-mobile">0</span>
83
+ </div>
84
+ <div id="cabecalho-principal" class="bg-gray-800 rounded-lg p-3 flex-1 ml-2">
85
+ <h1 id="PROGRAMA-TITULO-mobile" class="text-xl font-bold text-center">Event Title</h1>
86
+ </div>
87
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
+ <!-- Status -->
90
+ <div id="card-status-tema-container-mobile" class="bg-gray-800 rounded-lg p-4">
91
+ <div id="card-status-tema-mobile" class="text-center">
92
+ <h2 id="TEMA-mobile" class="text-lg font-semibold">Current Theme</h2>
93
+ <div id="MOMENTO-FALTA-mobile" class="text-3xl my-2">
94
+ <span id="MOMENTO-mobile">RESTA</span> <span id="FALTA-mobile">00:00:00</span>
95
+ </div>
96
+ <div id="card-aviso-container-mobile" class="hidden bg-yellow-500 text-gray-900 rounded p-2 mt-2">
97
+ <span id="AVISO-mobile">Warning message</span>
98
+ </div>
99
+ </div>
100
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ <!-- Clock and Date -->
103
+ <div class="flex justify-between">
104
+ <div id="card-relogio-mobile" class="bg-gray-800 rounded-lg p-3 flex items-center">
105
+ <i data-feather="clock" class="mr-2"></i>
106
+ <span id="current-time-mobile">00:00:00</span>
107
+ </div>
108
+ <div id="card-data-mobile" class="bg-gray-800 rounded-lg p-3 flex items-center">
109
+ <i data-feather="calendar" class="mr-2"></i>
110
+ <span id="current-date-mobile">01/01/2023</span>
111
+ </div>
112
+ </div>
 
 
113
 
114
+ <!-- Schedule Header -->
115
+ <div id="cronograma-header-mobile" class="bg-gray-800 rounded-lg p-3">
116
+ <h2 class="text-lg font-semibold">Schedule</h2>
117
+ </div>
 
 
 
 
 
 
 
 
118
 
119
+ <!-- Schedule Table -->
120
+ <div id="cronograma-table-mobile" class="bg-gray-800 rounded-lg p-3 overflow-x-auto">
121
+ <table class="w-full">
122
+ <thead>
123
+ <tr class="border-b border-gray-700">
124
+ <th class="p-2 text-left">Start</th>
125
+ <th class="p-2 text-left">Duration</th>
126
+ <th class="p-2 text-left">Item</th>
127
+ </tr>
128
+ </thead>
129
+ <tbody id="tabela-cronograma-body-mobile">
130
+ <!-- Schedule items will be inserted here -->
131
+ </tbody>
132
+ </table>
133
+ </div>
134
+ </div>
135
 
136
+ <!-- Inactive State (Hidden by default) -->
137
+ <div id="msg-inativo-card-wrapper" class="hidden fixed inset-0 bg-gray-900 bg-opacity-90 flex items-center justify-center">
138
+ <div class="bg-gray-800 rounded-lg p-8 max-w-md text-center">
139
+ <i data-feather="clock" class="w-16 h-16 mx-auto mb-4"></i>
140
+ <h2 class="text-2xl font-bold mb-4">Temporizador Inativo</h2>
141
+ <p id="inactive-message" class="text-gray-300">O temporizador está inativo no momento. Por favor, verifique mais tarde.</p>
142
+ </div>
143
+ </div>
 
 
144
 
145
+ <!-- Floating Buttons -->
146
+ <button id="fullscreen-button" class="fixed bottom-4 left-4 bg-gray-800 p-3 rounded-full shadow-lg hover:bg-gray-700 transition">
147
+ <i data-feather="maximize"></i>
148
+ </button>
149
+
150
+ <a href="/admin.html" id="admin-access-link" class="fixed bottom-4 right-4 bg-gray-800 p-3 rounded-full shadow-lg hover:bg-gray-700 transition">
151
+ <i data-feather="shield"></i>
152
+ </a>
 
 
 
153
 
154
+ <button id="install-app-btn" class="hidden fixed bottom-20 right-4 bg-blue-600 p-3 rounded-full shadow-lg hover:bg-blue-700 transition">
155
+ <i data-feather="download"></i>
156
+ </button>
157
+ </div>
158
 
159
+ <script src="script.js"></script>
160
+ <script>
161
+ feather.replace();
162
+ </script>
163
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
164
+ </body>
165
+ </html>
 
 
 
 
 
 
 
 
 
 
script.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
  // Generate or retrieve user ID
3
  function getOrCreateUserId() {
4
  let userId = localStorage.getItem('timeSyncUserId');
@@ -10,13 +9,7 @@ function getOrCreateUserId() {
10
  }
11
 
12
  // Connect to Socket.IO server
13
- let socket;
14
- try {
15
- socket = io();
16
- } catch (error) {
17
- console.error('Socket.IO connection failed:', error);
18
- }
19
-
20
  const userId = getOrCreateUserId();
21
 
22
  // Update current time
@@ -26,19 +19,17 @@ function updateCurrentTime() {
26
  const dateString = now.toLocaleDateString();
27
 
28
  document.querySelectorAll('#current-time, #current-time-mobile').forEach(el => {
29
- if (el) el.textContent = timeString;
30
  });
31
 
32
  document.querySelectorAll('#current-date, #current-date-mobile').forEach(el => {
33
- if (el) el.textContent = dateString;
34
  });
35
  }
36
 
37
  // Heartbeat function
38
  function sendHeartbeat() {
39
- if (socket) {
40
- socket.emit('userHeartbeat', { userId });
41
- }
42
  }
43
  setInterval(sendHeartbeat, 10000);
44
 
@@ -46,67 +37,60 @@ setInterval(sendHeartbeat, 10000);
46
  function updateTemporizadorUI(data) {
47
  // Update all relevant elements
48
  document.querySelectorAll('#PROGRAMA-TITULO, #PROGRAMA-TITULO-mobile').forEach(el => {
49
- if (el) el.textContent = data.PROGRAMA || 'Event Title';
50
- });
51
 
52
  document.querySelectorAll('#TEMA, #TEMA-mobile').forEach(el => {
53
- if (el) el.textContent = data.TEMA || 'Current Theme';
54
- });
55
 
56
  document.querySelectorAll('#MOMENTO, #MOMENTO-mobile').forEach(el => {
57
- if (el) el.textContent = data.MOMENTO || 'RESTA';
58
- });
59
 
60
  document.querySelectorAll('#FALTA, #FALTA-mobile').forEach(el => {
61
- if (el) el.textContent = data.FALTA || '00:00:00';
62
  });
63
 
64
  // Handle status colors
65
  const momentoFaltaElements = document.querySelectorAll('#MOMENTO-FALTA, #MOMENTO-FALTA-mobile');
66
  momentoFaltaElements.forEach(el => {
67
- if (el) {
68
- el.classList.remove('alerta-vermelho', 'alerta-amarelo', 'alerta-verde');
69
-
70
- if (data.MOMENTO === 'ATRASADO EM' || (parseInt(data.FALTA?.split(':').join('') || 0) < 0) {
71
- el.classList.add('alerta-vermelho');
72
- } else if (data.MOMENTO === 'RESTA' && (parseInt(data.FALTA?.split(':')[2] || 0) < 900) {
73
- el.classList.add('alerta-amarelo');
74
- } else {
75
- el.classList.add('alerta-verde');
76
- }
77
  }
78
  });
79
 
80
  // Handle activation state
81
  if (data.ATIVACAO === 'INATIVO' || data.ATIVACAO === 'PAUSADO') {
82
- showTemporizadorInativoState(data.ATIVACAO === 'PAUSADO' ? 'Timer Paused' : 'Timer Inactive');
83
- } else {
84
  showTemporizadorAtivoState();
85
  }
86
  }
87
 
88
  // Show inactive state
89
  function showTemporizadorInativoState(message = 'Timer Inactive') {
90
- const wrapper = document.getElementById('msg-inativo-card-wrapper');
91
- const messageEl = document.getElementById('inactive-message');
92
-
93
- if (wrapper) wrapper.style.display = 'flex';
94
- if (messageEl) messageEl.textContent = message;
95
 
96
  // Hide elements in desktop view
97
- const desktopSelectors = [
98
  '#card-status-tema-container',
99
  '#cronograma-header',
100
  '#cronograma-table'
101
- ];
102
-
103
- desktopSelectors.forEach(selector => {
104
  const el = document.querySelector(selector);
105
  if (el) el.style.display = 'none';
106
  });
107
 
108
  // Hide elements in mobile view
109
- const mobileSelectors = [
110
  '#card-status-tema-container-mobile',
111
  '#cronograma-header-mobile',
112
  '#cronograma-table-mobile'
@@ -118,23 +102,20 @@ function showTemporizadorInativoState(message = 'Timer Inactive') {
118
 
119
  // Show active state
120
  function showTemporizadorAtivoState() {
121
- const wrapper = document.getElementById('msg-inativo-card-wrapper');
122
- if (wrapper) wrapper.style.display = 'none';
123
 
124
  // Show elements in desktop view
125
- const desktopSelectors = [
126
  '#card-status-tema-container',
127
  '#cronograma-header',
128
  '#cronograma-table'
129
- ];
130
-
131
- desktopSelectors.forEach(selector => {
132
  const el = document.querySelector(selector);
133
  if (el) el.style.display = 'block';
134
  });
135
 
136
  // Show elements in mobile view
137
- const mobileSelectors = [
138
  '#card-status-tema-container-mobile',
139
  '#cronograma-header-mobile',
140
  '#cronograma-table-mobile'
@@ -157,7 +138,7 @@ function handleAviso(message) {
157
  const container = document.querySelector(selector);
158
  if (container) {
159
  const avisoEl = container.querySelector('span');
160
- if (avisoEl) avisoEl.textContent = message;
161
 
162
  container.classList.remove('hidden');
163
  container.classList.add('show');
@@ -200,8 +181,8 @@ function updateTabelaCronogramaUI(data) {
200
  marcarLinhaAtivaNaTabela();
201
  } else {
202
  const row = document.createElement('tr');
203
- row.innerHTML = '<td colspan="3" class="p-2 text-center text-gray-400">No schedule available</td>';
204
- tbody.appendChild(row);
205
  }
206
  });
207
  }
@@ -221,91 +202,48 @@ function marcarLinhaAtivaNaTabela() {
221
  }
222
 
223
  // Fullscreen toggle
224
- const fullscreenButton = document.getElementById('fullscreen-button');
225
- if (fullscreenButton) {
226
- fullscreenButton.addEventListener('click', () => {
227
- if (!document.fullscreenElement) {
228
- document.documentElement.requestFullscreen().catch(err => {
229
- console.error('Error attempting to enable fullscreen:', err);
230
- });
231
- } else {
232
- if (document.exitFullscreen) {
233
- document.exitFullscreen();
234
- }
235
  }
236
- });
237
- }
238
 
239
  // PWA installation prompt
240
  let deferredPrompt;
241
  window.addEventListener('beforeinstallprompt', (e) => {
242
  e.preventDefault();
243
  deferredPrompt = e;
244
- const installBtn = document.getElementById('install-app-btn');
245
- if (installBtn) installBtn.classList.remove('hidden');
246
  });
247
 
248
- const installBtn = document.getElementById('install-app-btn');
249
- if (installBtn) {
250
- installBtn.addEventListener('click', async () => {
251
- if (deferredPrompt) {
252
- deferredPrompt.prompt();
253
- const { outcome } = await deferredPrompt.userChoice;
254
- if (outcome === 'accepted') {
255
- installBtn.classList.add('hidden');
256
- }
257
- deferredPrompt = null;
258
  }
259
- });
260
- }
 
261
 
262
  // Socket.IO event listeners
263
- if (socket) {
264
- socket.on('dadosAtualizados', updateTemporizadorUI);
265
- socket.on('cronogramaAtualizado', updateTabelaCronogramaUI);
266
- socket.on('onlineUsersCountUpdated', (count) => {
267
- document.querySelectorAll('#online-users-count, #online-users-count-mobile').forEach(el => {
268
- if (el) el.textContent = count;
269
- });
270
- socket.on('encerrarTemporizador', () => {
271
- showTemporizadorInativoState('Timer Ended');
272
- });
273
- }
274
-
275
- // Admin authentication
276
- function validateAdminLogin(username, password) {
277
- return username === 'admin' && password === 'admin';
278
- }
279
-
280
- // Admin login form handler
281
- if (document.getElementById('login-form')) {
282
- document.getElementById('login-form').addEventListener('submit', function(e) {
283
- e.preventDefault();
284
-
285
- const username = document.getElementById('username').value;
286
- const password = document.getElementById('password').value;
287
- const errorDiv = document.getElementById('login-error');
288
-
289
- if (validateAdminLogin(username, password)) {
290
- document.getElementById('login-container').classList.add('hidden');
291
- document.getElementById('dashboard-container').classList.remove('hidden');
292
- if (errorDiv) errorDiv.classList.add('hidden');
293
- } else {
294
- if (errorDiv) {
295
- errorDiv.textContent = 'Invalid username or password';
296
- errorDiv.classList.remove('hidden');
297
- }
298
- }
299
  });
300
- }
301
-
302
- // Admin logout handler
303
- if (document.getElementById('logout-button')) {
304
- document.getElementById('logout-button').addEventListener('click', function() {
305
- document.getElementById('dashboard-container').classList.add('hidden');
306
- document.getElementById('login-container').classList.remove('hidden');
307
- });
308
- }
309
 
310
  // Initialize
311
  updateCurrentTime();
@@ -314,5 +252,18 @@ sendHeartbeat();
314
 
315
  // Error logging
316
  window.onerror = function(message, source, lineno, colno, error) {
317
- console.error('Global error:', { message, source, lineno, colno, error });
318
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  // Generate or retrieve user ID
2
  function getOrCreateUserId() {
3
  let userId = localStorage.getItem('timeSyncUserId');
 
9
  }
10
 
11
  // Connect to Socket.IO server
12
+ const socket = io();
 
 
 
 
 
 
13
  const userId = getOrCreateUserId();
14
 
15
  // Update current time
 
19
  const dateString = now.toLocaleDateString();
20
 
21
  document.querySelectorAll('#current-time, #current-time-mobile').forEach(el => {
22
+ el.textContent = timeString;
23
  });
24
 
25
  document.querySelectorAll('#current-date, #current-date-mobile').forEach(el => {
26
+ el.textContent = dateString;
27
  });
28
  }
29
 
30
  // Heartbeat function
31
  function sendHeartbeat() {
32
+ socket.emit('userHeartbeat', { userId });
 
 
33
  }
34
  setInterval(sendHeartbeat, 10000);
35
 
 
37
  function updateTemporizadorUI(data) {
38
  // Update all relevant elements
39
  document.querySelectorAll('#PROGRAMA-TITULO, #PROGRAMA-TITULO-mobile').forEach(el => {
40
+ el.textContent = data.PROGRAMA || 'Título do Evento';
41
+ });
42
 
43
  document.querySelectorAll('#TEMA, #TEMA-mobile').forEach(el => {
44
+ el.textContent = data.TEMA || 'Tema Atual';
45
+ });
46
 
47
  document.querySelectorAll('#MOMENTO, #MOMENTO-mobile').forEach(el => {
48
+ el.textContent = data.MOMENTO || 'TEMPO RESTANTE';
49
+ });
50
 
51
  document.querySelectorAll('#FALTA, #FALTA-mobile').forEach(el => {
52
+ el.textContent = data.FALTA || '00:00:00';
53
  });
54
 
55
  // Handle status colors
56
  const momentoFaltaElements = document.querySelectorAll('#MOMENTO-FALTA, #MOMENTO-FALTA-mobile');
57
  momentoFaltaElements.forEach(el => {
58
+ el.classList.remove('alerta-vermelho', 'alerta-amarelo', 'alerta-verde');
59
+
60
+ if (data.MOMENTO === 'ATRASADO EM' || (parseInt(data.FALTA.split(':').join('')) < 0)) {
61
+ el.classList.add('alerta-vermelho');
62
+ } else if (data.MOMENTO === 'RESTA' && (parseInt(data.FALTA.split(':')[2]) < 900)) {
63
+ el.classList.add('alerta-amarelo');
64
+ } else {
65
+ el.classList.add('alerta-verde');
 
 
66
  }
67
  });
68
 
69
  // Handle activation state
70
  if (data.ATIVACAO === 'INATIVO' || data.ATIVACAO === 'PAUSADO') {
71
+ showTemporizadorInativoState(data.ATIVACAO === 'PAUSADO' ? 'Temporizador Pausado' : 'Temporizador Inativo');
72
+ } else {
73
  showTemporizadorAtivoState();
74
  }
75
  }
76
 
77
  // Show inactive state
78
  function showTemporizadorInativoState(message = 'Timer Inactive') {
79
+ document.getElementById('msg-inativo-card-wrapper').style.display = 'flex';
80
+ document.getElementById('inactive-message').textContent = message;
 
 
 
81
 
82
  // Hide elements in desktop view
83
+ const desktopElements = [
84
  '#card-status-tema-container',
85
  '#cronograma-header',
86
  '#cronograma-table'
87
+ ].forEach(selector => {
 
 
88
  const el = document.querySelector(selector);
89
  if (el) el.style.display = 'none';
90
  });
91
 
92
  // Hide elements in mobile view
93
+ const mobileElements = [
94
  '#card-status-tema-container-mobile',
95
  '#cronograma-header-mobile',
96
  '#cronograma-table-mobile'
 
102
 
103
  // Show active state
104
  function showTemporizadorAtivoState() {
105
+ document.getElementById('msg-inativo-card-wrapper').style.display = 'none';
 
106
 
107
  // Show elements in desktop view
108
+ const desktopElements = [
109
  '#card-status-tema-container',
110
  '#cronograma-header',
111
  '#cronograma-table'
112
+ ].forEach(selector => {
 
 
113
  const el = document.querySelector(selector);
114
  if (el) el.style.display = 'block';
115
  });
116
 
117
  // Show elements in mobile view
118
+ const mobileElements = [
119
  '#card-status-tema-container-mobile',
120
  '#cronograma-header-mobile',
121
  '#cronograma-table-mobile'
 
138
  const container = document.querySelector(selector);
139
  if (container) {
140
  const avisoEl = container.querySelector('span');
141
+ avisoEl.textContent = message;
142
 
143
  container.classList.remove('hidden');
144
  container.classList.add('show');
 
181
  marcarLinhaAtivaNaTabela();
182
  } else {
183
  const row = document.createElement('tr');
184
+ row.innerHTML = '<td colspan="3" class="p-2 text-center text-gray-400">Nenhum cronograma disponível</td>';
185
+ tbody.appendChild(row);
186
  }
187
  });
188
  }
 
202
  }
203
 
204
  // Fullscreen toggle
205
+ document.getElementById('fullscreen-button').addEventListener('click', () => {
206
+ if (!document.fullscreenElement) {
207
+ document.documentElement.requestFullscreen().catch(err => {
208
+ console.error('Error attempting to enable fullscreen:', err);
209
+ });
210
+ } else {
211
+ if (document.exitFullscreen) {
212
+ document.exitFullscreen();
 
 
 
213
  }
214
+ }
215
+ });
216
 
217
  // PWA installation prompt
218
  let deferredPrompt;
219
  window.addEventListener('beforeinstallprompt', (e) => {
220
  e.preventDefault();
221
  deferredPrompt = e;
222
+ document.getElementById('install-app-btn').classList.remove('hidden');
 
223
  });
224
 
225
+ document.getElementById('install-app-btn').addEventListener('click', async () => {
226
+ if (deferredPrompt) {
227
+ deferredPrompt.prompt();
228
+ const { outcome } = await deferredPrompt.userChoice;
229
+ if (outcome === 'accepted') {
230
+ document.getElementById('install-app-btn').classList.add('hidden');
 
 
 
 
231
  }
232
+ deferredPrompt = null;
233
+ }
234
+ });
235
 
236
  // Socket.IO event listeners
237
+ socket.on('dadosAtualizados', updateTemporizadorUI);
238
+ socket.on('cronogramaAtualizado', updateTabelaCronogramaUI);
239
+ socket.on('onlineUsersCountUpdated', (count) => {
240
+ document.querySelectorAll('#online-users-count, #online-users-count-mobile').forEach(el => {
241
+ el.textContent = count;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  });
243
+ });
244
+ socket.on('encerrarTemporizador', () => {
245
+ showTemporizadorInativoState('Temporizador Finalizado');
246
+ });
 
 
 
 
 
247
 
248
  // Initialize
249
  updateCurrentTime();
 
252
 
253
  // Error logging
254
  window.onerror = function(message, source, lineno, colno, error) {
255
+ fetch('/api/log-error', {
256
+ method: 'POST',
257
+ headers: {
258
+ 'Content-Type': 'application/json',
259
+ },
260
+ body: JSON.stringify({
261
+ message,
262
+ source,
263
+ lineno,
264
+ colno,
265
+ error: error ? error.stack : null,
266
+ userId
267
+ })
268
+ }).catch(err => console.error('Error logging failed:', err));
269
+ };