-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.html
More file actions
1287 lines (1215 loc) · 76.9 KB
/
Copy pathcontroller.html
File metadata and controls
1287 lines (1215 loc) · 76.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="sr">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'">
<title>ProTimer — Kontrola</title>
<style>
:root{
--bg:#0a0a0d; --panel:#141419; --panel2:#1e1e25; --border:rgba(255,255,255,.075);
--border-strong:rgba(255,255,255,.14);
--text:#f2f2f5; --dim:#9b9ba6; --dim2:#5e5e68;
--accent:#30d158; --accent-d:#28b34c; --blue:#0a84ff; --red:#ff453a; --amber:#d9a441;
--radius:12px;
--focus:0 0 0 3px rgba(10,132,255,.28);
--shadow-card:0 1px 2px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.03);
}
*{box-sizing:border-box; -webkit-user-select:none; user-select:none;}
input,textarea{-webkit-user-select:auto; user-select:auto;}
body{margin:0; color:var(--text); overflow:hidden;
height:100vh; display:flex; flex-direction:column;
background:radial-gradient(1200px 500px at 50% -200px, #131318 0%, var(--bg) 60%) fixed;
font:13.5px/1.45 -apple-system, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
-webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;}
/* ---- top bar ---- */
.topbar{flex:0 0 auto; display:flex; align-items:center; gap:10px; padding:12px 18px;
border-bottom:1px solid var(--border); background:rgba(20,20,25,.6); backdrop-filter:blur(20px);}
.brand{font-weight:700; letter-spacing:4px; font-size:13.5px;}
.brand b{color:var(--accent); font-weight:700;}
.grow{flex:1;}
select,input[type=text],input[type=time]{background:rgba(255,255,255,.055); color:var(--text);
border:1px solid var(--border); border-radius:9px; padding:7px 10px; font-size:13px; outline:none;
transition:border-color .15s, box-shadow .15s;}
select:focus,input:focus{border-color:var(--blue); box-shadow:var(--focus);}
input.armed{border-color:var(--accent); box-shadow:0 0 0 3px rgba(48,209,88,.16);}
input[type=color]{width:34px; height:30px; padding:2px; border:1px solid var(--border);
border-radius:9px; background:rgba(255,255,255,.055); cursor:pointer;}
button{background:rgba(255,255,255,.065); color:var(--text); border:1px solid var(--border);
border-radius:9px; padding:7px 13px; font-size:13px; font-weight:500; cursor:pointer; white-space:nowrap;
transition:background .15s, border-color .15s, transform .06s, box-shadow .15s;}
button:hover{background:rgba(255,255,255,.11); border-color:var(--border-strong);}
button:active{transform:scale(.97);}
button.primary{background:linear-gradient(180deg, #2fbd54, #23a344); border-color:transparent; color:#fff;
font-weight:600; box-shadow:0 1px 8px rgba(48,209,88,.25), inset 0 1px 0 rgba(255,255,255,.18);}
button.primary:hover{background:linear-gradient(180deg, #36d160, #28b34c); filter:brightness(1.04);}
button.ghost{background:transparent;}
button.danger{background:transparent; border-color:rgba(255,69,58,.35); color:#ff8b84;}
button.danger:hover{border-color:var(--red); background:rgba(255,69,58,.1);}
button:disabled{opacity:.42; cursor:default; filter:none; transform:none; box-shadow:none;}
label.chk{display:flex; align-items:center; gap:6px; color:var(--dim); font-size:12.5px; cursor:pointer; transition:color .15s;}
label.chk:hover{color:var(--text);}
label.chk input{accent-color:var(--accent);}
.main{flex:1 1 auto; min-height:0; display:grid; grid-template-columns:1fr 300px; align-items:start;
gap:14px; padding:14px; overflow-y:auto; overflow-x:hidden;}
.main::-webkit-scrollbar{width:11px;}
.main::-webkit-scrollbar-thumb{background:var(--border); border-radius:6px; border:2px solid var(--bg);}
.main::-webkit-scrollbar-thumb:hover{background:var(--dim2);}
.left{display:flex; flex-direction:column; gap:10px; min-width:0;}
.cuelist::-webkit-scrollbar{width:8px;}
.cuelist::-webkit-scrollbar-thumb{background:var(--border); border-radius:4px;}
.panel{background:var(--panel); border:1px solid var(--border); border-radius:var(--radius);
padding:12px 14px; box-shadow:var(--shadow-card);}
.row{display:flex; gap:9px; align-items:center; flex-wrap:wrap;}
.lbl{color:var(--dim); font-size:10.5px; text-transform:uppercase; letter-spacing:1.4px; font-weight:600;}
.sep{width:1px; height:20px; background:var(--border-strong); margin:0 2px;}
/* poravnata polja sa levim žlebom za oznaku sekcije */
.field{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}
.field + .field{margin-top:11px; padding-top:11px; border-top:1px solid var(--border);}
.glabel{flex:0 0 70px; font-size:10.5px; letter-spacing:1.3px; text-transform:uppercase;
color:var(--dim); font-weight:700;}
.swatch{display:flex; align-items:center; gap:7px; color:var(--dim); font-size:12.5px;}
.warn-sw{display:flex; align-items:center; gap:4px;}
.warn-sw .tag{font-size:11px; color:var(--dim2); font-family:"SF Mono",Menlo,monospace; width:11px; text-align:center;}
.field input.short{width:58px;}
/* ---- preview (sadržaj izlaza; u kontroli je uvek velik i centriran) ---- */
.preview{position:relative; border:1px solid var(--border); border-radius:var(--radius);
flex:0 0 auto; height:clamp(170px, 26vh, 320px); min-height:170px; overflow:hidden; display:flex; flex-direction:column;
align-items:center; justify-content:center; background:#000;}
.pv-checker{position:absolute; inset:0; background-color:#2a2f3a;
background-image:linear-gradient(45deg,#1a1f28 25%,transparent 25%),linear-gradient(-45deg,#1a1f28 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#1a1f28 75%),linear-gradient(-45deg,transparent 75%,#1a1f28 75%);
background-size:24px 24px; background-position:0 0,0 12px,12px -12px,-12px 0; display:none;}
.pv-stage{position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; overflow:hidden;}
.gridsel{width:248px; max-width:100%; aspect-ratio:16/9; background:#000; border:1px solid var(--border);
border-radius:7px; display:grid; gap:1px; overflow:hidden;}
.gridsel .gc{background:#11151c; cursor:pointer; transition:background .08s;}
.gridsel .gc:hover{background:#22303f;}
.gridsel .gc.sel{background:var(--accent);}
.gridsel.off{opacity:.35; pointer-events:none;}
.pv-text{position:relative; font-weight:600; line-height:1.1; text-align:center; padding:0 24px; display:none;
white-space:pre-wrap; max-width:100%; overflow:hidden;}
.pv-time{position:relative; font-family:"SF Mono",ui-monospace,Menlo,monospace; font-weight:700;
font-variant-numeric:tabular-nums; line-height:.95; white-space:nowrap;}
.pv-time.neg{animation:pulse 1s steps(2,start) infinite;}
@keyframes pulse{50%{opacity:.25;}}
.pv-msg{position:absolute; bottom:14px; left:0; right:0; text-align:center; font-size:17px; font-weight:700;
padding:0 16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:none;}
.pv-msg.flash{animation:pulse .8s steps(2,start) infinite;}
.pv-prog{position:absolute; bottom:0; left:0; height:5px; display:none;}
.badges{position:absolute; top:9px; right:11px; display:flex; gap:6px; z-index:2;}
.badge{font-size:10px; font-weight:700; letter-spacing:.5px; padding:3px 8px; border-radius:20px;
background:rgba(0,0,0,.5); color:var(--dim); border:1px solid var(--border);}
.badge.on{background:var(--accent-d); color:#fff; border-color:var(--accent-d);}
.badge.bk{background:var(--red); color:#fff; border-color:var(--red);}
/* ---- transport ---- */
.transport{display:flex; gap:8px;}
#btnStart{flex:1.7; font-size:17px; font-weight:700; padding:15px 8px; letter-spacing:1.5px; border-radius:11px;}
#btnStart.running{background:linear-gradient(180deg,#c9880c,#a86f05); border-color:transparent; color:#fff;
box-shadow:0 1px 8px rgba(217,164,65,.25), inset 0 1px 0 rgba(255,255,255,.18);}
#btnReset{flex:.7; font-size:14px; border-radius:11px;}
.adjust{display:flex; gap:6px; flex:3;}
.adjust button{flex:1; font-family:"SF Mono",ui-monospace,Menlo,monospace; font-size:12.5px; padding:8px 4px;
font-variant-numeric:tabular-nums;}
#btnBlackout{flex:1; border-radius:11px;}
#btnBlackout.on{background:linear-gradient(180deg,#ff453a,#e03026); border-color:transparent; color:#fff;
box-shadow:0 1px 8px rgba(255,69,58,.3), inset 0 1px 0 rgba(255,255,255,.15);}
/* segmented kontrola (Apple-stil) */
.tabs{display:inline-flex; gap:2px; background:rgba(255,255,255,.05); border:1px solid var(--border);
border-radius:10px; padding:2px;}
.tabs button{padding:6px 13px; color:var(--dim); background:transparent; border:none; border-radius:8px; font-weight:500;}
.tabs button:hover{color:var(--text); background:rgba(255,255,255,.05);}
.tabs button.active{background:var(--blue); color:#fff; font-weight:600;
box-shadow:0 1px 4px rgba(10,132,255,.35), inset 0 1px 0 rgba(255,255,255,.15);}
.chips{display:flex; gap:5px; flex-wrap:wrap;}
.chips button{padding:5px 10px; font-size:12px; font-family:"SF Mono",ui-monospace,Menlo,monospace; color:var(--dim);
border-radius:20px;}
.chips button:hover{color:var(--text);}
input.short{width:62px; text-align:center; font-family:"SF Mono",Menlo,monospace;}
input.w90{width:92px; text-align:center; font-family:"SF Mono",Menlo,monospace;}
/* ---- zajednički birač trajanja ---- */
.duration-control{display:inline-flex; align-items:center; gap:6px; min-width:0;}
.duration-trigger{display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:34px;
padding:6px 10px; border-color:var(--border-strong); font-family:"SF Mono",ui-monospace,Menlo,monospace;
font-variant-numeric:tabular-nums; letter-spacing:.2px;}
.duration-trigger[aria-expanded="true"]{border-color:var(--blue); box-shadow:var(--focus); background:rgba(10,132,255,.12);}
.duration-trigger .caption{font-family:-apple-system,"SF Pro Text","Helvetica Neue",system-ui,sans-serif;
color:var(--dim); font-size:9.5px; font-weight:700; letter-spacing:1.2px; text-transform:uppercase;}
.duration-trigger .value{color:var(--text); font-size:13px;}
.duration-trigger.cue-duration{min-width:94px; padding-inline:9px;}
.duration-trigger.cue-duration .value{font-size:12.5px;}
.target-control{display:inline-flex; align-items:center; gap:7px; flex:0 0 auto; white-space:nowrap;}
.duration-popover{position:fixed; z-index:80; width:min(456px,calc(100vw - 24px)); padding:17px;
background:#1a1a21; border:1px solid var(--border-strong); border-radius:14px;
box-shadow:0 22px 60px rgba(0,0,0,.58), inset 0 1px 0 rgba(255,255,255,.045);}
.duration-popover[hidden]{display:none;}
.duration-popover-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px;}
.duration-popover-title{font-size:11px; color:var(--dim); font-weight:700; letter-spacing:1.4px; text-transform:uppercase;}
.duration-close{padding:3px 8px; font-size:11px; color:var(--dim); background:transparent;}
.duration-readout{display:grid; grid-template-columns:1fr 22px 1fr 22px 1fr; align-items:start;}
.duration-unit{display:flex; min-width:0; flex-direction:column; align-items:center; gap:7px;}
.duration-segment{width:100%; min-width:0; border:none!important; background:transparent!important; box-shadow:none!important;
padding:0!important; color:var(--text); text-align:center; font:700 38px/1.05 "SF Mono",ui-monospace,Menlo,monospace!important;
font-variant-numeric:tabular-nums; caret-color:var(--blue);}
.duration-segment:focus{color:#fff; text-shadow:0 0 18px rgba(10,132,255,.28);}
.duration-unit-label{font-size:9.5px; color:var(--dim); font-weight:700; letter-spacing:1.25px; text-transform:uppercase;}
.duration-colon{font:700 34px/1 "SF Mono",ui-monospace,Menlo,monospace; text-align:center; color:var(--dim); padding-top:3px;}
.duration-stepper{display:grid; grid-template-columns:1fr 1fr; gap:6px; width:100%; margin-top:1px;}
.duration-stepper button{padding:6px 8px; font:600 18px/1 "SF Mono",ui-monospace,Menlo,monospace;}
.duration-presets{display:grid; grid-template-columns:repeat(6,1fr); gap:6px; margin:15px 0 12px;}
.duration-presets button{padding:7px 4px; font-family:"SF Mono",ui-monospace,Menlo,monospace; color:var(--dim);}
.duration-presets button.active{border-color:var(--accent); color:var(--text); background:rgba(48,209,88,.09);}
.duration-confirm{width:100%; padding:11px!important; font-size:14px!important; letter-spacing:.8px;}
.duration-help{margin-top:8px; text-align:center; color:var(--dim2); font-size:10.5px;}
/* ---- right column ---- */
.right{display:flex; flex-direction:column; gap:12px; min-width:0;}
.card{background:var(--panel); border:1px solid var(--border); border-radius:var(--radius);
padding:13px; display:flex; flex-direction:column; min-height:0; box-shadow:var(--shadow-card);}
.card h3{margin:0 0 10px; font-size:10.5px; letter-spacing:1.8px; color:var(--dim); font-weight:600;}
.cuewrap{flex:0 0 auto; display:flex; flex-direction:column;}
.cuehead{display:flex; align-items:center; gap:7px; margin-bottom:9px; flex-wrap:wrap;}
.cuehead .mini{padding:3px 8px; font-size:11px;}
.cuehead input[type=time]{padding:4px 6px; font-size:12px;}
.rundown-start{width:100%; padding:12px!important; margin-bottom:9px; font-size:14px!important;
font-weight:800!important; letter-spacing:.65px;}
.ou{font-family:"SF Mono",Menlo,monospace; font-size:11px; font-weight:700; padding:2px 7px; border-radius:6px;
background:var(--panel2); border:1px solid var(--border); color:var(--dim); white-space:nowrap;}
.ou.late{background:#3a1f1d; border-color:#5a2b28; color:#ff8b84;}
.ou.early{background:#16263a; border-color:#1f3a5a; color:#7db8ff;}
.ou.ontime{background:#13251a; border-color:#1f4a30; color:var(--accent);}
.cuelist{overflow-y:auto; overflow-x:hidden; display:flex; flex-direction:column; gap:5px;
min-height:40px; max-height:34vh; margin-bottom:9px; scrollbar-gutter:stable;
overscroll-behavior:contain;}
.cuelist::-webkit-scrollbar{width:8px;} .cuelist::-webkit-scrollbar-thumb{background:var(--border); border-radius:4px;}
.cue{display:flex; flex:0 0 auto; min-height:44px; align-items:center; gap:7px; background:rgba(255,255,255,.045); border:1px solid var(--border);
border-radius:9px; padding:7px 9px; padding-left:7px; cursor:pointer; position:relative; overflow:hidden;
transition:background .15s, border-color .15s;}
.cue:hover{background:rgba(255,255,255,.08);}
.cue .stripe{position:absolute; left:0; top:0; bottom:0; width:3px; border-radius:3px;}
.cue.current{border-color:rgba(48,209,88,.5); background:rgba(48,209,88,.09);}
.cue .n{color:var(--dim2); font-size:11px; width:14px; flex:0 0 auto;}
.cue .body{flex:1; min-width:0;}
.cue .nm{overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px;}
.cue .note{overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; color:var(--dim2); margin-top:1px;}
.cue .times{font-family:"SF Mono",Menlo,monospace; color:var(--dim); font-size:11px; text-align:right; flex:0 0 auto;}
.cue .times .du{color:var(--dim2); font-size:10.5px;}
.cue .mini{padding:2px 6px; font-size:10px; border-radius:5px; flex:0 0 auto;}
.cueadd{display:flex; gap:6px; align-items:center; margin-bottom:7px;}
.cuecolors{display:flex; gap:3px; align-items:center;}
.cuecolors .cdot{width:15px; height:15px; border-radius:50%; cursor:pointer; border:2px solid transparent;}
.cuecolors .cdot.sel{border-color:#fff;}
.cuecolors .cdot.none{background:var(--panel2); border:1px dashed var(--dim2); position:relative;}
.empty{color:var(--dim2); font-size:12px; text-align:center; padding:14px 0;}
/* mreža / OBS */
.net-url{display:flex; align-items:center; gap:7px; background:rgba(255,255,255,.045); border:1px solid var(--border);
border-radius:9px; padding:8px 10px; font-family:"SF Mono",ui-monospace,Menlo,monospace; font-size:12px; margin-bottom:8px;}
.net-url span{flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--accent);}
.net-url .mini{padding:3px 8px; font-size:11px; flex:0 0 auto;}
.qrbtn{padding:3px 7px; font-size:10px; flex:0 0 auto;}
.qrbox{display:none; background:#fff; border-radius:10px; padding:11px; margin:2px 0 9px; text-align:center;}
.qrbox svg{width:172px; height:172px; display:block; margin:0 auto;}
.qrbox .qrlbl{color:#0b0d11; font-size:10.5px; margin-top:7px; word-break:break-all; font-family:"SF Mono",Menlo,monospace; line-height:1.3;}
.qrbox .audience-qr-action{width:100%; margin-top:9px;}
#btnShare.on{background:var(--accent-d); border-color:var(--accent-d); color:#fff; font-weight:600;}
.net-note{color:var(--dim2); font-size:11px; line-height:1.5;}
.dot{width:7px; height:7px; border-radius:50%; background:var(--red); display:inline-block;}
.dot.on{background:var(--accent);}
.statusbar{flex:0 0 auto; padding:6px 18px; color:var(--dim2); font-size:11px;
border-top:1px solid var(--border); background:rgba(20,20,25,.6); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
kbd{background:rgba(255,255,255,.07); border:1px solid var(--border-strong); border-bottom-width:2px;
border-radius:5px; padding:0 5px; font-size:10px; color:var(--dim);}
.lang{display:inline-flex; gap:2px; background:rgba(255,255,255,.05); border:1px solid var(--border); border-radius:9px; padding:2px;}
.lang button{padding:4px 9px; font-size:11.5px; font-weight:600; border:none; background:transparent; color:var(--dim); border-radius:7px;}
.lang button.active{background:var(--blue); color:#fff; box-shadow:0 1px 4px rgba(10,132,255,.35);}
@media (max-width:960px){
.topbar{flex-wrap:wrap; padding-block:9px;}
.topbar>.grow{flex:0 0 100%; height:0;}
.topbar #displaySel{flex:1 1 180px; min-width:150px; max-width:220px!important;}
.transport{flex-wrap:wrap;}
#btnStart{flex:2 1 160px;}
#btnReset{flex:1 1 100px;}
#btnBlackout{flex:1 1 120px;}
.transport .adjust{order:4; flex:1 0 100%;}
}
</style>
</head>
<body>
<div class="topbar">
<div class="brand">PRO<b>TIMER</b></div>
<div class="lang">
<button data-lang="sr">SR</button>
<button data-lang="en">EN</button>
</div>
<div class="grow"></div>
<span class="lbl" data-i18n="outLabel">Izlaz na</span>
<select id="displaySel" data-i18n-title="displayTitle" title="Monitor za izlazni ekran" style="max-width:280px"></select>
<button id="btnOpenOut" class="primary" data-i18n="sendScreen">Pošalji na ekran</button>
<button id="btnFs" data-i18n-title="fsTitle" title="Pun ekran (F)">⛶</button>
<button id="btnCloseOut" class="ghost" data-i18n-title="closeTitle" title="Zatvori izlazni prozor">✕</button>
<div class="sep"></div>
<label class="chk" data-i18n-title="fitTitle" title="Prozor (kad nije pun ekran) prati veličinu tajmera"><input type="checkbox" id="chkFit"> <span data-i18n="fitWindow">Kompaktan</span></label>
<label class="chk"><input type="checkbox" id="chkOnTop"> <span data-i18n="onTop">Na vrhu</span></label>
</div>
<div class="main">
<div class="left">
<div class="preview" id="preview">
<div class="pv-checker" id="pvChecker"></div>
<div class="badges">
<div class="badge" id="bdgOut">EKRAN</div>
<div class="badge" id="bdgBk">BLACKOUT</div>
</div>
<div class="pv-stage" id="pvStage">
<div class="pv-text" id="pvText"></div>
<div class="pv-time" id="pvTime">10:00</div>
</div>
<div class="pv-msg" id="pvMsg"></div>
<div class="pv-prog" id="pvProg"></div>
</div>
<div class="transport">
<button id="btnStart" class="primary">▶ START</button>
<button id="btnReset">↺ RESET</button>
<div class="adjust">
<button data-adj="-300">−5m</button>
<button data-adj="-60">−1m</button>
<button data-adj="-10">−10s</button>
<button data-adj="10">+10s</button>
<button data-adj="60">+1m</button>
<button data-adj="300">+5m</button>
</div>
<button id="btnBlackout">■ BLACKOUT</button>
</div>
<div class="panel">
<div class="field">
<span class="glabel" data-i18n="mode">Režim</span>
<div class="tabs">
<button data-mode="countdown" class="active" data-i18n="modeCountdown">Odbrojavanje</button>
<button data-mode="countup" data-i18n="modeCountup">Štoperica</button>
<button data-mode="clock" data-i18n="modeClock">Sat</button>
</div>
<div class="sep"></div>
<div class="duration-control">
<button id="durTrigger" class="duration-trigger" type="button" aria-haspopup="dialog" aria-controls="durationPopover" aria-expanded="false" data-i18n-title="durTitle" title="Postavi sate, minute i sekunde">
<span class="caption" data-i18n="duration">Trajanje</span><span class="value" id="durTriggerValue">00:10:00</span>
</button>
<button id="btnSetDur" class="ghost" data-i18n="set">Postavi</button>
</div>
<div class="target-control">
<div class="sep"></div>
<span class="lbl" data-i18n="endAt">Kraj u</span>
<input type="time" id="targetInput" data-i18n-title="targetTitle" title="Izaberi vreme završetka, zatim pokreni velikim START dugmetom">
</div>
</div>
<div class="field">
<span class="glabel" data-i18n="quick">Brzo</span>
<div class="chips" id="chips"></div>
</div>
</div>
<div class="panel">
<div class="field">
<span class="glabel" data-i18n="colors">Boje</span>
<label class="swatch"><span data-i18n="background">Pozadina</span> <input type="color" id="bgColor" value="#000000"></label>
<label class="swatch"><span data-i18n="timeText">Vreme/tekst</span> <input type="color" id="fgColor" value="#ffffff"></label>
<div class="sep"></div>
<label class="chk"><input type="checkbox" id="chkWarn" checked> <span data-i18n="warnColors">Boje upozorenja</span></label>
<span class="warn-sw"><span class="tag" data-i18n="tagY">Ž</span><input type="color" id="warnYellow" value="#ffc23a" data-i18n-title="yellow" title="Žuto"></span>
<span class="warn-sw"><span class="tag" data-i18n="tagR">C</span><input type="color" id="warnRed" value="#ff4540" data-i18n-title="red" title="Crveno"></span>
<div class="sep"></div>
<label class="chk"><input type="checkbox" id="chkTransparent"> <span data-i18n="transparent">Providna pozadina (OBS)</span></label>
</div>
<div class="field">
<span class="glabel" data-i18n="text">Tekst</span>
<input type="text" id="textInput" placeholder="Tekst na ekranu (npr. PAUZA, DOBRO DOŠLI)…" data-i18n-ph="textPh" style="flex:1; min-width:140px">
<label class="chk"><input type="checkbox" id="chkTextOnly"> <span data-i18n="textOnly">Samo tekst</span></label>
<button id="btnTextClear" class="ghost" data-i18n="clear">Obriši</button>
</div>
</div>
<div class="panel">
<div class="field" style="align-items:flex-start">
<span class="glabel" data-i18n="grid">Grid</span>
<div style="flex:1; min-width:0;">
<div class="row" style="margin-bottom:9px">
<label class="chk"><input type="checkbox" id="chkGrid"> <span data-i18n="gridOn">Pozicija na ekranu</span></label>
<div class="sep"></div>
<div class="tabs" id="gridSizes">
<button data-gs="3">3×3</button><button data-gs="5">5×5</button><button data-gs="7">7×7</button><button data-gs="9">9×9</button>
</div>
<span class="lbl" id="gridHint" data-i18n="gridHint">izaberi kockicu →</span>
</div>
<div class="gridsel" id="gridSel"></div>
</div>
</div>
</div>
<div class="panel">
<div class="field">
<span class="glabel" data-i18n="thresholds">Pragovi</span>
<label class="swatch"><span data-i18n="yellowAt">Žuto na</span> <input type="text" id="yellowInput" class="short" value="2:00"></label>
<label class="swatch"><span data-i18n="redAt">Crveno na</span> <input type="text" id="redInput" class="short" value="1:00"></label>
<div class="sep"></div>
<label class="chk"><input type="checkbox" id="chkFlash" checked> <span data-i18n="flashZero">Blic na nuli</span></label>
<label class="chk"><input type="checkbox" id="chkSound"> <span data-i18n="sound">Zvuk</span></label>
<label class="chk"><input type="checkbox" id="chkOver" checked> <span data-i18n="overtime">Minus posle nule</span></label>
<label class="chk"><input type="checkbox" id="chkProg"> <span data-i18n="progress">Traka napretka</span></label>
</div>
</div>
<div class="panel">
<div class="field">
<span class="glabel" data-i18n="message">Poruka</span>
<input type="text" id="msgInput" placeholder="Poruka govorniku… (M za fokus, Enter šalje)" data-i18n-ph="messagePh" style="flex:1; min-width:140px">
<label class="chk"><input type="checkbox" id="chkMsgFlash"> <span data-i18n="flash">Treperi</span></label>
<button id="btnMsgSend" class="primary" data-i18n="send">Pošalji</button>
<button id="btnMsgClear" class="ghost" data-i18n="clear">Obriši</button>
</div>
</div>
</div>
<div class="right">
<div class="card cuewrap" style="flex:1" tabindex="0">
<div class="cuehead">
<h3 data-i18n="rundown" style="margin:0">RUNDOWN</h3>
<div class="grow"></div>
<span class="lbl" data-i18n="showStart">Planirani početak</span>
<input type="time" id="showStartInput" title="Planirani početak showa">
<span id="ouStatus" class="ou"></span>
</div>
<button id="btnRundownStart" class="primary rundown-start" data-i18n="startRundown">▶ START RUNDOWN</button>
<div class="cuelist" id="cueList"></div>
<div class="cueadd">
<input type="text" id="cueName" placeholder="Naziv" data-i18n-ph="namePh" style="flex:1; min-width:40px">
<button id="cueDurationTrigger" class="duration-trigger cue-duration" type="button" aria-haspopup="dialog" aria-controls="durationPopover" aria-expanded="false" data-i18n-title="cueDurationTitle" title="Postavi trajanje stavke">
<span class="value" id="cueDurationValue">00:10:00</span>
</button>
<button id="btnCueAdd" title="Dodaj">+</button>
</div>
<div class="cueadd">
<input type="text" id="cueNote" placeholder="Beleška (opciono)…" data-i18n-ph="notePh" style="flex:1; min-width:60px">
<span class="cuecolors" id="cueColors"></span>
</div>
<label class="chk" style="margin-bottom:7px"><input type="checkbox" id="chkAuto"> <span data-i18n="autoNext">Auto-prelaz na sledeći</span></label>
<label class="chk" style="margin-bottom:9px"><input type="checkbox" id="chkNowNext"> <span data-i18n="nowNextOut">NOW/NEXT na ekranu</span></label>
<button id="btnGo" class="primary" style="font-weight:800; padding:11px" data-i18n-html="goNext">GO ▶ SLEDEĆI (N)</button>
</div>
<div class="card">
<h3 data-i18n="netTitle">MREŽA → OBS · TELEFON</h3>
<div class="lbl" style="margin-bottom:5px" data-i18n="screenOBS">Ekran (OBS / monitor)</div>
<div class="net-url">
<span id="netUrl">—</span>
<button class="mini ghost qrbtn" data-qr="netUrl" data-audience-qr="timer" title="QR kod">QR</button>
<button id="btnCopyUrl" class="mini ghost" data-i18n="copy">Kopiraj</button>
</div>
<div class="lbl" style="margin-bottom:5px" data-i18n="remoteLabel">Daljinski (telefon / tablet)</div>
<div class="net-url">
<span id="netRemote" style="color:var(--blue)">—</span>
<button class="mini ghost qrbtn" data-qr="netRemote" title="QR kod">QR</button>
<button id="btnCopyRemote" class="mini ghost" data-i18n="copy">Kopiraj</button>
</div>
<div class="lbl" style="margin-bottom:5px" data-i18n="backstageLabel">Backstage (raspored / crew)</div>
<div class="net-url">
<span id="netBackstage" style="color:var(--amber)">—</span>
<button class="mini ghost qrbtn" data-qr="netBackstage" data-audience-qr="backstage" title="QR kod">QR</button>
<button id="btnCopyBackstage" class="mini ghost" data-i18n="copy">Kopiraj</button>
</div>
<div class="lbl" style="margin-bottom:5px" data-i18n="apiLabel">API (Stream Deck / Companion)</div>
<div class="net-url">
<span id="netApi" style="color:#c9a0ff" data-i18n-title="apiTitle" title="GET komanda za Companion „Generic HTTP“ dugme. type: start · reset · go · blackout · adjust(&value=sek) · setDuration(&value=ms)">—</span>
<button id="btnCopyApi" class="mini ghost" data-i18n="copy">Kopiraj</button>
</div>
<div id="qrBox" class="qrbox"></div>
<button id="btnHideOutputQr" class="danger" style="display:none; width:100%; margin:0 0 8px" data-i18n="hideQrFromScreen">Skloni QR sa ekrana</button>
<button id="btnShare" class="ghost" style="width:100%; margin-top:4px" data-i18n="shareOnline">🌐 Deli online (bilo koja mreža)</button>
<div class="lbl" id="publicLbl" style="display:none; margin:8px 0 5px"><span data-i18n="publicLabel">Javni link (bilo koja mreža)</span><span id="publicProvider"></span></div>
<div class="net-url" id="publicRow" style="display:none">
<span id="netPublic" style="color:#7ee0a0">—</span>
<button class="mini ghost qrbtn" data-qr="netPublic" data-audience-qr="timer" title="QR kod">QR</button>
<button id="btnCopyPublic" class="mini ghost" data-i18n="copy">Kopiraj</button>
</div>
<div class="net-note">
<span class="dot" id="netDot"></span> <span id="netStatus">pokrećem…</span><br>
<span data-i18n-html="netNote">OBS: <b>Browser Source</b> → Ekran URL („Providna pozadina" za overlay; NDI preko DistroAV). Telefon: otvori Daljinski URL u pretraživaču.</span>
<span data-i18n="shareNote" style="display:block; margin-top:5px; color:var(--dim2)">QR = skeniraj telefonom (ista Wi-Fi). „Deli online" = link koji radi sa bilo koje mreže.</span>
</div>
</div>
</div>
</div>
<div id="durationPopover" class="duration-popover" role="dialog" aria-modal="false" aria-labelledby="durationPickerTitle" hidden>
<div class="duration-popover-head">
<div id="durationPickerTitle" class="duration-popover-title" data-i18n="durationPickerTitle">Postavi trajanje</div>
<button id="durationPickerClose" class="duration-close" type="button" data-i18n-title="cancel" title="Otkaži">✕</button>
</div>
<div class="duration-readout">
<div class="duration-unit">
<input id="durationHours" class="duration-segment" type="text" inputmode="numeric" maxlength="2" value="00" autocomplete="off" data-duration-part="hours" data-i18n-title="hours" title="Sati">
<span class="duration-unit-label" data-i18n="hours">Sati</span>
<div class="duration-stepper"><button type="button" data-duration-step="hours" data-delta="-1">−</button><button type="button" data-duration-step="hours" data-delta="1">+</button></div>
</div>
<div class="duration-colon">:</div>
<div class="duration-unit">
<input id="durationMinutes" class="duration-segment" type="text" inputmode="numeric" maxlength="2" value="10" autocomplete="off" data-duration-part="minutes" data-i18n-title="minutes" title="Minuti">
<span class="duration-unit-label" data-i18n="minutes">Minuti</span>
<div class="duration-stepper"><button type="button" data-duration-step="minutes" data-delta="-1">−</button><button type="button" data-duration-step="minutes" data-delta="1">+</button></div>
</div>
<div class="duration-colon">:</div>
<div class="duration-unit">
<input id="durationSeconds" class="duration-segment" type="text" inputmode="numeric" maxlength="2" value="00" autocomplete="off" data-duration-part="seconds" data-i18n-title="seconds" title="Sekunde">
<span class="duration-unit-label" data-i18n="seconds">Sekunde</span>
<div class="duration-stepper"><button type="button" data-duration-step="seconds" data-delta="-1">−</button><button type="button" data-duration-step="seconds" data-delta="1">+</button></div>
</div>
</div>
<div class="duration-presets">
<button type="button" data-duration-preset="1">1m</button><button type="button" data-duration-preset="5">5m</button>
<button type="button" data-duration-preset="10">10m</button><button type="button" data-duration-preset="15">15m</button>
<button type="button" data-duration-preset="30">30m</button><button type="button" data-duration-preset="60">60m</button>
</div>
<button id="durationPickerConfirm" class="primary duration-confirm" type="button" data-i18n="confirmDuration">Potvrdi</button>
<div class="duration-help" data-i18n="durationHelp">Enter potvrđuje · Esc otkazuje</div>
</div>
<div class="statusbar" data-i18n-html="shortcuts">
<kbd>Space</kbd> start/pauza · <kbd>R</kbd> reset · <kbd>N</kbd> sledeći · <kbd>↑↓</kbd> ±1m · <kbd>←→</kbd> ±10s · <kbd>B</kbd> blackout · <kbd>F</kbd> pun ekran · <kbd>M</kbd> poruka · <kbd>C</kbd> obriši poruku
</div>
<script>
const api = window.pt || {
sendState(){}, onState(){}, openOutput(){}, closeOutput(){}, toggleFullscreen(){},
exitFullscreen(){}, setOnTop(){}, getDisplays:async()=>[], isOutputOpen:async()=>false,
getNetworkInfo:async()=>({}), onDisplays(){}, onOutputState(){}, onNetworkInfo(){},
onRemoteCmd(){}, sendToDisplay(){},
qr:async()=>null, shareStart:async()=>({error:'preview'}), shareStop:async()=>true,
shareInfo:async()=>({}), onShareInfo(){}, showOutputQr:async()=>false, hideOutputQr(){}, onOutputQr(){}
};
// ---------- JEZIK / LANGUAGE ----------
const I18N = {
sr: {
outLabel:'Izlaz na', displayTitle:'Monitor za izlazni ekran', sendScreen:'Pošalji na ekran',
fsTitle:'Pun ekran (F)', closeTitle:'Zatvori izlazni prozor', onTop:'Na vrhu',
mode:'Režim', modeCountdown:'Odbrojavanje', modeCountup:'Štoperica', modeClock:'Sat',
set:'Postavi', endAt:'Kraj u', targetTitle:'Izaberi vreme završetka, zatim pokreni velikim START dugmetom',
duration:'Trajanje', durTitle:'Postavi sate, minute i sekunde', quick:'Brzo',
durationPickerTitle:'Postavi trajanje', durationPickerTimer:'Trajanje glavnog tajmera', durationPickerCue:'Trajanje rundown stavke',
hours:'Sati', minutes:'Minuti', seconds:'Sekunde', confirmDuration:'Potvrdi', cancel:'Otkaži',
durationHelp:'Enter potvrđuje · Esc otkazuje', cueDurationTitle:'Postavi trajanje stavke',
colors:'Boje', background:'Pozadina', timeText:'Vreme/tekst', warnColors:'Boje upozorenja',
tagY:'Ž', tagR:'C', yellow:'Žuto', red:'Crveno', transparent:'Providna pozadina (OBS)',
grid:'Grid', gridOn:'Pozicija na ekranu', gridHint:'klikni kockicu →',
fitWindow:'Kompaktan', fitTitle:'Prozor (kad nije pun ekran) prati veličinu tajmera',
text:'Tekst', textPh:'Tekst na ekranu (npr. PAUZA, DOBRO DOŠLI)…', textOnly:'Samo tekst', clear:'Obriši',
thresholds:'Pragovi', yellowAt:'Žuto na', redAt:'Crveno na', flashZero:'Blic na nuli',
sound:'Zvuk', overtime:'Minus posle nule', progress:'Traka napretka',
message:'Poruka', messagePh:'Poruka govorniku… (M za fokus, Enter šalje)', flash:'Treperi', send:'Pošalji',
cueList:'CUE LISTA', cueEmpty:'Nema tačaka. Dodaj naziv + trajanje ↓', namePh:'Naziv',
autoNext:'Auto-prelaz na sledeći', startRundown:'▶ START RUNDOWN', goNext:'GO ▶ SLEDEĆI (N)', noName:'(bez naziva)',
rundown:'RUNDOWN', showStart:'Planirani početak', notePh:'Beleška (opciono)…', nowNextOut:'NOW/NEXT na ekranu',
cueImportNone:'Nijedan red nije prepoznat. Format: naziv, trajanje (10:00), beleška',
backstageLabel:'Backstage (raspored / crew)', onTime:'NA VREME', late:'kasni', early:'ispred',
apiLabel:'API (Stream Deck / Companion)', apiTitle:'GET komanda za Companion „Generic HTTP“ dugme. type: start · reset · go · blackout · adjust(&value=sek) · setDuration(&value=ms)',
nowLabel:'SADA', nextLabel:'SLEDI', endLabel:'Kraj', plannedLabel:'Planirano', projectedLabel:'Procena',
netTitle:'MREŽA → OBS · TELEFON', screenOBS:'Ekran (OBS / monitor)', copy:'Kopiraj',
showQrOnScreen:'Prikaži QR publici', hideQrFromScreen:'Skloni QR sa ekrana',
audienceQrTitle:'Skenirajte za tajmer', audienceQrBackstage:'Skenirajte za backstage',
audienceQrHint:'Otvorite kameru na telefonu i skenirajte kod',
remoteLabel:'Daljinski (telefon / tablet)',
shareOnline:'🌐 Deli online (bilo koja mreža)', publicLabel:'Javni link (bilo koja mreža)',
connecting:'⏳ Povezivanje…', cancelSharing:'✕ Otkaži povezivanje', stopSharing:'✕ Prekini deljenje', shareFail:'⚠ Nije uspelo, pokušaj opet',
shareNote:'QR = skeniraj telefonom (ista Wi-Fi). „Deli online" = link sa bilo koje mreže.',
netNote:'⚠️ Svi uređaji moraju biti na <b>ISTOJ Wi-Fi</b> mreži. OBS: <b>Browser Source</b> → Ekran URL („Providna pozadina" za overlay; NDI preko DistroAV). Telefon: otvori Daljinski URL u pretraživaču. OSC: UDP port <b>7879</b>, adrese <b>/protimer/start</b> · reset · go · blackout · adjust · setDuration.',
start:'▶ START', pause:'⏸ PAUZA', clockBtn:'— SAT —',
outLive:'EKRAN ŽIV', outClosed:'EKRAN ZATVOREN', screenTag:'EKRAN', controlTag:'kontrola',
netOff:'server nije pokrenut', netStarting:'pokrećem…', live:'uživo', deviceOne:'uređaj', deviceMany:'uređaja', connected:'povezano',
shortcuts:'<kbd>Space</kbd> start/pauza · <kbd>R</kbd> reset · <kbd>N</kbd> sledeći · <kbd>↑↓</kbd> ±1m · <kbd>←→</kbd> ±10s · <kbd>B</kbd> blackout · <kbd>F</kbd> pun ekran · <kbd>M</kbd> poruka · <kbd>C</kbd> obriši poruku'
},
en: {
outLabel:'Output to', displayTitle:'Monitor for the output screen', sendScreen:'Send to screen',
fsTitle:'Fullscreen (F)', closeTitle:'Close output window', onTop:'On top',
mode:'Mode', modeCountdown:'Countdown', modeCountup:'Stopwatch', modeClock:'Clock',
set:'Set', endAt:'End at', targetTitle:'Choose an end time, then use the large START button',
duration:'Duration', durTitle:'Set hours, minutes and seconds', quick:'Quick',
durationPickerTitle:'Set duration', durationPickerTimer:'Main timer duration', durationPickerCue:'Rundown item duration',
hours:'Hours', minutes:'Minutes', seconds:'Seconds', confirmDuration:'Confirm', cancel:'Cancel',
durationHelp:'Enter confirms · Esc cancels', cueDurationTitle:'Set item duration',
colors:'Colors', background:'Background', timeText:'Time/text', warnColors:'Warning colors',
tagY:'Y', tagR:'R', yellow:'Yellow', red:'Red', transparent:'Transparent background (OBS)',
grid:'Grid', gridOn:'Position on screen', gridHint:'click a cell →',
fitWindow:'Compact', fitTitle:'When not fullscreen, the window follows the timer size',
text:'Text', textPh:'On-screen text (e.g. BREAK, WELCOME)…', textOnly:'Text only', clear:'Clear',
thresholds:'Warnings', yellowAt:'Yellow at', redAt:'Red at', flashZero:'Flash at zero',
sound:'Sound', overtime:'Count past zero', progress:'Progress bar',
message:'Message', messagePh:'Message to speaker… (M to focus, Enter sends)', flash:'Flash', send:'Send',
cueList:'CUE LIST', cueEmpty:'No items. Add name + duration ↓', namePh:'Name',
autoNext:'Auto-advance to next', startRundown:'▶ START RUNDOWN', goNext:'GO ▶ NEXT (N)', noName:'(no name)',
rundown:'RUNDOWN', showStart:'Planned start', notePh:'Note (optional)…', nowNextOut:'NOW/NEXT on screen',
cueImportNone:'No rows recognized. Format: name, duration (10:00), note',
backstageLabel:'Backstage (schedule / crew)', onTime:'ON TIME', late:'behind', early:'ahead',
apiLabel:'API (Stream Deck / Companion)', apiTitle:'GET command for a Companion "Generic HTTP" button. type: start · reset · go · blackout · adjust(&value=sec) · setDuration(&value=ms)',
nowLabel:'NOW', nextLabel:'NEXT', endLabel:'End', plannedLabel:'Planned', projectedLabel:'Projected',
netTitle:'NETWORK → OBS · PHONE', screenOBS:'Screen (OBS / monitor)', copy:'Copy',
showQrOnScreen:'Show QR to audience', hideQrFromScreen:'Hide QR from screen',
audienceQrTitle:'Scan to follow the timer', audienceQrBackstage:'Scan for backstage',
audienceQrHint:'Open your phone camera and scan the code',
remoteLabel:'Remote (phone / tablet)',
shareOnline:'🌐 Share online (any network)', publicLabel:'Public link (any network)',
connecting:'⏳ Connecting…', cancelSharing:'✕ Cancel connection', stopSharing:'✕ Stop sharing', shareFail:'⚠ Failed, try again',
shareNote:'QR = scan with a phone (same Wi-Fi). “Share online” = a link that works from any network.',
netNote:'⚠️ All devices must be on the <b>SAME Wi-Fi</b> network. OBS: <b>Browser Source</b> → Screen URL (enable “Transparent background” for overlay; NDI via DistroAV). Phone: open the Remote URL in a browser. OSC: UDP port <b>7879</b>, addresses <b>/protimer/start</b> · reset · go · blackout · adjust · setDuration.',
start:'▶ START', pause:'⏸ PAUSE', clockBtn:'— CLOCK —',
outLive:'SCREEN LIVE', outClosed:'SCREEN CLOSED', screenTag:'SCREEN', controlTag:'control',
netOff:'server not running', netStarting:'starting…', live:'live', deviceOne:'device', deviceMany:'devices', connected:'connected',
shortcuts:'<kbd>Space</kbd> start/pause · <kbd>R</kbd> reset · <kbd>N</kbd> next · <kbd>↑↓</kbd> ±1m · <kbd>←→</kbd> ±10s · <kbd>B</kbd> blackout · <kbd>F</kbd> fullscreen · <kbd>M</kbd> message · <kbd>C</kbd> clear message'
}
};
let lang = localStorage.getItem('pt_lang') || 'sr';
function t(key){ return (I18N[lang] && I18N[lang][key]) ?? I18N.sr[key] ?? key; }
function applyLang(){
document.documentElement.lang = lang;
document.querySelectorAll('[data-i18n]').forEach(el => el.textContent = t(el.dataset.i18n));
document.querySelectorAll('[data-i18n-ph]').forEach(el => el.placeholder = t(el.dataset.i18nPh));
document.querySelectorAll('[data-i18n-title]').forEach(el => el.title = t(el.dataset.i18nTitle));
document.querySelectorAll('[data-i18n-html]').forEach(el => el.innerHTML = t(el.dataset.i18nHtml));
document.querySelectorAll('.lang button').forEach(b => b.classList.toggle('active', b.dataset.lang===lang));
updateButtons(); renderCues(); showNet(lastNetInfo); fillDisplays(lastDisplays);
if(typeof applyShare==='function') applyShare({ url: publicUrl, starting: shareStarting, provider: shareProvider });
}
// ---------- STANJE ----------
let S = {
mode:'countdown', running:false,
durationMs:600000, remMs:600000, endAt:0, elapsedMs:0, startAt:0,
yellowSec:120, redSec:60,
flashZero:true, soundZero:false, overtime:true, showProgress:false,
message:{text:'', flash:false}, blackout:false,
// izgled
bgColor:'#000000', fgColor:'#ffffff', useWarnColors:true,
warnYellow:'#ffc23a', warnRed:'#ff4540',
text:'', textOnly:false, transparent:false,
// grid pozicioniranje tajmera na ekranu
gridOn:false, gridSize:3, gridCell:4,
// kompaktan prozor (prozor prati veličinu tajmera kad nije fullscreen)
fitWindow:false,
// rundown / raspored
cues:[], currentCue:-1, showStart:'', showNowNext:false,
lang:lang
};
let lastNetInfo = null, lastDisplays = [];
let cues = [], currentCue = -1, autoNext = false, zeroFired = false, outputOpen = false;
let autoAdvanceTimer = null;
let cueDraftMs = 600000, durationPickerTarget = null, durationPickerAnchor = null, targetArmed = false;
const $ = id => document.getElementById(id);
function pad(n){ return String(n).padStart(2,'0'); }
function fmtSecs(s,neg){ const h=Math.floor(s/3600),m=Math.floor((s%3600)/60),x=s%60;
return (neg?'−':'')+(h>0?`${h}:${pad(m)}:${pad(x)}`:`${m}:${pad(x)}`); }
function fmtMs(ms){ return ms>=0?fmtSecs(Math.ceil(ms/1000),false):fmtSecs(Math.floor(-ms/1000),true); }
function parseTime(str){
str=(str||'').trim().replace(',',':').replace('.',':');
if(!str) return null;
if(/^\d+$/.test(str)) return +str*60000;
const p=str.split(':').map(Number);
if(p.some(isNaN)) return null;
if(p.length===2) return (p[0]*60+p[1])*1000;
if(p.length===3) return (p[0]*3600+p[1]*60+p[2])*1000;
return null;
}
function formatDurationHMS(ms){
const total=Math.max(0,Math.round((Number(ms)||0)/1000));
const h=Math.floor(total/3600),m=Math.floor((total%3600)/60),s=total%60;
return `${String(h).padStart(2,'0')}:${pad(m)}:${pad(s)}`;
}
function syncDurationDisplays(){
if($('durTriggerValue')) $('durTriggerValue').textContent=formatDurationHMS(S.durationMs);
if($('cueDurationValue')) $('cueDurationValue').textContent=formatDurationHMS(cueDraftMs);
}
function clearTargetArm(clearValue){
targetArmed=false;
if($('targetInput')){
$('targetInput').classList.remove('armed');
if(clearValue) $('targetInput').value='';
}
}
function durationUntilTarget(value,now){
if(!value) return null;
const parts=value.split(':').map(Number); if(parts.length<2||parts.some(Number.isNaN)) return null;
const d=new Date(now); d.setHours(parts[0],parts[1],0,0); if(d.getTime()<=now) d.setDate(d.getDate()+1);
return d.getTime()-now;
}
function send(){ S.cues=cues; S.currentCue=currentCue; syncDurationDisplays(); api.sendState(S); saveSettings(); }
// ---------- RASPORED / OVER-UNDER ----------
function todayAt(hhmm, now){
if(!hhmm) return null;
const [h,m]=hhmm.split(':').map(Number);
if(isNaN(h)||isNaN(m)) return null;
const d=new Date(now); d.setHours(h,m,0,0); return d.getTime();
}
function schedule(now){
const list=cues||[]; const anchor=todayAt(S.showStart, now);
let acc=anchor;
const rows=list.map((c,i)=>{ const start=acc; const end=acc==null?null:acc+c.durationMs; acc=end;
return {name:c.name,durationMs:c.durationMs,note:c.note||'',color:c.color||'',plannedStart:start,plannedEnd:end,index:i}; });
let curRem=null;
if(currentCue>=0 && S.mode==='countdown') curRem=S.running?S.endAt-now:S.remMs;
let delta=null, plannedEnd=null;
const total=list.reduce((a,c)=>a+c.durationMs,0);
if(anchor!=null){ plannedEnd=anchor+total;
if(currentCue>=0 && curRem!=null){
const sumAfter=list.slice(currentCue+1).reduce((a,c)=>a+c.durationMs,0);
delta=(now+Math.max(0,curRem)+sumAfter)-plannedEnd;
}
}
return {rows,curRem,delta,plannedEnd};
}
// ---------- TAJMER ----------
function cancelAutoAdvance(){
if(autoAdvanceTimer!==null){ clearTimeout(autoAdvanceTimer); autoAdvanceTimer=null; }
}
function startPause(){
cancelAutoAdvance();
if(!S.running&&targetArmed){
const targetMs=durationUntilTarget($('targetInput').value,Date.now());
if(targetMs!==null&&targetMs>0){ targetArmed=false; $('targetInput').classList.remove('armed'); setDuration(targetMs,true); }
}
const now=Date.now();
if(S.mode==='clock') return;
if(S.running){
// countup broji naviše; sve ostalo (i countdown) računa preko endAt — usklađeno sa calc()
if(S.mode==='countup') S.elapsedMs+=now-S.startAt; else S.remMs=S.endAt-now;
S.running=false;
} else {
if(S.mode==='countup') S.startAt=now;
else { S.endAt=now+S.remMs; if(S.remMs>0) zeroFired=false; }
S.running=true;
}
send(); updateButtons();
}
function reset(){ cancelAutoAdvance(); clearTargetArm(true); S.running=false; S.remMs=S.durationMs; S.elapsedMs=0; zeroFired=false; send(); updateButtons(); }
function setDuration(ms,keepTarget=false){ cancelAutoAdvance(); if(!keepTarget) clearTargetArm(true); S.mode='countdown'; S.durationMs=ms; S.remMs=ms; S.running=false; zeroFired=false; setModeTabs(); send(); updateButtons(); }
function adjust(sec){
if(S.mode!=='countdown') return;
cancelAutoAdvance(); clearTargetArm(true);
const d=sec*1000;
if(S.running) S.endAt+=d; else S.remMs=Math.max(0,S.remMs+d);
S.durationMs=Math.max(1000,S.durationMs+d);
if((S.running?S.endAt-Date.now():S.remMs)>0) zeroFired=false;
send();
}
function setMode(m){ if(!['countdown','countup','clock'].includes(m)) return; cancelAutoAdvance(); clearTargetArm(true); S.mode=m; S.running=false; S.remMs=S.durationMs; S.elapsedMs=0; zeroFired=false; setModeTabs(); send(); updateButtons(); }
function setModeTabs(){ document.querySelectorAll('.tabs button').forEach(b=>b.classList.toggle('active',b.dataset.mode===S.mode)); }
// ---------- ZVUK ----------
function beep(){
try{
const ctx=new AudioContext(), t=ctx.currentTime;
[0,.25,.5].forEach((off,i)=>{ const o=ctx.createOscillator(),g=ctx.createGain();
o.frequency.value=i===2?1318:880; o.connect(g); g.connect(ctx.destination);
g.gain.setValueAtTime(.0001,t+off); g.gain.exponentialRampToValueAtTime(.5,t+off+.02);
g.gain.exponentialRampToValueAtTime(.0001,t+off+.22); o.start(t+off); o.stop(t+off+.25); });
setTimeout(()=>ctx.close(),1200);
}catch(e){}
}
// ---------- RENDER (ogledalo izlaza) ----------
function calc(now){
if(S.mode==='clock'){ const d=new Date(); return {text:`${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`,fg:S.fgColor,neg:false,prog:null,rem:null}; }
if(S.mode==='countup'){ const el=S.running?S.elapsedMs+(now-S.startAt):S.elapsedMs; return {text:fmtSecs(Math.floor(el/1000),false),fg:S.fgColor,neg:false,prog:null,rem:null}; }
let rem=S.running?S.endAt-now:S.remMs;
if(!S.overtime&&rem<0) rem=0;
let fg=S.fgColor, neg=false;
if(S.useWarnColors){ if(rem<=S.redSec*1000) fg=S.warnRed; else if(rem<=S.yellowSec*1000) fg=S.warnYellow; }
if(rem<0){ fg=S.warnRed; neg=true; }
const prog=S.durationMs>0?Math.max(0,Math.min(1,rem/S.durationMs)):0;
return {text:fmtMs(rem),fg,neg,prog,rem};
}
let lastKey='';
function render(){
const now=Date.now(), r=calc(now);
const pv=$('preview');
// pozadina
if(S.transparent){ $('pvChecker').style.display='block'; pv.style.background='transparent'; }
else { $('pvChecker').style.display='none'; pv.style.background=S.bgColor; }
const textOnly = S.textOnly && S.text;
const txtEl=$('pvText'), tEl=$('pvTime'), ps=$('pvStage');
// GRID pomera i menja veličinu samo pravog izlaznog prozora. Operaterski
// pregled ostaje preko cele površine da bi vreme uvek bilo čitljivo.
const sw=ps.clientWidth||pv.clientWidth, sh=ps.clientHeight||pv.clientHeight;
if(S.text){
txtEl.style.display='block'; txtEl.textContent=S.text; txtEl.style.color=r.fg;
txtEl.style.fontSize = textOnly
? Math.min(sw*0.85/Math.max(6,S.text.length*0.55), sh*0.42)+'px'
: Math.min(sh*0.13, sw*0.06)+'px';
txtEl.style.marginBottom = textOnly?'0':(sh*0.025)+'px';
} else txtEl.style.display='none';
if(textOnly){ tEl.style.display='none'; }
else {
tEl.style.display='block'; tEl.textContent=r.text; tEl.style.color=r.fg;
tEl.className='pv-time'+(r.neg?' neg':'');
const key=r.text.length+'|'+Math.round(sw)+'x'+Math.round(sh)+'|'+(S.text?1:0);
if(key!==lastKey){ lastKey=key;
const avail=S.text?sh*0.42:sh*0.55;
tEl.style.fontSize=Math.min(sw*0.9/(r.text.length*0.6),avail)+'px'; }
}
const m=$('pvMsg');
if(S.message.text){ m.style.display='block'; m.textContent=S.message.text; m.style.color=r.fg; m.className='pv-msg'+(S.message.flash?' flash':''); }
else m.style.display='none';
const p=$('pvProg');
if(S.showProgress&&r.prog!==null){ p.style.display='block'; p.style.width=(r.prog*100)+'%'; p.style.background=r.fg; }
else p.style.display='none';
$('bdgBk').classList.toggle('bk',S.blackout);
$('bdgOut').classList.toggle('on',outputOpen);
$('bdgOut').textContent=outputOpen?t('outLive'):t('outClosed');
// over / under raspored
const sch=schedule(now); const ou=$('ouStatus');
if(sch.delta==null){ ou.textContent=''; ou.className='ou'; }
else { const sec=Math.round(sch.delta/1000);
if(Math.abs(sec)<=5){ ou.textContent=t('onTime'); ou.className='ou ontime'; }
else if(sec>0){ ou.textContent='▲ '+fmtSecs(sec,false); ou.className='ou late'; ou.title=t('late'); }
else { ou.textContent='▼ '+fmtSecs(-sec,false); ou.className='ou early'; ou.title=t('early'); }
}
if(S.mode==='countdown'&&S.running&&r.rem!==null&&r.rem<=0&&!zeroFired){
zeroFired=true;
if(S.soundZero) beep();
if(autoNext&¤tCue>=0&¤tCue+1<cues.length){
const nextCue=currentCue+1;
autoAdvanceTimer=setTimeout(()=>{ autoAdvanceTimer=null; loadCue(nextCue,true); },800);
}
}
requestAnimationFrame(render);
}
function updateButtons(){
const b=$('btnStart');
if(S.mode==='clock'){ b.textContent=t('clockBtn'); b.classList.remove('running'); return; }
if(S.running){ b.textContent=t('pause'); b.classList.add('running'); }
else { b.textContent=t('start'); b.classList.remove('running'); }
}
// ---------- RUNDOWN ----------
function clock(ms){ const d=new Date(ms); return pad(d.getHours())+':'+pad(d.getMinutes()); }
function renderCues(){
const el=$('cueList'); el.innerHTML='';
$('btnRundownStart').disabled=!cues.length;
$('btnGo').disabled=!cues.length||currentCue>=cues.length-1;
if(!cues.length){ const d=document.createElement('div'); d.className='empty'; d.textContent=t('cueEmpty'); el.appendChild(d); return; }
const sch=schedule(Date.now());
cues.forEach((c,i)=>{
const pr=sch.rows[i];
const row=document.createElement('div');
row.className='cue'+(i===currentCue?' current':'');
const times = pr.plannedStart!=null
? `${clock(pr.plannedStart)}–${clock(pr.plannedEnd)}<div class="du">${fmtMs(c.durationMs)}</div>`
: `<div class="du">${fmtMs(c.durationMs)}</div>`;
row.innerHTML=`${c.color?`<span class="stripe" style="background:${c.color}"></span>`:''}<span class="n">${i+1}</span>`+
`<div class="body"><div class="nm"></div>${c.note?'<div class="note"></div>':''}</div>`+
`<span class="times">${times}</span>`+
`<button class="mini up">▲</button><button class="mini dn">▼</button><button class="mini del">✕</button>`;
row.querySelector('.nm').textContent=c.name||t('noName');
if(c.note) row.querySelector('.note').textContent=c.note;
row.addEventListener('click',e=>{ if(e.target.tagName!=='BUTTON') loadCue(i,false); });
row.querySelector('.up').addEventListener('click',()=>moveCue(i,-1));
row.querySelector('.dn').addEventListener('click',()=>moveCue(i,1));
row.querySelector('.del').addEventListener('click',()=>{
cancelAutoAdvance();
cues.splice(i,1);
if(i<currentCue) currentCue--;
else if(i===currentCue) currentCue=-1;
saveCues(); send(); renderCues();
});
el.appendChild(row);
});
}
function loadCue(i,autostart){ if(i<0||i>=cues.length) return; cancelAutoAdvance(); currentCue=i; setDuration(cues[i].durationMs); if(autostart) startPause(); renderCues(); }
function moveCue(i,dir){ const j=i+dir; if(j<0||j>=cues.length) return; [cues[i],cues[j]]=[cues[j],cues[i]];
if(currentCue===i) currentCue=j; else if(currentCue===j) currentCue=i; saveCues(); send(); renderCues(); }
function startRundown(){ cancelAutoAdvance(); if(cues.length) loadCue(0,true); }
function go(){ cancelAutoAdvance(); if(currentCue+1<cues.length) loadCue(currentCue+1,true); }
// ---------- ČUVANJE ----------
function saveCues(){ localStorage.setItem('pt_cues',JSON.stringify(cues)); }
function saveSettings(){
localStorage.setItem('pt_settings',JSON.stringify({
yellowSec:S.yellowSec,redSec:S.redSec,flashZero:S.flashZero,soundZero:S.soundZero,
overtime:S.overtime,showProgress:S.showProgress,durationMs:S.durationMs,autoNext,
bgColor:S.bgColor,fgColor:S.fgColor,useWarnColors:S.useWarnColors,
warnYellow:S.warnYellow,warnRed:S.warnRed,textOnly:S.textOnly,transparent:S.transparent,
showStart:S.showStart,showNowNext:S.showNowNext,
gridOn:S.gridOn,gridSize:S.gridSize,gridCell:S.gridCell,fitWindow:S.fitWindow
}));
}
function load(){
try{
const st=JSON.parse(localStorage.getItem('pt_settings')||'{}');
Object.assign(S,{
yellowSec:st.yellowSec??S.yellowSec, redSec:st.redSec??S.redSec,
flashZero:st.flashZero??S.flashZero, soundZero:st.soundZero??S.soundZero,
overtime:st.overtime??S.overtime, showProgress:st.showProgress??S.showProgress,
durationMs:st.durationMs??S.durationMs,
bgColor:st.bgColor??S.bgColor, fgColor:st.fgColor??S.fgColor,
useWarnColors:st.useWarnColors??S.useWarnColors,
warnYellow:st.warnYellow??S.warnYellow, warnRed:st.warnRed??S.warnRed,
textOnly:st.textOnly??S.textOnly, transparent:st.transparent??S.transparent,
showStart:st.showStart??S.showStart, showNowNext:st.showNowNext??S.showNowNext,
gridOn:st.gridOn??S.gridOn, gridSize:st.gridSize??S.gridSize, gridCell:st.gridCell??S.gridCell,
fitWindow:st.fitWindow??S.fitWindow
});
S.remMs=S.durationMs; autoNext=!!st.autoNext;
cues=JSON.parse(localStorage.getItem('pt_cues')||'[]');
}catch(e){}
$('showStartInput').value=S.showStart||''; $('chkNowNext').checked=S.showNowNext;
$('yellowInput').value=fmtSecs(S.yellowSec,false);
$('redInput').value=fmtSecs(S.redSec,false);
$('chkFlash').checked=S.flashZero; $('chkSound').checked=S.soundZero;
$('chkOver').checked=S.overtime; $('chkProg').checked=S.showProgress;
$('chkAuto').checked=autoNext; cueDraftMs=S.durationMs;
$('bgColor').value=S.bgColor; $('fgColor').value=S.fgColor;
$('chkWarn').checked=S.useWarnColors; $('warnYellow').value=S.warnYellow; $('warnRed').value=S.warnRed;
$('chkTextOnly').checked=S.textOnly; $('chkTransparent').checked=S.transparent;
$('chkFit').checked=S.fitWindow;
syncDurationDisplays();
buildGrid();
renderCues();
}
// ---------- MONITORI ----------
function fillDisplays(list){
lastDisplays = list || [];
const sel=$('displaySel'); sel.innerHTML='';
lastDisplays.forEach(d=>{
const o=document.createElement('option'); o.value=d.id;
const tag=d.hasOutput?` — ${t('screenTag')}`:(d.hasControl?` — ${t('controlTag')}`:'');
o.textContent=`${d.label} (${d.width}×${d.height})${tag}`;
if(d.hasOutput||(!d.hasControl&&lastDisplays.length>1)) o.selected=true;
sel.appendChild(o);
});
}
async function refreshDisplays(){ fillDisplays(await api.getDisplays()); }
api.onDisplays(fillDisplays);
// ---------- MREŽA ----------
let netUrl='', remoteUrl='', backstageUrl='', apiUrl='';
function showNet(info){
lastNetInfo = info;
if(!info||!info.running){ $('netUrl').textContent='—'; $('netRemote').textContent='—'; $('netBackstage').textContent='—'; $('netApi').textContent='—'; $('netStatus').textContent=t('netOff'); $('netDot').classList.remove('on'); return; }
netUrl=`http://${info.ip}:${info.port}`;
remoteUrl=`${netUrl}/remote${info.token?`?t=${info.token}`:''}`;
backstageUrl=`${netUrl}/backstage`;
apiUrl=`${netUrl}/cmd?type=start${info.token?`&t=${info.token}`:''}`;
$('netUrl').textContent=netUrl;
$('netRemote').textContent=remoteUrl;
$('netBackstage').textContent=backstageUrl;
$('netApi').textContent=apiUrl;
$('netDot').classList.add('on');
const word = info.clients===1?t('deviceOne'):t('deviceMany');
$('netStatus').textContent=`${t('live')} · ${info.clients} ${word} ${t('connected')}`;
}
api.onNetworkInfo(showNet);
api.getNetworkInfo().then(showNet).catch(()=>{});
function copyBtn(btn, getUrl){ btn.addEventListener('click',()=>{ const u=getUrl(); if(u){ navigator.clipboard.writeText(u); const o=btn.textContent; btn.textContent='✓'; setTimeout(()=>btn.textContent=o,1200); } }); }
copyBtn($('btnCopyUrl'), ()=>netUrl);
copyBtn($('btnCopyRemote'), ()=>remoteUrl);
copyBtn($('btnCopyBackstage'), ()=>backstageUrl);
copyBtn($('btnCopyApi'), ()=>apiUrl);
// ---------- QR KOD ----------
let qrShownFor='', audienceQrShownFor='';
function applyOutputQrState(info){
audienceQrShownFor=(info&&info.url)||'';
$('btnHideOutputQr').style.display=audienceQrShownFor?'block':'none';
}
api.onOutputQr(applyOutputQrState);
document.querySelectorAll('.qrbtn').forEach(b=>b.addEventListener('click',async ()=>{
const url=$(b.dataset.qr).textContent.trim();
const box=$('qrBox');
if(!url||url==='—') return;
if(qrShownFor===url && box.style.display==='block'){ box.style.display='none'; qrShownFor=''; return; }
const svg=await api.qr(url);
if(svg){
box.innerHTML=svg;
const lbl=document.createElement('div'); lbl.className='qrlbl'; lbl.textContent=url; box.appendChild(lbl);
if(b.dataset.audienceQr){
const action=document.createElement('button'); action.type='button'; action.className='primary audience-qr-action'; action.textContent=t('showQrOnScreen');
action.addEventListener('click',async ()=>{
const backstage=b.dataset.audienceQr==='backstage';
const ok=await api.showOutputQr({url,label:t(backstage?'audienceQrBackstage':'audienceQrTitle'),hint:t('audienceQrHint'),displayId:+$('displaySel').value||null});
if(ok!==false) applyOutputQrState({url});
});
box.appendChild(action);
}
box.style.display='block'; qrShownFor=url; box.scrollIntoView({block:'nearest'});
}
}));
$('btnHideOutputQr').addEventListener('click',()=>{ api.hideOutputQr(); applyOutputQrState(null); });
// ---------- JAVNI LINK (tunel) ----------
let publicUrl='', shareStarting=false, shareProvider=null;
function applyShare(info){
publicUrl = (info&&info.url)||'';
shareStarting = !!(info&&info.starting);
shareProvider = (info&&info.provider)||null;
$('publicProvider').textContent=shareProvider==='cloudflare'?' · CLOUDFLARE':(shareProvider==='localtunnel'?' · FALLBACK':'');
if(publicUrl){
$('publicLbl').style.display='block'; $('publicRow').style.display='flex';
$('netPublic').textContent=publicUrl; $('btnShare').textContent=t('stopSharing'); $('btnShare').classList.add('on');
} else if(shareStarting){
$('btnShare').textContent=t('cancelSharing'); $('btnShare').classList.remove('on');
} else {
$('publicLbl').style.display='none'; $('publicRow').style.display='none';
$('btnShare').textContent=t('shareOnline'); $('btnShare').classList.remove('on');
if(qrShownFor && qrShownFor===$('netPublic').textContent){ $('qrBox').style.display='none'; }
}
}
api.onShareInfo(applyShare);
api.shareInfo().then(applyShare).catch(()=>{});
$('btnShare').addEventListener('click',async ()=>{
if(publicUrl||shareStarting){ await api.shareStop(); return; }
$('btnShare').textContent=t('connecting'); $('btnShare').disabled=true;
const start=api.shareStart();
// pushShare() vraća dugme čim start zaista krene; ostavi veoma kratak guard protiv double-clicka.
setTimeout(()=>{ $('btnShare').disabled=false; },150);
const r=await start; $('btnShare').disabled=false;