krishgokul92 commited on
Commit
c5d4931
·
verified ·
1 Parent(s): 52f8019

Update public/index.html

Browse files
Files changed (1) hide show
  1. public/index.html +119 -112
public/index.html CHANGED
@@ -1,112 +1,119 @@
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" />
6
- <title>Timer Interface</title>
7
- <style>
8
- /* Shared Styles for Admin and Client */
9
- body { font-family: Arial, sans-serif; background: #121820; color: #e6edf3; }
10
- .wrapper { margin: 0 auto; padding: 20px; max-width: 1200px; }
11
- .btn { border: none; border-radius: 8px; padding: 10px 15px; font-size: 16px; cursor: pointer; }
12
- .btn:hover { background: #333; }
13
- .start-btn { background-color: #2261ff; }
14
- .stop-btn { background-color: #f43f5e; }
15
- .reset-btn { background-color: #0ea5e9; }
16
- .blackout-btn { background-color: #000; color: #fff; }
17
- .btn-group { display: flex; gap: 10px; margin-bottom: 20px; }
18
- .time-display { font-size: 100px; margin-bottom: 20px; }
19
- </style>
20
- </head>
21
- <body>
22
-
23
- <div class="wrapper" id="app">
24
- <!-- The Timer will dynamically show the Admin or Client UI -->
25
- <div id="admin" style="display: none;">
26
- <h2>Admin Controls</h2>
27
- <div class="btn-group">
28
- <button class="btn start-btn" id="start">Start</button>
29
- <button class="btn stop-btn" id="stop">Stop</button>
30
- <button class="btn reset-btn" id="reset">Reset</button>
31
- </div>
32
- <div class="btn-group">
33
- <button class="btn blackout-btn" id="blackoutOn">Blackout ON</button>
34
- <button class="btn blackout-btn" id="blackoutOff">Blackout OFF</button>
35
- </div>
36
- </div>
37
-
38
- <div id="client" style="display: none;">
39
- <h2>Client Timer</h2>
40
- <div class="time-display" id="time">00:00</div>
41
- </div>
42
- </div>
43
-
44
- <script src="/socket.io/socket.io.js"></script>
45
- <script>
46
- const params = new URLSearchParams(window.location.search);
47
- const role = params.get('role') || 'client'; // Default to 'client'
48
- const socket = io({ query: { role, room: 'default' } });
49
-
50
- // Show either admin or client interface
51
- if (role === 'admin') {
52
- document.getElementById('admin').style.display = 'block';
53
- document.getElementById('client').style.display = 'none';
54
- } else {
55
- document.getElementById('admin').style.display = 'none';
56
- document.getElementById('client').style.display = 'block';
57
- }
58
-
59
- // Admin controls
60
- document.getElementById('start').onclick = () => socket.emit('admin:start', { delayMs: 3000, label: 'Start Timer' });
61
- document.getElementById('stop').onclick = () => socket.emit('admin:stop');
62
- document.getElementById('reset').onclick = () => socket.emit('admin:reset');
63
- document.getElementById('blackoutOn').onclick = () => socket.emit('admin:blackout', { on: true });
64
- document.getElementById('blackoutOff').onclick = () => socket.emit('admin:blackout', { on: false });
65
-
66
- // Client timer
67
- let startTime = 0;
68
- let isRunning = false;
69
- let interval;
70
- socket.on('cmd', (cmd) => {
71
- if (cmd.type === 'start') {
72
- startTime = Date.now() + (cmd.startAt - Date.now());
73
- isRunning = true;
74
- startTimer();
75
- }
76
- if (cmd.type === 'stop') {
77
- clearInterval(interval);
78
- isRunning = false;
79
- }
80
- if (cmd.type === 'reset') {
81
- startTime = 0;
82
- isRunning = false;
83
- clearInterval(interval);
84
- updateTime();
85
- }
86
- if (cmd.type === 'blackout') {
87
- if (cmd.on) {
88
- document.body.style.background = 'black';
89
- } else {
90
- document.body.style.background = '#121820';
91
- }
92
- }
93
- });
94
-
95
- function startTimer() {
96
- interval = setInterval(() => {
97
- if (isRunning) {
98
- const elapsed = Date.now() - startTime;
99
- const seconds = Math.floor(elapsed / 1000);
100
- const milliseconds = Math.floor((elapsed % 1000) / 10);
101
- document.getElementById('time').textContent = `${String(seconds).padStart(2, '0')}:${String(milliseconds).padStart(2, '0')}`;
102
- }
103
- }, 50); // Update every 50ms
104
- }
105
-
106
- function updateTime() {
107
- document.getElementById('time').textContent = '00:00';
108
- }
109
- </script>
110
-
111
- </body>
112
- </html>
 
 
 
 
 
 
 
 
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" />
6
+ <title>Timer Interface</title>
7
+ <style>
8
+ /* Shared Styles for Admin and Client */
9
+ body { font-family: Arial, sans-serif; background: #121820; color: #e6edf3; }
10
+ .wrapper { margin: 0 auto; padding: 20px; max-width: 1200px; text-align: center; }
11
+ .btn { border: none; border-radius: 8px; padding: 10px 15px; font-size: 16px; cursor: pointer; }
12
+ .btn:hover { background: #333; }
13
+ .start-btn { background-color: #2261ff; }
14
+ .stop-btn { background-color: #f43f5e; }
15
+ .reset-btn { background-color: #0ea5e9; }
16
+ .blackout-btn { background-color: #000; color: #fff; }
17
+ .btn-group { display: flex; gap: 10px; margin-bottom: 20px; justify-content: center; }
18
+ .time-display { font-size: 100px; margin-bottom: 20px; }
19
+ /* Ensure proper centering and consistency */
20
+ .wrapper { display: flex; flex-direction: column; justify-content: center; align-items: center; }
21
+ /* Fullscreen blackout overlay */
22
+ .blackout { position: fixed; inset: 0; background: #000; display: none; z-index: 999999; }
23
+ </style>
24
+ </head>
25
+ <body>
26
+
27
+ <div class="wrapper" id="app">
28
+ <!-- The Timer will dynamically show the Admin or Client UI based on role -->
29
+ <div id="admin" style="display: none;">
30
+ <h2>Admin Controls</h2>
31
+ <div class="btn-group">
32
+ <button class="btn start-btn" id="start">Start</button>
33
+ <button class="btn stop-btn" id="stop">Stop</button>
34
+ <button class="btn reset-btn" id="reset">Reset</button>
35
+ </div>
36
+ <div class="btn-group">
37
+ <button class="btn blackout-btn" id="blackoutOn">Blackout ON</button>
38
+ <button class="btn blackout-btn" id="blackoutOff">Blackout OFF</button>
39
+ </div>
40
+ </div>
41
+
42
+ <div id="client" style="display: none;">
43
+ <h2>Client Timer</h2>
44
+ <div class="time-display" id="time">00:00</div>
45
+ </div>
46
+ </div>
47
+
48
+ <div class="blackout" id="blackout"></div>
49
+
50
+ <script src="/socket.io/socket.io.js"></script>
51
+ <script>
52
+ const params = new URLSearchParams(window.location.search);
53
+ const role = params.get('role') || 'client'; // Default to 'client'
54
+ const socket = io({ query: { role, room: 'default' } });
55
+
56
+ // Show either admin or client interface
57
+ if (role === 'admin') {
58
+ document.getElementById('admin').style.display = 'block';
59
+ document.getElementById('client').style.display = 'none';
60
+ } else {
61
+ document.getElementById('admin').style.display = 'none';
62
+ document.getElementById('client').style.display = 'block';
63
+ }
64
+
65
+ // Admin controls
66
+ document.getElementById('start').onclick = () => socket.emit('admin:start', { delayMs: 3000, label: 'Start Timer' });
67
+ document.getElementById('stop').onclick = () => socket.emit('admin:stop');
68
+ document.getElementById('reset').onclick = () => socket.emit('admin:reset');
69
+ document.getElementById('blackoutOn').onclick = () => socket.emit('admin:blackout', { on: true });
70
+ document.getElementById('blackoutOff').onclick = () => socket.emit('admin:blackout', { on: false });
71
+
72
+ // Client timer
73
+ let startTime = 0;
74
+ let isRunning = false;
75
+ let interval;
76
+
77
+ socket.on('cmd', (cmd) => {
78
+ if (cmd.type === 'start') {
79
+ startTime = Date.now() + (cmd.startAt - Date.now());
80
+ isRunning = true;
81
+ startTimer();
82
+ }
83
+ if (cmd.type === 'stop') {
84
+ clearInterval(interval);
85
+ isRunning = false;
86
+ }
87
+ if (cmd.type === 'reset') {
88
+ startTime = 0;
89
+ isRunning = false;
90
+ clearInterval(interval);
91
+ updateTime();
92
+ }
93
+ if (cmd.type === 'blackout') {
94
+ if (cmd.on) {
95
+ document.body.style.background = 'black';
96
+ } else {
97
+ document.body.style.background = '#121820';
98
+ }
99
+ }
100
+ });
101
+
102
+ function startTimer() {
103
+ interval = setInterval(() => {
104
+ if (isRunning) {
105
+ const elapsed = Date.now() - startTime;
106
+ const seconds = Math.floor(elapsed / 1000);
107
+ const milliseconds = Math.floor((elapsed % 1000) / 10);
108
+ document.getElementById('time').textContent = `${String(seconds).padStart(2, '0')}:${String(milliseconds).padStart(2, '0')}`;
109
+ }
110
+ }, 50); // Update every 50ms
111
+ }
112
+
113
+ function updateTime() {
114
+ document.getElementById('time').textContent = '00:00';
115
+ }
116
+ </script>
117
+
118
+ </body>
119
+ </html>