Spocklet commited on
Commit
cd8b76f
·
verified ·
1 Parent(s): d05d8d4

Update main.go

Browse files
Files changed (1) hide show
  1. main.go +51 -17
main.go CHANGED
@@ -295,12 +295,22 @@ var htmlContent = `
295
  .btn-big { width: 60px; height: 60px; font-size: 1.5rem; background: var(--text); color: var(--bg); }
296
 
297
  /* Pick Next Grid */
298
- #pick-next { display: none; grid-template-columns: 1fr 1fr 1fr; gap: 8px; animation: fadeIn 0.5s; }
 
 
 
 
299
  .pick-btn { background: #333; border: 1px solid #444; color: #ccc; padding: 15px 5px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: 0.2s; }
300
  .pick-btn:hover { background: #444; border-color: #666; }
301
  .pick-btn span { font-size: 0.8rem; opacity: 0.7; }
302
  .pick-btn b { font-size: 1.1rem; }
303
 
 
 
 
 
 
 
304
  /* User List */
305
  .user-list { margin-top: 30px; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
306
  .user-pill { background: #252525; padding: 5px 12px; border-radius: 15px; font-size: 0.85rem; border: 1px solid #333; display: flex; align-items: center; gap: 6px; }
@@ -341,15 +351,26 @@ var htmlContent = `
341
  </div>
342
 
343
  <!-- Pick Next Screen (Replaces controls when timer ends) -->
344
- <div id="pick-next" class="controls">
345
- <div class="pick-btn" onclick="setMode(25, 'WORK')">
346
- <b>25</b> <span>Work</span>
347
- </div>
348
- <div class="pick-btn" onclick="setMode(5, 'BREAK')">
349
- <b>5</b> <span>Break</span>
 
 
 
 
 
 
350
  </div>
351
- <div class="pick-btn" onclick="setMode(15, 'LONG BREAK')">
352
- <b>15</b> <span>Long</span>
 
 
 
 
 
353
  </div>
354
  </div>
355
  </div>
@@ -438,7 +459,7 @@ var htmlContent = `
438
 
439
  if(state.timerEnded) {
440
  controls.classList.add('hidden');
441
- pickNext.style.display = 'grid'; // Show the voting/picking grid
442
  pickNext.classList.remove('hidden');
443
  } else {
444
  pickNext.style.display = 'none';
@@ -477,24 +498,37 @@ var htmlContent = `
477
  }
478
 
479
  function resetTimer() {
480
- // Resetting just pauses and sets time back to current total
481
- // Or we can just force the pick menu to appear
482
  send({type: 'STOP'});
483
  send({type: 'SET', duration: lastState.totalTime/60, mode: lastState.mode});
484
  }
485
 
486
  function forcePick() {
487
  send({type: 'STOP'});
488
- // We simulate timer ending to show menu, or we can just pause.
489
- // Actually, let's just pause. The UI won't show the menu unless timerEnded is true.
490
- // But clicking one of the menu items manually is always allowed if we unhide it.
491
- // For now, stopping is enough, user can click menu button.
 
 
 
 
 
 
 
492
  }
493
 
494
  function setMode(mins, modeName) {
495
  send({type: 'SET', duration: mins, mode: modeName});
496
  }
 
 
 
 
 
 
 
 
497
  </script>
498
  </body>
499
  </html>
