jkorstad commited on
Commit
7501e69
·
verified ·
1 Parent(s): f604ae0

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +362 -21
index.html CHANGED
@@ -1,29 +1,370 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
-
4
  <head>
5
- <meta charset="UTF-8" />
6
- <link rel="stylesheet" href="style.css" />
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
- <title>Transformers.js - Object Detection</title>
10
- </head>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  <body>
13
- <h1>Object Detection w/ 🤗 Transformers.js</h1>
14
- <label id="container" for="upload">
15
- <svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
16
- <path fill="#000"
17
- d="M3.5 24.3a3 3 0 0 1-1.9-.8c-.5-.5-.8-1.2-.8-1.9V2.9c0-.7.3-1.3.8-1.9.6-.5 1.2-.7 2-.7h18.6c.7 0 1.3.2 1.9.7.5.6.7 1.2.7 2v18.6c0 .7-.2 1.4-.7 1.9a3 3 0 0 1-2 .8H3.6Zm0-2.7h18.7V2.9H3.5v18.7Zm2.7-2.7h13.3c.3 0 .5 0 .6-.3v-.7l-3.7-5a.6.6 0 0 0-.6-.2c-.2 0-.4 0-.5.3l-3.5 4.6-2.4-3.3a.6.6 0 0 0-.6-.3c-.2 0-.4.1-.5.3l-2.7 3.6c-.1.2-.2.4 0 .7.1.2.3.3.6.3Z">
18
- </path>
19
- </svg>
20
- Click to upload image
21
- <label id="example">(or try example)</label>
22
- </label>
23
- <label id="status">Loading model...</label>
24
- <input id="upload" type="file" accept="image/*" />
25
-
26
- <script src="index.js" type="module"></script>
27
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  </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.0">
6
+ <title>Dot Counter Stopwatch/Timer</title>
7
+ <style>
8
+ :root {
9
+ --color-bg: #1e1e1e;
10
+ --color-dot: #ffffff;
11
+ --color-active: #f39c12;
12
+ --color-inactive: #555555;
13
+ --dot-size: 8px;
14
+ --grid-gap: 4px;
15
+ --animation-duration: 0.3s;
16
+ --font-size: 16px;
17
+ --container-width: 300px;
18
+ }
19
 
20
+ body {
21
+ margin: 0;
22
+ padding: 0;
23
+ background-color: var(--color-bg);
24
+ color: var(--color-dot);
25
+ font-family: Arial, sans-serif;
26
+ display: flex;
27
+ flex-direction: column;
28
+ align-items: center;
29
+ justify-content: center;
30
+ min-height: 100vh;
31
+ overflow: hidden;
32
+ box-sizing: border-box;
33
+ padding: 20px;
34
+ }
35
+
36
+ .controls {
37
+ margin-bottom: 20px;
38
+ display: flex;
39
+ flex-wrap: wrap;
40
+ gap: 10px;
41
+ justify-content: center;
42
+ }
43
+
44
+ .controls button, .controls input {
45
+ padding: 8px 12px;
46
+ font-size: var(--font-size);
47
+ border: none;
48
+ border-radius: 5px;
49
+ cursor: pointer;
50
+ }
51
+
52
+ .controls button {
53
+ background-color: var(--color-active);
54
+ color: var(--color-bg);
55
+ transition: background-color var(--animation-duration);
56
+ }
57
+
58
+ .controls button:hover {
59
+ background-color: #d35400;
60
+ }
61
+
62
+ .controls input {
63
+ background-color: var(--color-bg);
64
+ color: var(--color-dot);
65
+ border: 1px solid var(--color-dot);
66
+ width: 60px;
67
+ text-align: center;
68
+ }
69
+
70
+ .timer-display {
71
+ font-size: 24px;
72
+ margin-bottom: 20px;
73
+ text-align: center;
74
+ }
75
+
76
+ .label {
77
+ font-size: var(--font-size);
78
+ margin: 10px 0;
79
+ text-align: center;
80
+ }
81
+
82
+ .grid-row {
83
+ display: flex;
84
+ gap: var(--grid-gap);
85
+ margin-bottom: 10px;
86
+ }
87
+
88
+ .grid-container {
89
+ display: flex;
90
+ flex-direction: column;
91
+ align-items: center;
92
+ margin-bottom: 20px;
93
+ }
94
 
