-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1130 lines (987 loc) · 42.1 KB
/
index.html
File metadata and controls
1130 lines (987 loc) · 42.1 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="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<title>RollCall</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/quagga/0.12.1/quagga.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Barlow:wght@400;500;600&display=swap');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #29353C;
--surface: #344550;
--card: #3D5166;
--border: #768A96;
--accent: #AAC7D8;
--green: #5BAD8F;
--yellow: #D4A843;
--red: #C0544A;
--text: #E6E6E6;
--muted: #AAC7D8;
--radius: 16px;
}
html, body {
min-height: 100vh;
background: var(--bg);
color: var(--text);
font-family: 'Barlow', sans-serif;
/* Removed overflow: hidden so the page can actually scroll */
}
.screen {
display: none;
flex-direction: column;
min-height: 100vh; /* Ensures short screens still fill the viewport */
/* Removed position: fixed and internal overflow rules */
}
.screen.active { display: flex; }
/* ── WELCOME / FIRST-TIME SETUP ── */
#welcomeScreen {
padding: 60px 28px 60px;
gap: 0;
justify-content: flex-start;
}
.welcome-eyebrow {
font-family: 'Barlow Condensed', sans-serif;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.2em;
color: var(--accent);
text-transform: uppercase;
margin-bottom: 10px;
}
.welcome-title {
font-family: 'Barlow Condensed', sans-serif;
font-size: 52px;
font-weight: 800;
line-height: 0.95;
letter-spacing: -0.01em;
margin-bottom: 12px;
}
.welcome-title span {
color: var(--accent);
}
.welcome-desc {
font-size: 15px;
color: var(--muted);
line-height: 1.6;
margin-bottom: 32px;
max-width: 340px;
}
.welcome-features {
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 32px;
}
.feature-row {
display: flex;
align-items: flex-start;
gap: 12px;
}
.feature-icon {
font-size: 20px;
flex-shrink: 0;
margin-top: 1px;
}
.feature-text {
font-size: 14px;
color: var(--muted);
line-height: 1.4;
}
.feature-text strong {
color: var(--text);
font-weight: 600;
}
.welcome-divider {
border: none;
border-top: 1px solid var(--border);
margin: 8px 0 24px;
}
.welcome-setup-label {
font-family: 'Barlow Condensed', sans-serif;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.14em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 10px;
}
/* ── SETUP SCREEN (settings) ── */
#setupScreen {
padding: 52px 24px 60px;
gap: 18px;
justify-content: flex-start;
}
.setup-header {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 4px;
}
.setup-back {
color: var(--accent);
font-size: 15px;
font-weight: 600;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.setup-title-text {
font-family: 'Barlow Condensed', sans-serif;
font-size: 26px;
font-weight: 800;
}
.setup-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 18px;
display: flex;
flex-direction: column;
gap: 12px;
}
.setup-card h3 {
font-family: 'Barlow Condensed', sans-serif;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--muted);
}
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label {
font-size: 11px;
font-weight: 600;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.input-group input {
background: var(--surface);
border: 1.5px solid var(--border);
border-radius: 10px;
color: var(--text);
font-family: 'Barlow', sans-serif;
font-size: 13px;
padding: 12px 14px;
outline: none;
width: 100%;
-webkit-appearance: none;
appearance: none;
transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--accent); }
.hint {
font-size: 11px;
color: var(--muted);
line-height: 1.5;
}
/* ── ACCORDION ── */
.accordion {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
}
.accordion-header {
padding: 14px 16px;
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
font-size: 14px;
font-weight: 600;
}
.accordion-arrow { transition: transform 0.2s; font-size: 12px; color: var(--muted); }
.accordion.open .accordion-arrow { transform: rotate(180deg); }
.accordion-body { display: none; padding: 0 16px 16px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.accordion.open .accordion-body { display: block; }
.step { display: flex; gap: 10px; margin-bottom: 10px; }
.step-num {
background: var(--accent); color: white; border-radius: 50%;
width: 22px; height: 22px; display: flex; align-items: center;
justify-content: center; font-size: 11px; font-weight: 700;
flex-shrink: 0; margin-top: 1px;
}
.code-block {
background: #AAC7D810; border: 1px solid #AAC7D822;
border-radius: 8px; padding: 10px 12px;
font-family: 'Courier New', monospace; font-size: 11px;
color: #AAC7D8; margin: 8px 0; white-space: pre-wrap; word-break: break-all;
}
/* ── BUTTONS ── */
.btn {
display: flex; align-items: center; justify-content: center; gap: 8px;
border: none; border-radius: 14px;
font-family: 'Barlow Condensed', sans-serif; font-size: 17px;
font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
padding: 16px 20px; cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: opacity 0.15s, transform 0.1s; width: 100%;
}
.btn:active { opacity: 0.8; transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #29353C; }
.btn-green { background: var(--green); color: #29353C; }
.btn-ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
/* ── SCANNER SCREEN ── */
#scanScreen {
position: fixed;
inset: 0;
overflow: hidden;
z-index: 10;
background: var(--bg); /* Prevents background bleed */
}
#cameraView { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#cameraView video { width: 100% !important; height: 100% !important; object-fit: cover !important; }
#cameraView canvas { display: none; }
.scan-overlay {
position: absolute; inset: 0; display: flex;
flex-direction: column; align-items: center;
justify-content: center; pointer-events: none;
}
.scan-frame { width: 260px; height: 160px; position: relative; }
.scan-frame::before, .scan-frame::after,
.scan-frame .c3, .scan-frame .c4 {
content: ''; position: absolute; width: 28px; height: 28px;
border-color: white; border-style: solid;
}
.scan-frame::before { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scan-frame::after { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.scan-frame .c3 { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.scan-frame .c4 { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
.scan-line {
position: absolute; left: 8px; right: 8px; height: 2px;
background: linear-gradient(90deg, transparent, var(--accent), transparent);
animation: scanline 2s ease-in-out infinite;
}
@keyframes scanline {
0% { top: 10px; opacity: 0; }
10% { opacity: 1; }
90% { opacity: 1; }
100% { top: 148px; opacity: 0; }
}
.scan-hint-text {
color: white; font-size: 14px; font-weight: 600;
margin-top: 24px; text-shadow: 0 1px 6px rgba(0,0,0,0.8);
letter-spacing: 0.03em;
}
.scan-top-bar {
position: absolute; top: 0; left: 0; right: 0;
padding: 52px 20px 16px;
background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
display: flex; align-items: center; justify-content: space-between; z-index: 10;
}
.scan-title-bar {
font-family: 'Barlow Condensed', sans-serif;
font-size: 22px; font-weight: 800; color: white; letter-spacing: 0.04em;
}
.scan-title-bar span {
color: var(--accent);
}
.icon-btn {
background: rgba(255,255,255,0.15); backdrop-filter: blur(6px);
border: none; border-radius: 50%; width: 38px; height: 38px;
display: flex; align-items: center; justify-content: center;
color: white; font-size: 16px; cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.scan-bottom-bar {
position: absolute; bottom: 0; left: 0; right: 0;
padding: 16px 20px 40px;
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
display: flex; flex-direction: column; gap: 10px; z-index: 10;
}
.manual-btn {
background: rgba(255,255,255,0.12); backdrop-filter: blur(8px);
border: 1px solid rgba(255,255,255,0.2); border-radius: 14px;
color: white; font-family: 'Barlow Condensed', sans-serif;
font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
text-transform: uppercase; padding: 14px; cursor: pointer;
-webkit-tap-highlight-color: transparent; text-align: center;
}
/* ── CONFIRM SCREEN ── */
#confirmScreen { padding: 52px 20px 60px; gap: 16px; }
.confirm-back {
display: flex; align-items: center; gap: 8px;
color: var(--accent); font-size: 15px; font-weight: 600;
cursor: pointer; -webkit-tap-highlight-color: transparent; margin-bottom: 4px;
}
.confirm-card {
background: var(--card); border: 1px solid var(--border);
border-radius: var(--radius); padding: 20px;
}
.confirm-label {
font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.confirm-paper {
font-family: 'Barlow Condensed', sans-serif;
font-size: 26px; font-weight: 800; line-height: 1.1; margin-bottom: 6px;
}
.confirm-barcode { font-size: 12px; color: var(--muted); font-family: monospace; }
.confirm-section-tag {
display: inline-block; font-size: 11px; font-weight: 700;
letter-spacing: 0.08em; text-transform: uppercase;
padding: 3px 10px; border-radius: 20px; margin-top: 10px;
}
.tag-24 { background: #44576D55; color: #AAC7D8; border: 1px solid #768A96; }
.tag-36 { background: #3D6655; color: #5BAD8F; border: 1px solid #4A8A70; }
.tag-bp { background: #6B571E44; color: #D4A843; border: 1px solid #8A7230; }
.qty-section {
background: var(--card); border: 1px solid var(--border);
border-radius: var(--radius); padding: 20px;
display: flex; flex-direction: column; gap: 12px;
}
.qty-label {
font-family: 'Barlow Condensed', sans-serif;
font-size: 13px; font-weight: 700; letter-spacing: 0.1em;
text-transform: uppercase; color: var(--muted);
}
.qty-controls { display: flex; align-items: center; gap: 16px; }
.qty-stepper {
background: var(--surface); border: none; border-radius: 12px;
width: 52px; height: 52px; font-size: 26px; color: var(--text);
cursor: pointer; display: flex; align-items: center; justify-content: center;
-webkit-tap-highlight-color: transparent; flex-shrink: 0;
}
.qty-input {
flex: 1; background: var(--surface); border: 2px solid var(--accent);
border-radius: 14px; color: var(--text);
font-family: 'Barlow Condensed', sans-serif;
font-size: 42px; font-weight: 800; text-align: center;
padding: 10px; outline: none;
-webkit-appearance: none; appearance: none;
}
.max-hint { font-size: 12px; color: var(--muted); text-align: center; }
.status-preview {
display: flex; align-items: center; justify-content: center;
gap: 8px; padding: 12px; border-radius: 10px;
font-size: 14px; font-weight: 600; transition: all 0.3s;
}
.status-ok { background: #2A5C4422; color: var(--green); border: 1px solid #3D7A5A44; }
.status-low { background: #5C481A22; color: var(--yellow); border: 1px solid #8A703044; }
.status-empty { background: #5C2A2A22; color: var(--red); border: 1px solid #8A404044; }
.status-none { background: var(--surface); color: var(--muted); }
/* ── SUCCESS SCREEN ── */
#successScreen {
align-items: center; justify-content: center;
gap: 20px; padding: 40px 24px; text-align: center;
}
.success-icon {
width: 80px; height: 80px; background: var(--green);
border-radius: 50%; display: flex; align-items: center;
justify-content: center; font-size: 36px;
animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop {
from { transform: scale(0); opacity: 0; }
to { transform: scale(1); opacity: 1; }
}
.success-title { font-family: 'Barlow Condensed', sans-serif; font-size: 32px; font-weight: 800; }
.success-detail { font-size: 15px; color: var(--muted); line-height: 1.6; }
/* ── MANUAL SCREEN ── */
#manualScreen { padding: 52px 20px 60px; gap: 16px; }
.paper-list { display: flex; flex-direction: column; gap: 8px; }
.paper-item {
background: var(--card); border: 1px solid var(--border);
border-radius: 12px; padding: 14px 16px;
display: flex; align-items: center; gap: 12px;
cursor: pointer; -webkit-tap-highlight-color: transparent;
transition: border-color 0.15s;
}
.paper-item:active { border-color: var(--accent); }
.paper-item-name { font-size: 14px; font-weight: 600; line-height: 1.2; flex: 1; }
.paper-item-tag {
font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
text-transform: uppercase; padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
}
.section-divider {
font-family: 'Barlow Condensed', sans-serif;
font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
text-transform: uppercase; color: var(--muted); padding: 4px 0;
}
/* ── UNKNOWN BARCODE ── */
.unknown-card {
background: #C0544A18; border: 1px solid #C0544A66;
border-radius: var(--radius); padding: 20px;
display: flex; flex-direction: column; gap: 14px;
}
.unknown-title {
font-family: 'Barlow Condensed', sans-serif;
font-size: 20px; font-weight: 800; color: var(--red);
}
.unknown-code {
font-family: monospace; font-size: 13px; color: var(--muted);
background: var(--surface); padding: 8px 12px;
border-radius: 8px; text-align: center;
}
.register-label {
font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
}
.register-select {
background: var(--surface); border: 1.5px solid var(--border);
border-radius: 10px; color: var(--text);
font-family: 'Barlow', sans-serif; font-size: 15px;
padding: 13px 14px; outline: none; width: 100%;
-webkit-appearance: none; appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6355' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
background-repeat: no-repeat; background-position: right 14px center; cursor: pointer;
}
.register-select:focus { border-color: var(--accent); }
.register-select option { background: #344550; color: #E6E6E6; }
.btn-register {
background: var(--accent); color: #29353C; border: none;
border-radius: 12px; font-family: 'Barlow Condensed', sans-serif;
font-size: 16px; font-weight: 700; letter-spacing: 0.04em;
text-transform: uppercase; padding: 14px; cursor: pointer;
-webkit-tap-highlight-color: transparent; transition: opacity 0.15s; width: 100%;
}
.btn-register:active { opacity: 0.8; }
.btn-register:disabled { opacity: 0.4; }
/* ── TOAST ── */
.toast {
position: fixed; bottom: 30px; left: 50%;
transform: translateX(-50%) translateY(80px);
background: #44576D; color: #E6E6E6; border: 1px solid #768A96;
padding: 12px 20px;
border-radius: 30px; font-size: 14px; font-weight: 600;
z-index: 999; transition: transform 0.3s ease;
white-space: nowrap; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
</style>
</head>
<body>
<!-- ══════════════════════════════════════════════ -->
<!-- WELCOME / FIRST-TIME SETUP SCREEN -->
<!-- ══════════════════════════════════════════════ -->
<div id="welcomeScreen" class="screen active">
<div class="welcome-eyebrow">Print Shop Inventory</div>
<div class="welcome-title">Roll<span>Call</span></div>
<div class="welcome-desc">Scan a barcode, enter the quantity, and your Google Sheet updates instantly.</div>
<div class="welcome-features">
<div class="feature-row">
<div class="feature-icon">📷</div>
<div class="feature-text"><strong>Barcode scanning</strong> — point your camera at any paper roll and it's identified automatically</div>
</div>
<div class="feature-row">
<div class="feature-icon">📊</div>
<div class="feature-text"><strong>Live Google Sheet sync</strong> — quantities update in real time with 🟢 OK / 🟡 Low / 🔴 Order Now status</div>
</div>
<div class="feature-row">
<div class="feature-icon">🏷️</div>
<div class="feature-text"><strong>Register new barcodes on the spot</strong> — unknown rolls get a dropdown to assign and save instantly</div>
</div>
</div>
<hr class="welcome-divider">
<div class="welcome-setup-label">Connect your Google Sheet to get started</div>
<div class="setup-card">
<h3>Your Apps Script URL</h3>
<div class="input-group">
<label>Web App URL</label>
<input type="url" id="welcomeScriptUrl"
placeholder="https://script.google.com/macros/s/..."
autocomplete="off" autocorrect="off" spellcheck="false">
</div>
<div class="hint">Paste the URL from your Google Apps Script deployment. See the setup guide below if you haven't done this yet.</div>
</div>
<div class="accordion" id="welcomeAccordion">
<div class="accordion-header" onclick="toggleWelcomeAccordion()">
<span>📋 How to set up Google Sheets</span>
<span class="accordion-arrow">▼</span>
</div>
<div class="accordion-body">
<div class="step"><div class="step-num">1</div><div>Create a new Google Sheet. Name the first sheet tab <strong>Inventory</strong>. Set up columns: A = section, B = paper name, C = max, D = qty.</div></div>
<div class="step"><div class="step-num">2</div><div>Go to <strong>Extensions → Apps Script</strong>. Delete any existing code and paste the script below.</div></div>
<div class="code-block">const SHEET_NAME = "Inventory";
function doPost(e) {
try {
const data = JSON.parse(e.postData.contents);
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName(SHEET_NAME);
const values = sheet.getDataRange().getValues();
for (let r = 0; r < values.length; r++) {
for (let c = 0; c < values[r].length; c++) {
const cell = String(values[r][c]).trim();
const searchName = String(data.name || '').trim();
if (cell === searchName || cell.includes(searchName)) {
sheet.getRange(r + 1, 4).setValue(data.qty);
return ContentService
.createTextOutput(JSON.stringify({ status: "ok", row: r + 1 }))
.setMimeType(ContentService.MimeType.JSON);
}
}
}
return ContentService
.createTextOutput(JSON.stringify({ status: "not_found" }))
.setMimeType(ContentService.MimeType.JSON);
} catch(err) {
return ContentService
.createTextOutput(JSON.stringify({ status: "error", message: err.toString() }))
.setMimeType(ContentService.MimeType.JSON);
}
}</div>
<div class="step"><div class="step-num">3</div><div>Click <strong>Deploy → New deployment</strong>. Type: <strong>Web app</strong>. Execute as: <strong>Me</strong>. Who has access: <strong>Anyone</strong>. Click Deploy.</div></div>
<div class="step"><div class="step-num">4</div><div>Copy the <strong>Web app URL</strong> and paste it in the field above.</div></div>
</div>
</div>
<button class="btn btn-primary" onclick="completeWelcomeSetup()">
✓ Let's Go
</button>
</div>
<!-- ══════════════════════════════════════════════ -->
<!-- SCAN SCREEN -->
<!-- ══════════════════════════════════════════════ -->
<div id="scanScreen" class="screen">
<div id="cameraView"></div>
<div class="scan-overlay">
<div class="scan-frame">
<div class="c3"></div><div class="c4"></div>
<div class="scan-line"></div>
</div>
<div class="scan-hint-text">Point camera at barcode</div>
</div>
<div class="scan-top-bar">
<div class="scan-title-bar">Roll<span>Call</span></div>
<button class="icon-btn" onclick="goToSetup()">⚙️</button>
</div>
<div class="scan-bottom-bar">
<button class="manual-btn" onclick="showManual()">
📋 Select Paper Manually
</button>
</div>
</div>
<!-- ══════════════════════════════════════════════ -->
<!-- CONFIRM / QUANTITY SCREEN -->
<!-- ══════════════════════════════════════════════ -->
<div id="confirmScreen" class="screen">
<div class="confirm-back" onclick="backToScan()">← Back to Scanner</div>
<div class="confirm-card">
<div class="confirm-label">Paper Identified</div>
<div class="confirm-paper" id="confirmPaperName">—</div>
<div class="confirm-barcode" id="confirmBarcode"></div>
<div id="confirmTag" class="confirm-section-tag tag-24">24″ Roll</div>
</div>
<div class="unknown-card" id="unknownCard" style="display:none;">
<div class="unknown-title">⚠ New Barcode Scanned</div>
<div id="unknownCode" class="unknown-code"></div>
<div style="font-size:13px;color:var(--muted);line-height:1.5;">
This barcode isn't registered yet. Pick the paper type below to save it — it'll be recognized automatically next time.
</div>
<div>
<div class="register-label">Which paper is this?</div>
<select class="register-select" id="registerSelect" onchange="onRegisterSelectChange()">
<option value="">— Select paper type —</option>
<optgroup label="Blueprint Paper (Max: 4)">
<option value="20 lb Bond (24")|BP|4">20 lb Bond (24″)</option>
<option value="20 lb Bond (36")|BP|4">20 lb Bond (36″)</option>
</optgroup>
<optgroup label="24″ Rolls (Max: 2)">
<option value="Universal Heavyweight|24|2">Universal Heavyweight</option>
<option value="Super Heavyweight|24|2">Super Heavyweight</option>
<option value="Photo Gloss|24|2">Photo Gloss</option>
<option value="Photo Satin|24|2">Photo Satin</option>
<option value="Matte Polypropylene|24|2">Matte Polypropylene</option>
<option value="Scrim Vinyl|24|2">Scrim Vinyl</option>
</optgroup>
<optgroup label="36″ Rolls (Max: 4)">
<option value="Universal Heavyweight|36|4">Universal Heavyweight</option>
<option value="Super Heavyweight|36|4">Super Heavyweight</option>
<option value="Photo Gloss|36|4">Photo Gloss</option>
<option value="Photo Satin|36|4">Photo Satin</option>
<option value="Matte Polypropylene|36|4">Matte Polypropylene</option>
<option value="Scrim Vinyl|36|4">Scrim Vinyl</option>
<option value="Wrapping Paper (30")|36|4">Wrapping Paper (30″)</option>
</optgroup>
</select>
</div>
<button class="btn-register" id="registerBtn" onclick="registerBarcode()" disabled>
+ Register & Set Quantity
</button>
</div>
<div class="qty-section" id="qtySection">
<div class="qty-label">Set Quantity on Hand</div>
<div class="qty-controls">
<button class="qty-stepper" onclick="changeQty(-1)">−</button>
<input type="number" class="qty-input" id="qtyInput" value="0" min="0" max="99"
inputmode="numeric" oninput="updateStatusPreview()">
<button class="qty-stepper" onclick="changeQty(1)">+</button>
</div>
<div class="max-hint" id="maxHint">Max capacity: —</div>
<div class="status-preview status-none" id="statusPreview">Enter quantity above</div>
</div>
<button class="btn btn-green" id="saveBtn" onclick="saveQty()">
↑ Update Google Sheet
</button>
<button class="btn btn-ghost" onclick="backToScan()">Cancel</button>
</div>
<!-- ══════════════════════════════════════════════ -->
<!-- SUCCESS SCREEN -->
<!-- ══════════════════════════════════════════════ -->
<div id="successScreen" class="screen">
<div class="success-icon">✓</div>
<div class="success-title">Sheet Updated!</div>
<div class="success-detail" id="successDetail">Quantity saved successfully.</div>
<button class="btn btn-primary" onclick="backToScan()" style="width:100%;max-width:320px;">Scan Another</button>
<button class="btn btn-ghost" onclick="goToSetup()" style="width:100%;max-width:320px;">Settings</button>
</div>
<!-- ══════════════════════════════════════════════ -->
<!-- MANUAL SELECT SCREEN -->
<!-- ══════════════════════════════════════════════ -->
<div id="manualScreen" class="screen">
<div class="confirm-back" onclick="backToScan()">← Back to Scanner</div>
<div style="font-family:'Barlow Condensed',sans-serif;font-size:22px;font-weight:800;margin-bottom:4px;">Select Paper</div>
<div style="font-size:13px;color:var(--muted);margin-bottom:8px;">Tap to choose paper type manually</div>
<div class="paper-list" id="paperList"></div>
</div>
<!-- ══════════════════════════════════════════════ -->
<!-- SETTINGS SCREEN -->
<!-- ══════════════════════════════════════════════ -->
<div id="setupScreen" class="screen">
<div class="setup-header">
<div class="setup-back" onclick="backToScan()">← Back</div>
<div class="setup-title-text">Settings</div>
</div>
<div class="setup-card">
<h3>Apps Script URL</h3>
<div class="input-group">
<label>Web App URL</label>
<input type="url" id="scriptUrl"
placeholder="https://script.google.com/macros/s/..."
autocomplete="off" autocorrect="off" spellcheck="false">
</div>
<div class="hint">Update this if you redeploy your Apps Script.</div>
</div>
<div class="setup-card">
<h3>Registered Barcodes</h3>
<div class="hint" id="barcodeCountHint">Loading...</div>
<button class="btn btn-ghost" style="font-size:14px;padding:12px;" onclick="clearBarcodes()">
🗑 Clear All Registered Barcodes
</button>
</div>
<button class="btn btn-primary" onclick="saveSettings()">
✓ Save Settings
</button>
<div class="accordion" id="settingsAccordion">
<div class="accordion-header" onclick="toggleSettingsAccordion()">
<span>📋 Apps Script setup guide</span>
<span class="accordion-arrow">▼</span>
</div>
<div class="accordion-body">
<div class="step"><div class="step-num">1</div><div>Go to your Google Sheet → <strong>Extensions → Apps Script</strong></div></div>
<div class="step"><div class="step-num">2</div><div>Paste the script, then go to <strong>Deploy → Manage deployments</strong> → pencil icon → set version to <strong>New version</strong> → Deploy.</div></div>
<div class="step"><div class="step-num">3</div><div>Make sure <strong>Execute as: Me</strong> and <strong>Who has access: Anyone</strong>.</div></div>
</div>
</div>
</div>
<div class="toast" id="toast"></div>
<script>
// ── CONFIG ───────────────────────────────────────
// This is intentionally blank for the public version.
// Each user pastes their own Apps Script URL on first launch.
let APPS_SCRIPT_URL = '';
// ── STATE ────────────────────────────────────────
let state = {
barcodeMap: [],
currentPaper: null,
scannedBarcode: '',
};
// ── MASTER PAPER LIST ────────────────────────────
const MASTER_PAPERS = [
{ name: '20 lb Bond (24")', section: 'BP', max: 4 },
{ name: '20 lb Bond (36")', section: 'BP', max: 4 },
{ name: 'Universal Heavyweight', section: '24', max: 2 },
{ name: 'Super Heavyweight', section: '24', max: 2 },
{ name: 'Photo Gloss', section: '24', max: 2 },
{ name: 'Photo Satin', section: '24', max: 2 },
{ name: 'Matte Polypropylene', section: '24', max: 2 },
{ name: 'Scrim Vinyl', section: '24', max: 2 },
{ name: 'Universal Heavyweight', section: '36', max: 4 },
{ name: 'Super Heavyweight', section: '36', max: 4 },
{ name: 'Photo Gloss', section: '36', max: 4 },
{ name: 'Photo Satin', section: '36', max: 4 },
{ name: 'Matte Polypropylene', section: '36', max: 4 },
{ name: 'Scrim Vinyl', section: '36', max: 4 },
{ name: 'Wrapping Paper (30")', section: '36', max: 4 },
];
// ── PERSIST ──────────────────────────────────────
function saveToStorage() {
localStorage.setItem('rc_scriptUrl', APPS_SCRIPT_URL);
localStorage.setItem('rc_barcodeMap', JSON.stringify(state.barcodeMap));
}
function loadFromStorage() {
const url = localStorage.getItem('rc_scriptUrl');
const map = localStorage.getItem('rc_barcodeMap');
if (map) {
try { state.barcodeMap = JSON.parse(map); } catch(e) { state.barcodeMap = []; }
}
if (url) {
APPS_SCRIPT_URL = url;
// Already configured — go straight to scanner
showScreen('scanScreen');
startCamera();
} else {
// First time — show welcome screen
showScreen('welcomeScreen');
}
}
// ── WELCOME SETUP ────────────────────────────────
function completeWelcomeSetup() {
const url = document.getElementById('welcomeScriptUrl').value.trim();
if (!url || !url.startsWith('https://script.google.com')) {
showToast('Please paste a valid Apps Script URL');
return;
}
APPS_SCRIPT_URL = url;
saveToStorage();
showScreen('scanScreen');
startCamera();
}
// ── SETTINGS ────────────────────────────────────
function goToSetup() {
stopCamera();
document.getElementById('scriptUrl').value = APPS_SCRIPT_URL;
const count = state.barcodeMap.length;
document.getElementById('barcodeCountHint').textContent =
count === 0 ? 'No barcodes registered yet.' : `${count} barcode${count === 1 ? '' : 's'} registered on this device.`;
showScreen('setupScreen');
}
function saveSettings() {
const url = document.getElementById('scriptUrl').value.trim();
if (!url || !url.startsWith('https://script.google.com')) {
showToast('Please enter a valid Apps Script URL');
return;
}
APPS_SCRIPT_URL = url;
saveToStorage();
showToast('✓ Settings saved');
backToScan();
}
function clearBarcodes() {
if (!confirm('Clear all registered barcodes? This cannot be undone.')) return;
state.barcodeMap = [];
saveToStorage();
showToast('✓ Barcodes cleared');
document.getElementById('barcodeCountHint').textContent = 'No barcodes registered yet.';
}
// ── SCREENS ──────────────────────────────────────
function showScreen(id) {
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
document.getElementById(id).classList.add('active');
}
// ── CAMERA / QUAGGA ──────────────────────────────
let scannerRunning = false;
let lastScan = '';
let lastScanTime = 0;
function startCamera() {
if (scannerRunning) return;
Quagga.init({
inputStream: {
name: 'Live', type: 'LiveStream',
target: document.getElementById('cameraView'),
constraints: { facingMode: 'environment', width: { ideal: 1280 }, height: { ideal: 720 } },
},
decoder: {
readers: ['ean_reader','ean_8_reader','upc_reader','upc_e_reader','code_128_reader','code_39_reader'],
multiple: false,
},
locate: true,
frequency: 10,
}, (err) => {
if (err) { showToast('Camera error — use manual mode'); return; }
Quagga.start();
scannerRunning = true;
});
Quagga.onDetected((result) => {
const code = result.codeResult.code;
const now = Date.now();
if (code === lastScan && now - lastScanTime < 2000) return;
lastScan = code;
lastScanTime = now;
if (navigator.vibrate) navigator.vibrate(60);
handleBarcode(code);
});
}
function stopCamera() {
if (!scannerRunning) return;
Quagga.stop();
scannerRunning = false;
}
// ── BARCODE HANDLING ─────────────────────────────
function handleBarcode(code) {
state.scannedBarcode = code;
const match = state.barcodeMap.find(b => b.barcode === code);
stopCamera();
if (match) { state.currentPaper = match; showConfirm(match, code); }
else { showConfirm(null, code); }
}
function showConfirm(paper, barcode) {
showScreen('confirmScreen');
const unknownCard = document.getElementById('unknownCard');
const qtySection = document.getElementById('qtySection');
const saveBtn = document.getElementById('saveBtn');
if (paper) {
unknownCard.style.display = 'none';
qtySection.style.display = 'flex';
saveBtn.style.display = 'flex';
document.getElementById('confirmPaperName').textContent = paper.name;
document.getElementById('confirmBarcode').textContent = `Barcode: ${barcode}`;
const tag = document.getElementById('confirmTag');
tag.style.display = 'inline-block';
if (paper.section === '24') { tag.className = 'confirm-section-tag tag-24'; tag.textContent = '24″ Roll'; }
else if (paper.section === '36') { tag.className = 'confirm-section-tag tag-36'; tag.textContent = '36″ Roll'; }
else { tag.className = 'confirm-section-tag tag-bp'; tag.textContent = 'Blueprint'; }
document.getElementById('maxHint').textContent = `Max capacity: ${paper.max} rolls`;
document.getElementById('qtyInput').value = 0;
updateStatusPreview();
} else {
unknownCard.style.display = 'flex';
qtySection.style.display = 'none';
saveBtn.style.display = 'none';
document.getElementById('confirmPaperName').textContent = 'Unknown Barcode';
document.getElementById('confirmBarcode').textContent = '';
document.getElementById('confirmTag').style.display = 'none';
document.getElementById('unknownCode').textContent = barcode;
document.getElementById('registerSelect').value = '';
document.getElementById('registerBtn').disabled = true;
}
}
// ── QTY ──────────────────────────────────────────
function changeQty(delta) {
const input = document.getElementById('qtyInput');
input.value = Math.max(0, (parseInt(input.value) || 0) + delta);
updateStatusPreview();
}
function updateStatusPreview() {
const qty = parseInt(document.getElementById('qtyInput').value) || 0;
const preview = document.getElementById('statusPreview');
const max = state.currentPaper ? state.currentPaper.max : 99;
if (qty === 0) { preview.className = 'status-preview status-empty'; preview.textContent = '🔴 Order Now — 0 in stock'; }
else if (qty === 1) { preview.className = 'status-preview status-low'; preview.textContent = '🟡 Low — only 1 left'; }
else { preview.className = 'status-preview status-ok'; preview.textContent = `🟢 OK — ${qty} of ${max} in stock`; }
}
// ── SAVE ─────────────────────────────────────────
async function saveQty() {
const qty = parseInt(document.getElementById('qtyInput').value) || 0;
const paper = state.currentPaper;
if (!paper) return;
const saveBtn = document.getElementById('saveBtn');