500
- `
 
295
  .btn-big { width: 60px; height: 60px; font-size: 1.5rem; background: var(--text); color: var(--bg); }
296
 
297
  /* Pick Next Grid */
298
+ #pick-next { display: none; flex-direction: column; gap: 15px; animation: fadeIn 0.5s; width: 100%; }
299
+
300
+ /* Grid for presets */
301
+ .grid-presets { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; width: 100%; }
302
+
303
  .pick-btn { background: #333; border: 1px solid #444; color: #ccc; padding: 15px 5px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: 0.2s; }
304
  .pick-btn:hover { background: #444; border-color: #666; }
305
  .pick-btn span { font-size: 0.8rem; opacity: 0.7; }
306
  .pick-btn b { font-size: 1.1rem; }
307
 
308
+ /* Custom Input Row */
309
+ .custom-row { display: flex; gap: 10px; justify-content: center; align-items: center; background: #252525; padding: 10px; border-radius: 12px; }
310
+ .custom-input { width: 50px; padding: 8px; margin: 0; background: #121212; border: 1px solid #444; color: white; text-align: center; border-radius: 6px; font-weight: bold; }
311
+ .btn-small { padding: 8px 12px; font-size: 0.8rem; border-radius: 6px; background: #333; border: 1px solid #444; color: #ddd; cursor: pointer; }
312
+ .btn-small:hover { background: #444; }
313
+
314
  /* User List */
315
  .user-list { margin-top: 30px; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
316
  .user-pill { background: #252525; padding: 5px 12px; border-radius: 15px; font-size: 0.85rem; border: 1px solid #333; display: flex; align-items: center; gap: 6px; }
 
351
  </div>
352
 
353
  <!-- Pick Next Screen (Replaces controls when timer ends) -->
354
+ <div id="pick-next">
355
+ <!-- Presets -->
356
+ <div class="grid-presets">
357
+ <div class="pick-btn" onclick="setMode(25, 'WORK')">
358
+ <b>25</b> <span>Work</span>
359
+ </div>
360
+ <div class="pick-btn" onclick="setMode(5, 'BREAK')">
361
+ <b>5</b> <span>Break</span>
362
+ </div>
363
+ <div class="pick-btn" onclick="setMode(15, 'LONG BREAK')">
364
+ <b>15</b> <span>Long</span>
365
+ </div>
366
  </div>
367
+
368
+ <!-- Custom Input -->
369
+ <div class="custom-row">
370
+ <input type="number" id="custom-min" class="custom-input" value="50" min="1" max="180">
371
+ <span style="font-size: 0.8rem; opacity: 0.5;">min</span>
372
+ <button class="btn-small" onclick="startCustom('WORK')">Work</button>
373
+ <button class="btn-small" onclick="startCustom('BREAK')">Break</button>
374
  </div>
375
  </div>
376
  </div>
 
459
 
460
  if(state.timerEnded) {
461
  controls.classList.add('hidden');
462
+ pickNext.style.display = 'flex'; // Show the voting/picking container
463
  pickNext.classList.remove('hidden');
464
  } else {
465
  pickNext.style.display = 'none';
 
498
  }
499
 
500
  function resetTimer() {
 
 
501
  send({type: 'STOP'});
502
  send({type: 'SET', duration: lastState.totalTime/60, mode: lastState.mode});
503
  }
504
 
505
  function forcePick() {
506
  send({type: 'STOP'});
507
+ // Manually show the pick menu by simulating end state locally until server updates
508
+ // In reality, stopping generates a broadcast, but 'timerEnded' is server state.
509
+ // However, standard flow: user stops, then clicks the specific time button they want.
510
+ // But to make the menu appear instantly we can cheat via CSS in a full implementation,
511
+ // but here we rely on the fact that if you stop, you usually want to set a new time.
512
+ // Since the UI hides controls only on 'timerEnded', we need to actually set that.
513
+ // But for "Change Mode" button, we just want to see the menu.
514
+ // Simple hack: We will toggle the hidden class locally for a better UX
515
+ document.getElementById('active-controls').classList.add('hidden');
516
+ document.getElementById('pick-next').style.display = 'flex';
517
+ document.getElementById('pick-next').classList.remove('hidden');
518
  }
519
 
520
  function setMode(mins, modeName) {
521
  send({type: 'SET', duration: mins, mode: modeName});
522
  }
523
+
524
+ function startCustom(mode) {
525
+ const val = document.getElementById('custom-min').value;
526
+ const mins = parseInt(val);
527
+ if(mins > 0) {
528
+ setMode(mins, mode);
529
+ }
530
+ }
531
  </script>
532
  </body>
533
  </html>
534
+ `