95
+ .dot {
96
+ width: var(--dot-size);
97
+ height: var(--dot-size);
98
+ background-color: var(--color-dot);
99
+ border-radius: 50%;
100
+ transition: background-color var(--animation-duration);
101
+ }
102
+
103
+ .dot.active {
104
+ background-color: var(--color-active);
105
+ }
106
+
107
+ .dot.inactive {
108
+ background-color: var(--color-inactive);
109
+ }
110
+
111
+ @media (min-width: 600px) {
112
+ :root {
113
+ --dot-size: 10px;
114
+ --grid-gap: 6px;
115
+ --container-width: 400px;
116
+ }
117
+ }
118
+
119
+ @media (min-width: 900px) {
120
+ :root {
121
+ --dot-size: 12px;
122
+ --grid-gap: 8px;
123
+ --container-width: 500px;
124
+ }
125
+ }
126
+
127
+ /* Animations */
128
+ @keyframes fadeIn {
129
+ from { opacity: 0; }
130
+ to { opacity: 1; }
131
+ }
132
+
133
+ .dot.active {
134
+ animation: fadeIn var(--animation-duration);
135
+ }
136
+
137
+ .dot.inactive {
138
+ animation: fadeIn var(--animation-duration);
139
+ }
140
+ </style>
141
+ </head>
142
  <body>
143
+ <div class="controls">
144
+ <div>
145
+ <label for="hours-input">Hours:</label>
146
+ <input type="number" id="hours-input" value="0" min="0">
147
+ </div>
148
+ <div>
149
+ <label for="minutes-input">Minutes:</label>
150
+ <input type="number" id="minutes-input" value="0" min="0">
151
+ </div>
152
+ <div>
153
+ <label for="seconds-input">Seconds:</label>
154
+ <input type="number" id="seconds-input" value="0" min="0">
155
+ </div>
156
+
157
+ <button id="start-timer">Start Timer</button>
158
+ <button id="pause">Pause</button>
159
+ <button id="reset">Reset</button>
160
+ <button id="start-stopwatch">Start Stopwatch</button>
161
+ </div>
162
+
163
+ <div class="timer-display" id="timer-display">00:00:00</div>
164
+
165
+ <div class="grid-container">
166
+ <div class="label">Seconds:</div>
167
+ <div class="grid-row" id="seconds-row-1"></div>
168
+ <div class="grid-row" id="seconds-row-2"></div>
169
+ <div class="grid-row" id="seconds-row-3"></div>
170
+ </div>
171
 
