-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
1444 lines (1312 loc) · 60.5 KB
/
Copy pathadmin.html
File metadata and controls
1444 lines (1312 loc) · 60.5 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">
<title>Hull Chores — Admin</title>
<meta name="theme-color" content="#0f0f1a">
<link rel="manifest" href="manifest.json">
<link rel="icon" href="icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="icon.svg">
<link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
:root { --bg: #0f0f1a; --card: #1a1a2e; --accent: #667eea; --radius: 16px; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Nunito', sans-serif; background: var(--bg); color: #e0e0e0; min-height: 100vh; padding: 24px 16px; }
/* ---- PIN SCREEN ---- */
#pin-screen {
display: flex; flex-direction: column; align-items: center; justify-content: center;
min-height: 100vh; gap: 20px;
}
#pin-screen h1 { font-family: 'Fredoka One', cursive; font-size: 2rem; color: #fff; }
#pin-screen p { color: #888; font-size: 0.95rem; }
.pin-dots { display: flex; gap: 14px; margin: 8px 0; }
.pin-dot {
width: 18px; height: 18px; border-radius: 50%;
border: 2.5px solid #444; background: transparent; transition: all 0.15s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; max-width: 260px; width: 100%; }
.pin-btn {
padding: 18px; border-radius: 14px; border: none;
background: #1e1e30; color: #fff; font-family: 'Fredoka One', cursive;
font-size: 1.4rem; cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.pin-btn:hover { background: #2a2a40; }
.pin-btn:active { transform: scale(0.94); background: var(--accent); }
.pin-btn.clear { background: #2a1a1a; color: #f5576c; }
.pin-error { color: #f5576c; font-weight: 700; font-size: 0.9rem; animation: shake 0.3s ease; max-width: 320px; text-align: center; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.signin-btn {
display: inline-flex; align-items: center; gap: 10px; padding: 14px 26px;
border-radius: 50px; border: none; cursor: pointer; margin-top: 8px;
background: #fff; color: #222; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1rem;
}
.signin-btn:hover { opacity: 0.9; }
.signin-btn:disabled { opacity: 0.5; cursor: default; }
/* ---- ADMIN BOARD ---- */
#admin-board { display: none; }
.page-header {
display: flex; align-items: center; justify-content: space-between;
margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-family: 'Fredoka One', cursive; font-size: clamp(1.6rem,4vw,2.4rem); color: #fff; }
.page-header a {
padding: 8px 18px; border-radius: 50px; background: #1e1e30;
color: #aaa; text-decoration: none; font-weight: 700; font-size: 0.85rem;
transition: background 0.15s;
}
.page-header a:hover { background: #2a2a40; color: #fff; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card {
background: var(--card); border-radius: var(--radius);
padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.stat-card h3 { font-family: 'Fredoka One', cursive; font-size: 1.1rem; color: #ccc; margin-bottom: 14px; }
.big-stat { font-family: 'Fredoka One', cursive; font-size: 3rem; color: #fff; line-height: 1; }
.big-stat-label { font-size: 0.8rem; color: #666; font-weight: 700; margin-top: 4px; }
/* Kid completion bars */
.kid-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.kid-bar-name { font-size: 0.85rem; font-weight: 800; color: #ccc; width: 70px; flex-shrink: 0; }
.kid-bar-track { flex: 1; height: 10px; background: #2a2a3a; border-radius: 5px; overflow: hidden; }
.kid-bar-fill { height: 100%; border-radius: 5px; transition: width 0.6s ease; }
.kid-bar-pct { font-size: 0.8rem; font-weight: 800; color: #888; width: 36px; text-align: right; flex-shrink: 0; }
/* Weekly trend chart */
.trend-wrap { overflow-x: auto; }
.trend-chart { display: flex; align-items: flex-end; gap: 6px; min-height: 120px; padding-bottom: 24px; position: relative; min-width: max-content; }
.trend-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trend-bar {
width: 32px; border-radius: 6px 6px 0 0;
background: linear-gradient(180deg, #667eea, #764ba2);
transition: height 0.5s ease; min-height: 2px; position: relative; cursor: pointer;
}
.trend-bar:hover::after {
content: attr(data-tip);
position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
background: #333; color: #fff; font-size: 10px; font-weight: 700;
padding: 3px 7px; border-radius: 6px; white-space: nowrap; margin-bottom: 4px;
}
.trend-bar.saturday { background: linear-gradient(180deg,#f7971e,#ffd200); }
.trend-bar.sunday { background: linear-gradient(180deg,#667eea,#764ba2); }
.trend-label { font-size: 9px; font-weight: 700; color: #555; text-align: center; }
/* Per-chore completion */
.chore-stat-row {
display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
padding: 6px 8px; border-radius: 8px; background: #13131f;
}
.chore-stat-icon { font-size: 1rem; flex-shrink: 0; }
.chore-stat-label { flex: 1; font-size: 0.82rem; font-weight: 700; color: #bbb; }
.chore-stat-bar-track { width: 80px; height: 6px; background: #2a2a3a; border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.chore-stat-bar-fill { height: 100%; border-radius: 3px; background: #43e97b; }
.chore-stat-pct { font-size: 0.75rem; font-weight: 800; color: #666; width: 32px; text-align: right; flex-shrink: 0; }
/* Streaks */
.streak-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.streak-name { font-size: 0.9rem; font-weight: 800; color: #ccc; }
.streak-val { font-family: 'Fredoka One', cursive; font-size: 1.3rem; color: #f7971e; }
.streak-fire { font-size: 1rem; }
/* Reset section */
.danger-zone { background: #1a0f0f; border: 1px solid #3a1a1a; border-radius: var(--radius); padding: 20px; margin-top: 8px; }
.danger-zone h3 { font-family: 'Fredoka One', cursive; color: #f5576c; margin-bottom: 12px; }
.danger-zone p { font-size: 0.85rem; color: #888; margin-bottom: 14px; }
.reset-select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #3a1a1a; background: #120808; color: #ccc; font-family: 'Nunito', sans-serif; font-weight: 700; margin-bottom: 10px; }
.reset-btn-danger {
padding: 10px 22px; border-radius: 50px; border: none;
background: linear-gradient(135deg,#f5576c,#c0392b); color: white;
font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 0.9rem;
cursor: pointer; transition: opacity 0.15s;
}
.reset-btn-danger:hover { opacity: 0.85; }
.loading-msg { text-align: center; color: #555; font-weight: 700; padding: 40px; }
/* Section headers */
.section-title {
font-family: 'Fredoka One', cursive; font-size: 1.3rem; color: #fff;
margin: 28px 0 14px; display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: #2a2a3a; }
/* Kid color map */
.bar-theodore { background: linear-gradient(90deg,#667eea,#764ba2); }
.bar-alice { background: linear-gradient(90deg,#f093fb,#f5576c); }
.bar-andrew { background: linear-gradient(90deg,#4facfe,#00f2fe); }
.bar-felix { background: linear-gradient(90deg,#43e97b,#38f9d7); }
.bar-lucy { background: linear-gradient(90deg,#fa709a,#fee140); }
.bar-leo { background: linear-gradient(90deg,#f7971e,#ffd200); }
/* ---- MANAGE / DRAG-AND-DROP ---- */
.manage-controls { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin-bottom:14px; }
.manage-controls select {
padding:9px 12px; border-radius:10px; border:1px solid #2a2a3a;
background:#13131f; color:#ddd; font-family:'Nunito',sans-serif; font-weight:700;
}
#manageStatus { font-size:0.82rem; font-weight:800; color:#888; }
#manageStatus.dirty { color:#f7971e; }
#manageStatus.saved { color:#43e97b; }
.away-row { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.away-chip {
display:flex; align-items:center; gap:6px; padding:7px 13px; border-radius:50px;
background:#1e1e30; color:#bbb; font-weight:800; font-size:0.85rem; cursor:pointer;
border:1px solid #2a2a3a; user-select:none; transition:all 0.15s;
}
.away-chip:hover { background:#2a2a40; }
.away-chip.away { background:#3a2a10; color:#f7971e; border-color:#5a3a10; }
.manage-board { display:flex; gap:14px; overflow-x:auto; padding-bottom:10px; }
.kid-col {
background:var(--card); border-radius:var(--radius); padding:14px;
min-width:230px; width:230px; flex-shrink:0; display:flex; flex-direction:column; gap:10px;
}
.kid-col-head { display:flex; align-items:center; gap:8px; font-weight:800; color:#fff; font-size:1rem; }
.kid-col-head .ct { margin-left:auto; font-size:0.78rem; color:#777; font-weight:800; }
.kid-col.col-theodore { border-top:3px solid #667eea; }
.kid-col.col-alice { border-top:3px solid #f093fb; }
.kid-col.col-andrew { border-top:3px solid #4facfe; }
.kid-col.col-felix { border-top:3px solid #43e97b; }
.kid-col.col-lucy { border-top:3px solid #fa709a; }
.kid-col.col-leo { border-top:3px solid #f7971e; }
.card-list { display:flex; flex-direction:column; gap:7px; min-height:40px; }
.card-list:empty::after {
content:'Drop chores here'; display:block; text-align:center; color:#555;
font-size:0.78rem; font-weight:700; padding:14px 4px; border:1px dashed #2a2a3a; border-radius:10px;
}
.chore-card {
display:flex; align-items:center; gap:8px; padding:9px 10px; border-radius:10px;
background:#13131f; border:1px solid #232336; cursor:grab; touch-action:none;
}
.chore-card:active { cursor:grabbing; }
.chore-card .cc-icon { font-size:1.1rem; flex-shrink:0; }
.chore-card .cc-label { flex:1; font-size:0.85rem; font-weight:700; color:#ddd; line-height:1.2; }
.chore-card .cc-tod {
font-size:0.62rem; font-weight:800; text-transform:uppercase; letter-spacing:0.04em;
padding:2px 6px; border-radius:6px; background:#2a2a3a; color:#9aa; flex-shrink:0;
}
.chore-card .cc-tod.morning { background:#2a2410; color:#f7c54e; }
.chore-card .cc-tod.afternoon { background:#10242a; color:#4fd0fe; }
.chore-card .cc-tod.evening { background:#1a1030; color:#a98bff; }
.chore-card .cc-del {
border:none; background:transparent; color:#666; font-size:1rem; cursor:pointer;
padding:0 2px; flex-shrink:0;
}
.chore-card .cc-del:hover { color:#f5576c; }
.sortable-ghost { opacity:0.4; }
.sortable-chosen { box-shadow:0 0 0 2px var(--accent); }
.add-chore-btn {
border:1px dashed #2a2a3a; background:transparent; color:#888; border-radius:10px;
padding:8px; font-weight:800; font-size:0.8rem; cursor:pointer; font-family:'Nunito',sans-serif;
}
.add-chore-btn:hover { color:#fff; border-color:var(--accent); }
.manage-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:16px; }
.save-btn {
padding:11px 26px; border-radius:50px; border:none; cursor:pointer;
background:linear-gradient(135deg,#43e97b,#38a169); color:#06210f;
font-family:'Nunito',sans-serif; font-weight:800; font-size:0.92rem;
}
.save-btn:hover { opacity:0.9; }
.ghost-btn {
padding:11px 22px; border-radius:50px; border:1px solid #2a2a3a; cursor:pointer;
background:#1a1a2a; color:#aaa; font-family:'Nunito',sans-serif; font-weight:800; font-size:0.88rem;
}
.ghost-btn:hover { background:#24243a; color:#fff; }
/* ---- DEFAULTS EDITOR ---- */
.hint { font-size:0.82rem; color:#777; margin:-4px 0 14px; }
.dt-tabs { display:flex; gap:8px; margin-bottom:16px; flex-wrap:wrap; }
.dt-tab {
padding:9px 16px; border-radius:50px; border:1px solid #2a2a3a; cursor:pointer;
background:#1a1a2a; color:#aaa; font-family:'Nunito',sans-serif; font-weight:800; font-size:0.85rem;
}
.dt-tab.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.tod-group { margin-bottom:18px; }
.tod-group h4 {
font-family:'Fredoka One',cursive; font-size:0.95rem; color:#bbb; margin-bottom:8px;
display:flex; align-items:center; gap:6px;
}
.rule-row {
display:flex; align-items:center; gap:8px; padding:9px 11px; border-radius:10px;
background:#13131f; border:1px solid #232336; margin-bottom:7px;
}
.rule-main { flex:1; min-width:0; }
.rule-label { font-size:0.88rem; font-weight:700; color:#ddd; }
.rule-who { font-size:0.74rem; font-weight:700; color:#7a86b6; margin-top:2px; }
.rule-row .rr-btn {
border:none; background:transparent; color:#666; font-size:0.95rem; cursor:pointer; padding:2px 4px;
}
.rule-row .rr-btn:hover { color:#fff; }
.rule-row .rr-btn.del:hover { color:#f5576c; }
.rotate-tag {
display:inline-block; font-size:0.62rem; font-weight:800; text-transform:uppercase;
padding:1px 6px; border-radius:6px; background:#2a2440; color:#a98bff; margin-right:6px; vertical-align:middle;
}
/* ---- MODAL ---- */
.modal-overlay {
display:none; position:fixed; inset:0; background:rgba(0,0,0,0.6);
align-items:center; justify-content:center; z-index:1000; padding:16px;
}
.modal-overlay.open { display:flex; }
.modal {
background:var(--card); border-radius:var(--radius); padding:22px; width:100%; max-width:440px;
max-height:88vh; overflow-y:auto; box-shadow:0 10px 50px rgba(0,0,0,0.5);
}
.modal h3 { font-family:'Fredoka One',cursive; color:#fff; margin-bottom:16px; }
.modal label { display:block; font-size:0.78rem; font-weight:800; color:#9aa; margin:12px 0 5px; }
.modal input[type=text], .modal select {
width:100%; padding:9px 11px; border-radius:9px; border:1px solid #2a2a3a;
background:#13131f; color:#eee; font-family:'Nunito',sans-serif; font-weight:700; font-size:0.9rem;
}
.chk-row { display:flex; flex-wrap:wrap; gap:7px; }
.chk {
display:flex; align-items:center; gap:5px; padding:6px 11px; border-radius:50px;
background:#13131f; border:1px solid #2a2a3a; cursor:pointer; font-size:0.8rem; font-weight:700; color:#bbb; user-select:none;
}
.chk.on { background:#1e2a4a; border-color:var(--accent); color:#cdd; }
.icon-input { display:flex; gap:8px; align-items:center; }
.icon-input input { width:70px; text-align:center; font-size:1.2rem; }
.rot-chore { display:flex; gap:6px; align-items:center; margin-bottom:6px; }
.rot-chore input.lbl { flex:1; }
.rot-chore input.ico { width:56px; text-align:center; }
.rot-chore button, .add-row-btn {
border:none; background:#2a2a3a; color:#ccc; border-radius:8px; padding:7px 10px; cursor:pointer; font-weight:800;
}
.modal-actions { display:flex; gap:10px; margin-top:20px; }
.small-note { font-size:0.74rem; color:#666; margin-top:6px; line-height:1.4; }
/* ---- QUICK ADD ---- */
.quick-add { display:flex; gap:8px; align-items:stretch; }
.quick-add input {
flex:1; min-width:0; padding:13px 14px; border-radius:12px; border:1px solid #2a2a3a;
background:#13131f; color:#eee; font-family:'Nunito',sans-serif; font-weight:700; font-size:1rem;
}
.qa-mic, .qa-go {
border:none; border-radius:12px; cursor:pointer; font-family:'Nunito',sans-serif; font-weight:800;
padding:0 16px; font-size:1rem; flex-shrink:0;
}
.qa-mic { background:#1e1e30; color:#ccc; font-size:1.3rem; min-width:52px; }
.qa-mic.listening { background:#3a1530; color:#ff6ba8; animation:pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.qa-go { background:linear-gradient(135deg,#43e97b,#38a169); color:#06210f; }
.qa-msg { font-size:0.85rem; font-weight:800; margin-top:8px; min-height:1.2em; }
.qa-msg.ok { color:#43e97b; }
.qa-msg.err { color:#f7971e; }
/* ---- MOBILE ---- */
@media (max-width: 600px) {
body { padding:16px 12px; }
.page-header { margin-bottom:18px; }
.manage-board { flex-direction:column; overflow-x:visible; }
.kid-col { width:100%; min-width:0; }
.card-list { min-height:30px; }
.chore-card { padding:12px 12px; }
.chore-card .cc-del { font-size:1.4rem; padding:0 8px; }
.rule-row { padding:11px; }
.rule-row .rr-btn { font-size:1.2rem; padding:6px 8px; }
.dt-tab { flex:1; text-align:center; }
.stats-grid { grid-template-columns:1fr; }
.modal { padding:18px; }
}
</style>
</head>
<body>
<!-- LOGIN SCREEN -->
<div id="pin-screen">
<h1>🔐 Admin Access</h1>
<p>Sign in with a parent Google account to manage chores.</p>
<button class="signin-btn" id="signinBtn" onclick="signInGoogle()">
<span style="font-size:1.2rem">🔑</span> Sign in with Google
</button>
<div id="authError" class="pin-error" style="display:none"></div>
<a href="#" onclick="signOut();return false;" style="color:#666;font-size:0.8rem;font-weight:700;margin-top:6px">Sign out</a>
</div>
<!-- ADMIN BOARD -->
<div id="admin-board">
<div class="page-header">
<h1>📊 Hull Chores Admin</h1>
<div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap">
<span id="whoami" style="font-size:0.8rem;color:#777;font-weight:700"></span>
<a href="index.html">← Board</a>
<a href="#" onclick="signOut();return false;">Sign out</a>
</div>
</div>
<!-- QUICK ADD -->
<div class="section-title">⚡ Quick Add to Today</div>
<div class="quick-add">
<input type="text" id="quickAddInput" placeholder="e.g. Theodore take out trash"
autocomplete="off" autocapitalize="sentences"
onkeydown="if(event.key==='Enter')quickAddSubmit()">
<button class="qa-mic" id="qaMic" onclick="startVoice()" title="Speak" style="display:none">🎤</button>
<button class="qa-go" onclick="quickAddSubmit()">Add</button>
</div>
<div id="quickAddMsg" class="qa-msg"></div>
<!-- MANAGE ASSIGNMENTS -->
<div class="section-title">🗂️ Manage Assignments</div>
<div class="manage-controls">
<select id="manageDaySelect" onchange="loadManage(this.value)"></select>
<span id="manageStatus"></span>
</div>
<p style="font-size:0.82rem;color:#777;margin:-4px 0 14px">
Tap a child to mark them <b>away</b> (their chores get split among whoever's home). Drag cards between columns to reassign. Changes only take effect once you press Save.
</p>
<div class="away-row" id="awayRow"></div>
<div class="manage-board" id="manageBoard"></div>
<div class="manage-actions">
<button class="save-btn" onclick="saveManage()">💾 Save changes</button>
<button class="ghost-btn" onclick="loadManage(manageKey)">⟲ Discard</button>
<button class="ghost-btn" onclick="resetManage()">↺ Reset to defaults</button>
</div>
<!-- EDIT RECURRING DEFAULTS -->
<div class="section-title">🔁 Edit Recurring Defaults</div>
<p class="hint">These templates auto-generate each day's chores. Editing them changes every future day (a day you've already customised above keeps its custom assignments). <span id="templStatus" style="font-weight:800"></span></p>
<div class="dt-tabs" id="dtTabs">
<button class="dt-tab active" data-dt="weekday" onclick="selectDayType('weekday')">📚 Weekday</button>
<button class="dt-tab" data-dt="saturday" onclick="selectDayType('saturday')">🗓️ Saturday</button>
<button class="dt-tab" data-dt="sunday" onclick="selectDayType('sunday')">⛪ Sunday</button>
</div>
<div id="rulesEditor"></div>
<div class="manage-actions">
<button class="save-btn" onclick="saveTemplates()">💾 Save defaults</button>
<button class="ghost-btn" onclick="loadTemplates()">⟲ Discard</button>
<button class="ghost-btn" onclick="resetTemplates()">↺ Restore originals</button>
</div>
<div id="loadingMsg" class="loading-msg">Loading all-time data...</div>
<div id="statsContent" style="display:none">
<!-- Overview stats -->
<div class="stats-grid" id="overviewGrid"></div>
<!-- Weekly trend -->
<div class="section-title">📈 Weekly Completion Trend</div>
<div class="stat-card" style="margin-bottom:28px">
<div class="trend-wrap"><div class="trend-chart" id="trendChart"></div></div>
</div>
<!-- Per-kid breakdown -->
<div class="section-title">👦 Completion by Kid</div>
<div class="stats-grid" id="kidGrid"></div>
<!-- Top & bottom chores -->
<div class="section-title">✅ Chore Completion Rates</div>
<div class="stats-grid" id="choreGrid"></div>
<!-- Streaks -->
<div class="section-title">🔥 Best Streaks (Full Day Complete)</div>
<div class="stat-card" id="streakCard"></div>
<!-- Danger zone -->
<div class="section-title">⚠️ Reset</div>
<div class="danger-zone">
<h3>🗑️ Reset a Specific Day</h3>
<p>This permanently deletes all chore data for the selected day. Use only if data is corrupted.</p>
<select class="reset-select" id="resetSelect"><option value="">Select a day to reset...</option></select>
<br>
<button class="reset-btn-danger" onclick="resetDay()">Reset This Day</button>
</div>
</div>
</div>
<!-- RULE EDITOR MODAL -->
<div class="modal-overlay" id="ruleModal">
<div class="modal">
<h3 id="ruleModalTitle">Edit chore</h3>
<div id="ruleFormBody"></div>
<div class="modal-actions">
<button class="save-btn" onclick="saveRule()">Save</button>
<button class="ghost-btn" onclick="closeRuleModal()">Cancel</button>
</div>
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-firestore-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-auth-compat.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.2/Sortable.min.js"></script>
<script src="chore-engine.js"></script>
<script>
firebase.initializeApp({
apiKey: "AIzaSyBImvAIHP_3S9aDl0_yjhwtGG5pf1e5Z7k",
authDomain: "hull-chores.firebaseapp.com",
projectId: "hull-chores"
});
var db = firebase.firestore();
if ('serviceWorker' in navigator) {
window.addEventListener('load', function(){ navigator.serviceWorker.register('sw.js').catch(function(){}); });
}
// =============================================
// AUTH (parent Google sign-in)
// =============================================
// Only these accounts may manage chores. The list itself lives in
// allowlist.json — the single source of truth shared with firestore.rules
// (see that file for how the two stay in sync). Loaded at runtime here
// since this is a static, no-build app and can't literally import it.
var ALLOWED_PARENTS = [];
var allowlistReady = fetch('allowlist.json')
.then(function (r) { return r.json(); })
.then(function (data) {
ALLOWED_PARENTS = (data.parents || []).map(function (e) { return e.toLowerCase(); });
})
.catch(function (err) {
console.error('Failed to load allowlist.json — no one will be able to sign in as admin.', err);
});
var auth = firebase.auth();
var adminBooted = false;
function signInGoogle() {
showAuthError('');
var btn = document.getElementById('signinBtn');
if (btn) btn.disabled = true;
var provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({ prompt: 'select_account' });
auth.signInWithPopup(provider).catch(function (e) {
if (btn) btn.disabled = false;
if (e.code !== 'auth/popup-closed-by-user' && e.code !== 'auth/cancelled-popup-request') {
showAuthError('Sign-in failed: ' + e.message);
}
});
}
function signOut() { auth.signOut(); }
function showAuthError(msg) {
var el = document.getElementById('authError');
if (!el) return;
el.style.display = msg ? 'block' : 'none';
el.textContent = msg;
}
auth.onAuthStateChanged(function (user) {
var btn = document.getElementById('signinBtn');
if (btn) btn.disabled = false;
// Wait for allowlist.json before deciding — avoids a flash of "not
// authorised" (or worse, treating an empty list as "nobody's allowed")
// while the fetch is still in flight.
allowlistReady.then(function () {
var ok = user && user.email && ALLOWED_PARENTS.indexOf(user.email.toLowerCase()) !== -1;
if (ok) {
document.getElementById('pin-screen').style.display = 'none';
document.getElementById('admin-board').style.display = 'block';
document.getElementById('whoami').textContent = '👤 ' + user.email;
if (!adminBooted) {
adminBooted = true;
loadStats();
initManage();
initTemplates();
}
} else {
document.getElementById('admin-board').style.display = 'none';
document.getElementById('pin-screen').style.display = 'flex';
if (user) {
// Signed in, but not an allowed parent.
showAuthError(user.email + ' is not authorised. Sign out and use a parent account.');
}
}
});
});
// =============================================
// KIDS (roster comes from chore-engine.js)
// =============================================
var KIDS = ChoreEngine.KIDS;
var KID_COLORS = {
theodore:'#667eea', alice:'#f093fb', andrew:'#4facfe',
felix:'#43e97b', lucy:'#fa709a', leo:'#f7971e'
};
// =============================================
// LOAD ALL STATS
// =============================================
var allDays = []; // { key, dayType, date, state, completionByKid, overallPct }
function loadStats() {
db.collection('chores').get().then(function(snap) {
allDays = [];
snap.forEach(function(doc) {
var key = doc.id;
if (!/^(weekday|saturday|sunday)_/.test(key)) return; // skip avatars, templates, etc.
if (/_test$/.test(key)) return; // skip ?day= preview docs
var data = doc.data();
var state = data.state || {};
var info = ChoreEngine.parseKey(key);
var dayType = info.dayType;
var date = info.date;
// Calculate per-kid completion — count unique chore keys
var kidCompletion = {};
var totalDone = 0, totalChores = 0;
KIDS.forEach(function(kid) {
var kidState = state[kid.id] || {};
var keys = Object.keys(kidState);
var done = keys.filter(function(k){ return kidState[k] && kidState[k].done; }).length;
kidCompletion[kid.id] = { done: done, total: keys.length, pct: keys.length ? Math.round(done/keys.length*100) : 0 };
totalDone += done;
totalChores += keys.length;
});
allDays.push({
key: key,
dayType: dayType,
date: date,
state: state,
kidCompletion: kidCompletion,
overallPct: totalChores ? Math.round(totalDone/totalChores*100) : 0,
totalDone: totalDone,
totalChores: totalChores,
});
});
// Sort by date
allDays.sort(function(a,b) {
if (!a.date) return 1; if (!b.date) return -1;
return a.date - b.date;
});
renderStats();
}).catch(function(e) {
document.getElementById('loadingMsg').textContent = 'Error loading data: ' + e.message;
});
}
// =============================================
// RENDER STATS
// =============================================
function renderStats() {
document.getElementById('loadingMsg').style.display = 'none';
document.getElementById('statsContent').style.display = 'block';
renderOverview();
renderTrend();
renderKidBreakdown();
renderChoreBreakdown();
renderStreaks();
renderResetSelect();
renderManageSelect();
}
function renderOverview() {
var totalDays = allDays.length;
var perfectDays = allDays.filter(function(d){ return d.overallPct === 100; }).length;
var avgPct = totalDays ? Math.round(allDays.reduce(function(s,d){ return s+d.overallPct; },0)/totalDays) : 0;
var satDays = allDays.filter(function(d){ return d.dayType==='saturday'; });
var sunDays = allDays.filter(function(d){ return d.dayType==='sunday'; });
document.getElementById('overviewGrid').innerHTML =
statBox('📅', totalDays, 'Total days tracked') +
statBox('💯', perfectDays, 'Perfect days (100%)') +
statBox('📊', avgPct + '%', 'Average completion') +
statBox('⛪', sunDays.length + ' / 🗓️ ' + satDays.length, 'Sundays / Saturdays');
}
function statBox(icon, val, label) {
return '<div class="stat-card">' +
'<div class="big-stat">' + icon + ' ' + val + '</div>' +
'<div class="big-stat-label">' + label + '</div>' +
'</div>';
}
function renderTrend() {
if (!allDays.length) { document.getElementById('trendChart').innerHTML = '<div class="loading-msg">No data yet</div>'; return; }
var maxH = 100;
var html = '';
allDays.forEach(function(d) {
var h = Math.max(2, Math.round(d.overallPct / 100 * maxH));
var label = d.date ? (d.date.getMonth()+1)+'/'+(d.date.getDate()) : d.key;
var tip = label + ' — ' + d.overallPct + '%';
html += '<div class="trend-bar-wrap">' +
'<div class="trend-bar ' + d.dayType + '" style="height:' + h + 'px" data-tip="' + tip + '"></div>' +
'<div class="trend-label">' + label + '</div>' +
'</div>';
});
document.getElementById('trendChart').innerHTML = html;
}
function renderKidBreakdown() {
var kidTotals = {};
KIDS.forEach(function(k){ kidTotals[k.id] = { done:0, total:0, perfect:0, days:0 }; });
allDays.forEach(function(d) {
KIDS.forEach(function(k) {
var kc = d.kidCompletion[k.id];
if (kc && kc.total > 0) {
kidTotals[k.id].done += kc.done;
kidTotals[k.id].total += kc.total;
kidTotals[k.id].days++;
if (kc.pct === 100) kidTotals[k.id].perfect++;
}
});
});
// Overall completion per kid
var overallHtml = '<div class="stat-card"><h3>Overall Completion Rate</h3>';
KIDS.forEach(function(k) {
var t = kidTotals[k.id];
var pct = t.total ? Math.round(t.done/t.total*100) : 0;
overallHtml += kidBar(k, pct);
});
overallHtml += '</div>';
// Perfect days per kid
var perfectHtml = '<div class="stat-card"><h3>Perfect Day Rate</h3>';
KIDS.forEach(function(k) {
var t = kidTotals[k.id];
var pct = t.days ? Math.round(t.perfect/t.days*100) : 0;
perfectHtml += kidBar(k, pct);
});
perfectHtml += '</div>';
document.getElementById('kidGrid').innerHTML = overallHtml + perfectHtml;
}
function kidBar(kid, pct) {
return '<div class="kid-bar-row">' +
'<div class="kid-bar-name">' + kid.emoji + ' ' + kid.name.split(' ')[0] + '</div>' +
'<div class="kid-bar-track"><div class="kid-bar-fill bar-' + kid.id + '" style="width:' + pct + '%"></div></div>' +
'<div class="kid-bar-pct">' + pct + '%</div>' +
'</div>';
}
function renderChoreBreakdown() {
// Aggregate chore completion across all days
var choreCounts = {}; // label -> { done, total, icon }
allDays.forEach(function(d) {
KIDS.forEach(function(k) {
var kidState = d.state[k.id] || {};
Object.keys(kidState).forEach(function(fullKey) {
// key format: kidId__tod__label
var parts = fullKey.split('__');
if (parts.length < 3) return;
var label = parts.slice(2).join('__');
if (!choreCounts[label]) choreCounts[label] = { done:0, total:0 };
choreCounts[label].total++;
if (kidState[fullKey] && kidState[fullKey].done) choreCounts[label].done++;
});
});
});
var chores = Object.keys(choreCounts).map(function(l) {
var c = choreCounts[l];
return { label:l, pct: c.total ? Math.round(c.done/c.total*100) : 0, total:c.total };
}).filter(function(c){ return c.total >= 2; }); // only show chores with enough data
chores.sort(function(a,b){ return b.pct - a.pct; });
var topHtml = '<div class="stat-card"><h3>🏆 Most Completed</h3>';
chores.slice(0,8).forEach(function(c) {
topHtml += choreBar(c);
});
topHtml += '</div>';
var botHtml = '<div class="stat-card"><h3>😬 Least Completed</h3>';
chores.slice(-8).reverse().forEach(function(c) {
botHtml += choreBar(c, true);
});
botHtml += '</div>';
document.getElementById('choreGrid').innerHTML = chores.length ? topHtml + botHtml : '<div class="stat-card"><p style="color:#666">Not enough data yet</p></div>';
}
function choreBar(c, low) {
var color = low ? '#f5576c' : '#43e97b';
return '<div class="chore-stat-row">' +
'<div class="chore-stat-label">' + c.label + '</div>' +
'<div class="chore-stat-bar-track"><div class="chore-stat-bar-fill" style="width:' + c.pct + '%;background:' + color + '"></div></div>' +
'<div class="chore-stat-pct">' + c.pct + '%</div>' +
'</div>';
}
function renderStreaks() {
// Calculate longest streak of perfect days per kid
var streaks = {};
KIDS.forEach(function(k) {
var cur = 0, best = 0;
allDays.forEach(function(d) {
var kc = d.kidCompletion[k.id];
if (kc && kc.pct === 100 && kc.total > 0) { cur++; best = Math.max(best,cur); }
else cur = 0;
});
streaks[k.id] = best;
});
// Family streak (all kids perfect same day)
var famCur = 0, famBest = 0;
allDays.forEach(function(d) {
var allPerfect = KIDS.every(function(k){ var kc = d.kidCompletion[k.id]; return kc && kc.pct===100 && kc.total>0; });
if (allPerfect) { famCur++; famBest = Math.max(famBest,famCur); } else famCur=0;
});
var html = '<div class="streak-row"><div class="streak-name">👨👩👧👦 Whole Family</div><div class="streak-val">' + famBest + ' <span class="streak-fire">🔥</span></div></div>';
KIDS.forEach(function(k) {
html += '<div class="streak-row"><div class="streak-name">' + k.emoji + ' ' + k.name.split(' ')[0] + '</div><div class="streak-val">' + streaks[k.id] + ' <span class="streak-fire">🔥</span></div></div>';
});
document.getElementById('streakCard').innerHTML = html;
}
function renderResetSelect() {
var opts = '<option value="">Select a day to reset...</option>';
allDays.slice().reverse().forEach(function(d) {
var icon = d.dayType === 'saturday' ? '🗓️ Sat' : d.dayType === 'sunday' ? '⛪ Sun' : '📚 Weekday';
var label = d.date ? icon + ' ' + (d.date.getMonth()+1)+'/'+(d.date.getDate())+'/'+d.date.getFullYear() : d.key;
opts += '<option value="' + d.key + '">' + label + ' (' + d.overallPct + '% done)</option>';
});
document.getElementById('resetSelect').innerHTML = opts;
}
function resetDay() {
var key = document.getElementById('resetSelect').value;
if (!key) { alert('Please select a day first'); return; }
if (!confirm('Delete ALL chore data for ' + key + '? This cannot be undone.')) return;
db.collection('chores').doc(key).delete().then(function() {
alert('Deleted! Reloading stats...');
loadStats();
}).catch(function(e){ alert('Error: ' + e.message); });
}
// =============================================
// MANAGE ASSIGNMENTS (drag-and-drop)
// =============================================
var manageKey = null; // day-doc id currently being edited
var working = {}; // { kidId: [ {tod,label,icon} ] }
var workingAway = []; // [ kidId ]
var sortables = []; // active SortableJS instances
var TOD_OPTS = ['morning', 'afternoon', 'evening'];
function prettyKey(key) {
var info = ChoreEngine.parseKey(key);
var icon = info.dayType === 'sunday' ? '⛪' : info.dayType === 'saturday' ? '🗓️' : '📚';
var name = info.dayType.charAt(0).toUpperCase() + info.dayType.slice(1);
var d = info.date;
var dateStr = d ? ' ' + (d.getMonth() + 1) + '/' + d.getDate() : '';
return icon + ' ' + name + dateStr;
}
function initManage() {
manageKey = ChoreEngine.getTodayKey();
renderManageSelect();
loadManage(manageKey);
}
function renderManageSelect() {
var sel = document.getElementById('manageDaySelect');
if (!sel) return;
var today = ChoreEngine.getTodayKey();
var keys = [today];
allDays.forEach(function (d) { if (keys.indexOf(d.key) === -1) keys.push(d.key); });
var current = manageKey || today;
if (keys.indexOf(current) === -1) keys.unshift(current);
sel.innerHTML = keys.map(function (k) {
var lbl = (k === today ? 'Today — ' : '') + prettyKey(k);
return '<option value="' + k + '"' + (k === current ? ' selected' : '') + '>' + lbl + '</option>';
}).join('');
}
function loadManage(key) {
manageKey = key;
setManageStatus('Loading…', '');
db.collection('chores').doc(key).get().then(function (snap) {
var data = snap.exists ? snap.data() : {};
workingAway = (data.away || []).slice();
if (data.assignments) {
working = JSON.parse(JSON.stringify(data.assignments));
// ensure every kid has an entry
KIDS.forEach(function (k) { if (!working[k.id]) working[k.id] = []; });
} else {
working = ChoreEngine.generateAllForKey(key);
}
renderManage();
setManageStatus(data.assignments ? 'Custom assignments saved for this day' : 'Showing auto-generated defaults', '');
renderManageSelect();
}).catch(function (e) {
setManageStatus('Load error: ' + e.message, '');
});
}
function setManageStatus(text, cls) {
var el = document.getElementById('manageStatus');
if (!el) return;
el.textContent = text;
el.className = cls || '';
}
function destroySortables() {
sortables.forEach(function (s) { try { s.destroy(); } catch (e) {} });
sortables = [];
}
function presentKids() {
return KIDS.filter(function (k) { return workingAway.indexOf(k.id) === -1; });
}
function renderManage() {
destroySortables();
// Away chips (all kids; away ones highlighted)
document.getElementById('awayRow').innerHTML = KIDS.map(function (k) {
var away = workingAway.indexOf(k.id) !== -1;
return '<div class="away-chip' + (away ? ' away' : '') + '" onclick="toggleAway(\'' + k.id + '\')">' +
(k.emoji || '') + ' ' + k.name + (away ? ' · 🏠 away' : '') + '</div>';
}).join('');
// Columns for present kids
var board = document.getElementById('manageBoard');
board.innerHTML = presentKids().map(function (k) {
var list = working[k.id] || [];
var cards = list.map(function (c, i) { return choreCardHtml(k.id, c, i); }).join('');
return '<div class="kid-col col-' + k.id + '">' +
'<div class="kid-col-head">' + (k.emoji || '') + ' ' + k.name +
'<span class="ct">' + list.length + '</span></div>' +
'<div class="card-list" id="col-' + k.id + '">' + cards + '</div>' +
'<button class="add-chore-btn" onclick="addChore(\'' + k.id + '\')">+ Add chore</button>' +
'</div>';
}).join('');
// Init drag-and-drop on each present column
presentKids().forEach(function (k) {
var el = document.getElementById('col-' + k.id);
if (!el) return;
sortables.push(new Sortable(el, {
group: 'chores',
animation: 150,
ghostClass: 'sortable-ghost',
chosenClass: 'sortable-chosen',
onEnd: function () { syncFromDOM(); markDirty(); }
}));
});
}
function choreCardHtml(kidId, c, i) {
var safeTod = (c.tod || 'morning');
return '<div class="chore-card" data-tod="' + escAttr(safeTod) + '" data-label="' + escAttr(c.label) + '" data-icon="' + escAttr(c.icon || '📝') + '">' +
'<span class="cc-icon" onclick="editChore(\'' + kidId + '\',' + i + ')">' + (c.icon || '📝') + '</span>' +
'<span class="cc-label" onclick="editChore(\'' + kidId + '\',' + i + ')">' + escHtml(c.label) + '</span>' +
'<span class="cc-tod ' + safeTod + '">' + safeTod.slice(0, 3) + '</span>' +
'<button class="cc-del" onclick="removeChore(\'' + kidId + '\',' + i + ')">✕</button>' +
'</div>';
}
function escHtml(s) { return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); }
function escAttr(s) { return String(s).replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<'); }
// Rebuild `working` from the current DOM (after a drag).
function syncFromDOM() {
presentKids().forEach(function (k) {
var el = document.getElementById('col-' + k.id);
if (!el) return;
var cards = el.querySelectorAll('.chore-card');
var arr = [];
for (var i = 0; i < cards.length; i++) {
arr.push({
tod: cards[i].getAttribute('data-tod'),
label: cards[i].getAttribute('data-label'),
icon: cards[i].getAttribute('data-icon')
});
}
working[k.id] = arr;
});
}
function markDirty() { setManageStatus('Unsaved changes', 'dirty'); }
function toggleAway(kidId) {
syncFromDOM();
var idx = workingAway.indexOf(kidId);
if (idx === -1) {
// Mark away: split this kid's chores round-robin among present kids.
var pool = KIDS.map(function (k) { return k.id; })
.filter(function (id) { return id !== kidId && workingAway.indexOf(id) === -1; });
var theirs = working[kidId] || [];
if (pool.length) {
theirs.forEach(function (c, i) { working[pool[i % pool.length]].push(c); });
}
working[kidId] = [];
workingAway.push(kidId);
} else {
// Bring back: regenerate this kid's defaults for the day.
workingAway.splice(idx, 1);
var info = ChoreEngine.parseKey(manageKey);
working[kidId] = ChoreEngine.generate(kidId, info.dayType, info.date);
}
renderManage();
markDirty();
}
function addChore(kidId) {
syncFromDOM();
var label = prompt('Chore name:');
if (!label) return;
var icon = prompt('Emoji icon (optional):', '📝') || '📝';
var tod = (prompt('When? morning / afternoon / evening', 'morning') || 'morning').toLowerCase().trim();
if (TOD_OPTS.indexOf(tod) === -1) tod = 'morning';
working[kidId].push({ tod: tod, label: label, icon: icon });
renderManage();
markDirty();
}
function editChore(kidId, i) {
syncFromDOM();
var c = working[kidId][i];
if (!c) return;
var label = prompt('Chore name:', c.label);
if (label === null) return;
if (!label) { return; }
var icon = prompt('Emoji icon:', c.icon || '📝') || c.icon || '📝';
c.label = label; c.icon = icon;
renderManage();
markDirty();
}
function removeChore(kidId, i) {
syncFromDOM();
working[kidId].splice(i, 1);
renderManage();
markDirty();
}
function saveManage() {
syncFromDOM();
var payload = { assignments: working, away: workingAway, updatedAt: Date.now() };
setManageStatus('Saving…', '');
db.collection('chores').doc(manageKey).set(payload, { merge: true }).then(function () {
setManageStatus('Saved ✓', 'saved');
}).catch(function (e) {
setManageStatus('Save error: ' + e.message, 'dirty');
});
}
function resetManage() {
if (!confirm('Clear custom assignments for ' + prettyKey(manageKey) + ' and go back to the auto-generated defaults?')) return;
var del = firebase.firestore.FieldValue.delete();