172
+ <div class="grid-container">
173
+ <div class="label">Minutes:</div>
174
+ <div class="grid-row" id="minutes-row-1"></div>
175
+ <div class="grid-row" id="minutes-row-2"></div>
176
+ <div class="grid-row" id="minutes-row-3"></div>
177
+ </div>
178
+
179
+ <div class="grid-container">
180
+ <div class="label">Hours:</div>
181
+ <div class="grid-row" id="hours-row-1"></div>
182
+ <div class="grid-row" id="hours-row-2"></div>
183
+ <div class="grid-row" id="hours-row-3"></div>
184
+ </div>
185
+ <script>
186
+ const startStopwatchButton = document.getElementById('start-stopwatch');
187
+ const startTimerButton = document.getElementById('start-timer');
188
+ const pauseButton = document.getElementById('pause');
189
+ const resetButton = document.getElementById('reset');
190
+ const timerDisplay = document.getElementById('timer-display');
191
+ const secondsRows = [
192
+ document.getElementById('seconds-row-1'),
193
+ document.getElementById('seconds-row-2'),
194
+ document.getElementById('seconds-row-3')
195
+ ];
196
+ const minutesRows = [
197
+ document.getElementById('minutes-row-1'),
198
+ document.getElementById('minutes-row-2'),
199
+ document.getElementById('minutes-row-3')
200
+ ];
201
+ const hoursRows = [
202
+ document.getElementById('hours-row-1'),
203
+ document.getElementById('hours-row-2'),
204
+ document.getElementById('hours-row-3')
205
+ ];
206
+ const hoursInput = document.getElementById('hours-input');
207
+ const minutesInput = document.getElementById('minutes-input');
208
+ const secondsInput = document.getElementById('seconds-input');
209
+
210
+ let timerInterval;
211
+ let totalSeconds = 0;
212
+ let isRunning = false;
213
+ let isPaused = false;
214
+ let isStopwatch = true;
215
+ let previousSeconds = 0, previousMinutes = 0, previousHours = 0;
216
+
217
+ function updateDisplay() {
218
+ const hours = Math.floor(totalSeconds / 3600);
219
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
220
+ const seconds = totalSeconds % 60;
221
+ if (!isStopwatch && totalSeconds <= 0) {
222
+ timerDisplay.textContent = "DONE";
223
+ timerDisplay.style.color = "green";
224
+ timerDisplay.style.fontSize = "3em"; // Large font size for "DONE"
225
+ } else {
226
+ timerDisplay.textContent = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
227
+ timerDisplay.style.color = ""; // Reset color
228
+ timerDisplay.style.fontSize = "24px"; // Reset font size
229
+ }
230
+ }
231
+
232
+ function initializeGrid(rowGroup, maxCount) {
233
+ for (let i = 0; i < maxCount; i++) {
234
+ const dot = document.createElement('div');
235
+ dot.classList.add('dot', 'inactive');
236
+ const rowIndex = Math.floor(i / (maxCount / rowGroup.length));
237
+ rowGroup[rowIndex].appendChild(dot);
238
+ }
239
+ }
240
+
241
+ // Initialize all grids
242
+ initializeGrid(secondsRows, 60);
243
+ initializeGrid(minutesRows, 60);
244
+ initializeGrid(hoursRows, 24);
245
+
246
+ function updateGrids() {
247
+ const hours = Math.floor(totalSeconds / 3600);
248
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
249
+ const seconds = totalSeconds % 60;
250
+
251
+ updateGridRow(secondsRows, previousSeconds, seconds, 60);
252
+ previousSeconds = seconds;
253
+
254
+ updateGridRow(minutesRows, previousMinutes, minutes, 60);
255
+ previousMinutes = minutes;
256
+
257
+ updateGridRow(hoursRows, previousHours, hours, 24);
258
+ previousHours = hours;
259
+ }
260
+
261
+ function updateGridRow(rows, previous, current, max) {
262
+ const start = Math.min(previous, current);
263
+ const end = Math.max(previous, current);
264
+
265
+ for (let i = start; i < end; i++) {
266
+ const rowIndex = Math.floor(i / (max / rows.length));
267
+ const dotIndex = i % (max / rows.length);
268
+ const dot = rows[rowIndex].children[dotIndex];
269
+ if (dot) {
270
+ dot.classList.remove('active', 'inactive');
271
+ dot.classList.add(i < current ? 'active' : 'inactive');
272
+ }
273
+ }
274
+ }
275
+
276
+ // Make sure the start function doesn't reset totalSeconds when resuming
277
+ function start() {
278
+ if (!isRunning) {
279
+ // Set totalSeconds only if we're starting anew or if it's a timer
280
+ if (isStopwatch && totalSeconds === 0) {
281
+ totalSeconds = 0; // For stopwatch, only reset if starting from 0
282
+ } else if (!isStopwatch && totalSeconds <= 0) {
283
+ totalSeconds = parseInt(hoursInput.value) * 3600 + parseInt(minutesInput.value) * 60 + parseInt(secondsInput.value);
284
+ }
285
+ timerInterval = setInterval(() => {
286
+ if (isStopwatch) {
287
+ totalSeconds++;
288
+ } else {
289
+ totalSeconds--;
290
+ if (totalSeconds < 0) {
291
+ totalSeconds = 0;
292
+ clearInterval(timerInterval);
293
+ isRunning = false;
294
+ updateDisplay(); // Update display one last time to show "DONE"
295
+ }
296
+ }
297
+ updateDisplay();
298
+ updateGrids();
299
+ }, 1000);
300
+ isRunning = true;
301
+ }
302
+ }
303
+
304
+ function pause() {
305
+ if (isRunning) {
306
+ if (!isPaused) {
307
+ clearInterval(timerInterval);
308
+ isPaused = true;
309
+ pauseButton.textContent = "Play"; // Change button text to 'Play'
310
+ isRunning = false; // Set isRunning to false when paused
311
+ } else {
312
+ // Use start() to resume, which now doesn't reset totalSeconds for stopwatch
313
+ start();
314
+ isPaused = false;
315
+ pauseButton.textContent = "Pause"; // Change button text back to 'Pause'
316
+ }
317
+ } else if (isPaused) {
318
+ // This case is for when you click "Play" after pausing
319
+ isPaused = false;
320
+ pauseButton.textContent = "Pause";
321
+ start(); // Call start to resume from where it was paused
322
+ }
323
+ }
324
+
325
+ function reset() {
326
+ clearInterval(timerInterval);
327
+ isRunning = false;
328
+ totalSeconds = 0;
329
+ previousSeconds = previousMinutes = previousHours = 0;
330
+ isStopwatch = true;
331
+ updateDisplay();
332
+
333
+ // Clear all dots
334
+ clearGrid(secondsRows);
335
+ clearGrid(minutesRows);
336
+ clearGrid(hoursRows);
337
+
338
+ // Reinitialize the grids
339
+ initializeGrid(secondsRows, 60);
340
+ initializeGrid(minutesRows, 60);
341
+ initializeGrid(hoursRows, 24);
342
+
343
+ hoursInput.value = minutesInput.value = secondsInput.value = '0';
344
+ isPaused = false; // Reset pause state
345
+ pauseButton.textContent = "Pause"; // Reset button text
346
+ }
347
+
348
+ function clearGrid(rows) {
349
+ rows.forEach(row => row.innerHTML = '');
350
+ }
351
+
352
+ startStopwatchButton.addEventListener('click', () => {
353
+ isStopwatch = true;
354
+ start();
355
+ });
356
+
357
+ startTimerButton.addEventListener('click', () => {
358
+ isStopwatch = false;
359
+ start();
360
+ });
361
+
362
+ pauseButton.addEventListener('click', pause);
363
+ resetButton.addEventListener('click', reset);
364
+
365
+ // Initial display update
366
+ updateDisplay();
367
+ updateGrids();
368
+ </script>
369
+ </body>
370
  </html>