studysystem 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- studysystem/__init__.py +1 -0
- studysystem/assets/note-callouts.lua +100 -0
- studysystem/assets/note-no-html.lua +28 -0
- studysystem/assets/note.css +146 -0
- studysystem/cli.py +344 -0
- studysystem/dashboard.html +781 -0
- studysystem/dashboard.py +377 -0
- studysystem/db/__init__.py +1 -0
- studysystem/db/engine.py +158 -0
- studysystem/db/migrate.py +122 -0
- studysystem/db/migrations/env.py +59 -0
- studysystem/db/migrations/script.py.mako +29 -0
- studysystem/db/migrations/versions/0000_baseline.py +19 -0
- studysystem/db/migrations/versions/0001_the_whole_schema.py +1743 -0
- studysystem/db/migrations/versions/0002_semester_ignores_case.py +38 -0
- studysystem/db/migrations/versions/0003_course_vault_folder.py +26 -0
- studysystem/db/migrations/versions/0004_note_pdf_path.py +26 -0
- studysystem/db/migrations/versions/0005_tagging_kind.py +39 -0
- studysystem/db/migrations/versions/0006_practice_mode.py +36 -0
- studysystem/db/migrations/versions/0007_exam_prep_from.py +25 -0
- studysystem/db/migrations/versions/0008_more_papers_kind.py +37 -0
- studysystem/db/migrations/versions/0009_past_exam_month_date.py +28 -0
- studysystem/db/migrations/versions/0010_task_parts.py +70 -0
- studysystem/db/migrations/versions/0011_observation_kind.py +39 -0
- studysystem/db/migrations/versions/0012_profile_claim.py +52 -0
- studysystem/db/migrations/versions/0013_assumed_instructor_papers.py +40 -0
- studysystem/db/migrations/versions/0014_scan_confirmation.py +44 -0
- studysystem/db/migrations/versions/0015_practice_item_count.py +37 -0
- studysystem/db/migrations/versions/0016_timetable_patterns.py +102 -0
- studysystem/db/migrations/versions/0017_course_dropped.py +36 -0
- studysystem/db/migrations/versions/0018_syllabus_topics.py +82 -0
- studysystem/db/migrations/versions/0019_course_lab_group.py +36 -0
- studysystem/db/migrations/versions/0020_chapter_scope.py +61 -0
- studysystem/db/migrations/versions/0021_note_retired_at.py +28 -0
- studysystem/db/migrations/versions/0022_rescope.py +48 -0
- studysystem/db/migrations/versions/0023_backlog_reason.py +42 -0
- studysystem/db/migrations/versions/0024_guess_sensitivity.py +35 -0
- studysystem/db/migrations/versions/0025_shortfall_inputs.py +83 -0
- studysystem/db/migrations/versions/0026_trials_switch.py +36 -0
- studysystem/db/tables.py +1096 -0
- studysystem/demo.py +722 -0
- studysystem/errors.py +39 -0
- studysystem/server/__init__.py +83 -0
- studysystem/server/__main__.py +5 -0
- studysystem/services/__init__.py +1 -0
- studysystem/services/adherence.py +147 -0
- studysystem/services/assessments.py +171 -0
- studysystem/services/capacity.py +164 -0
- studysystem/services/claims.py +405 -0
- studysystem/services/course_folder.py +82 -0
- studysystem/services/courses.py +176 -0
- studysystem/services/coverage.py +121 -0
- studysystem/services/dashboard_key.py +102 -0
- studysystem/services/feedback.py +412 -0
- studysystem/services/forward_eval.py +65 -0
- studysystem/services/gate.py +77 -0
- studysystem/services/generation.py +2864 -0
- studysystem/services/ids.py +15 -0
- studysystem/services/intake.py +278 -0
- studysystem/services/launcher.py +455 -0
- studysystem/services/lookups.py +91 -0
- studysystem/services/materials.py +97 -0
- studysystem/services/note_markdown.py +241 -0
- studysystem/services/notes.py +396 -0
- studysystem/services/parts.py +65 -0
- studysystem/services/past_exams.py +115 -0
- studysystem/services/pdf_render.py +148 -0
- studysystem/services/pdf_worker.py +184 -0
- studysystem/services/plan.py +1300 -0
- studysystem/services/private_view.py +38 -0
- studysystem/services/profiles.py +544 -0
- studysystem/services/programs.py +16 -0
- studysystem/services/replacements.py +107 -0
- studysystem/services/rescope.py +277 -0
- studysystem/services/settings.py +50 -0
- studysystem/services/setup.py +235 -0
- studysystem/services/shortfall.py +443 -0
- studysystem/services/state.py +846 -0
- studysystem/services/statements.py +222 -0
- studysystem/services/study_loop.py +998 -0
- studysystem/services/summaries.py +369 -0
- studysystem/services/syllabus.py +138 -0
- studysystem/services/system_work.py +113 -0
- studysystem/services/taxonomy.py +459 -0
- studysystem/services/topics.py +477 -0
- studysystem/services/trials.py +201 -0
- studysystem/services/unconfirmed.py +95 -0
- studysystem/services/units.py +34 -0
- studysystem/services/users.py +53 -0
- studysystem/services/values.py +168 -0
- studysystem/startup.py +147 -0
- studysystem/tools/__init__.py +4 -0
- studysystem/tools/course_setup.py +185 -0
- studysystem/tools/dashboard.py +27 -0
- studysystem/tools/feedback.py +66 -0
- studysystem/tools/gate.py +24 -0
- studysystem/tools/generation.py +156 -0
- studysystem/tools/materials.py +32 -0
- studysystem/tools/notes.py +29 -0
- studysystem/tools/past_exams.py +51 -0
- studysystem/tools/ping.py +9 -0
- studysystem/tools/plan.py +40 -0
- studysystem/tools/profiles.py +94 -0
- studysystem/tools/results.py +77 -0
- studysystem/tools/study_loop.py +145 -0
- studysystem/tools/summaries.py +52 -0
- studysystem/tools/topics.py +143 -0
- studysystem-1.0.0.dist-info/METADATA +254 -0
- studysystem-1.0.0.dist-info/RECORD +112 -0
- studysystem-1.0.0.dist-info/WHEEL +4 -0
- studysystem-1.0.0.dist-info/entry_points.txt +3 -0
- studysystem-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>Studysystem</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root{
|
|
9
|
+
color-scheme:light;
|
|
10
|
+
--bg:#f5f5f7;--surface:#fff;--fill:rgba(118,118,128,.12);--fill-2:rgba(118,118,128,.2);
|
|
11
|
+
--text:#1d1d1f;--text-2:#6e6e73;--text-3:#86868b;--hair:rgba(0,0,0,.09);
|
|
12
|
+
--accent:#0071e3;--accent-soft:rgba(0,113,227,.12);
|
|
13
|
+
--green:#34c759;--green-text:#1d7a36;--red-text:#c9160c;--red-soft:rgba(255,59,48,.12);--orange-text:#b25000;
|
|
14
|
+
--shadow:0 1px 2px rgba(0,0,0,.04),0 8px 24px rgba(0,0,0,.04);
|
|
15
|
+
--bar:rgba(245,245,247,.72);--thumb:#fff;--pop:rgba(255,255,255,.86);
|
|
16
|
+
--spring:cubic-bezier(.3,.7,0,1);
|
|
17
|
+
}
|
|
18
|
+
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
|
|
19
|
+
color-scheme:dark;
|
|
20
|
+
--bg:#000;--surface:#1c1c1e;--fill:rgba(118,118,128,.24);--fill-2:rgba(118,118,128,.36);
|
|
21
|
+
--text:#f5f5f7;--text-2:#a1a1a6;--text-3:#8e8e93;--hair:rgba(255,255,255,.12);
|
|
22
|
+
--accent:#0a84ff;--accent-soft:rgba(10,132,255,.2);
|
|
23
|
+
--green:#30d158;--green-text:#30d158;--red-text:#ff6961;--red-soft:rgba(255,69,58,.2);--orange-text:#ff9f0a;
|
|
24
|
+
--shadow:none;--bar:rgba(0,0,0,.66);--thumb:#636366;--pop:rgba(52,52,54,.88);
|
|
25
|
+
}}
|
|
26
|
+
:root[data-theme="dark"]{
|
|
27
|
+
color-scheme:dark;
|
|
28
|
+
--bg:#000;--surface:#1c1c1e;--fill:rgba(118,118,128,.24);--fill-2:rgba(118,118,128,.36);
|
|
29
|
+
--text:#f5f5f7;--text-2:#a1a1a6;--text-3:#8e8e93;--hair:rgba(255,255,255,.12);
|
|
30
|
+
--accent:#0a84ff;--accent-soft:rgba(10,132,255,.2);
|
|
31
|
+
--green:#30d158;--green-text:#30d158;--red-text:#ff6961;--red-soft:rgba(255,69,58,.2);--orange-text:#ff9f0a;
|
|
32
|
+
--shadow:none;--bar:rgba(0,0,0,.66);--thumb:#636366;--pop:rgba(52,52,54,.88);
|
|
33
|
+
}
|
|
34
|
+
*{box-sizing:border-box;margin:0}
|
|
35
|
+
body{background:var(--bg);color:var(--text);font:1.0625rem/1.47 -apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI Variable Text","Segoe UI",system-ui,sans-serif;-webkit-font-smoothing:antialiased;transition:background-color .3s ease,color .3s ease}
|
|
36
|
+
h1,h2,h3,.num{font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI Variable Display","Segoe UI",system-ui,sans-serif}
|
|
37
|
+
button,select,input{font:inherit;color:inherit}
|
|
38
|
+
a{color:var(--accent);text-decoration:none}
|
|
39
|
+
:focus-visible{outline:3px solid var(--accent);outline-offset:2px;border-radius:8px}
|
|
40
|
+
.wrap{max-width:1120px;margin:0 auto;padding:0 24px}
|
|
41
|
+
|
|
42
|
+
/* Top bar: a translucent layer; the page scrolls under it */
|
|
43
|
+
.bar{position:sticky;top:0;z-index:10;background:var(--bar);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px)}
|
|
44
|
+
.bar .wrap{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;height:60px;gap:12px}
|
|
45
|
+
.brand{font-weight:600;font-size:1rem;letter-spacing:-.01em}
|
|
46
|
+
.bar-end{display:flex;justify-content:flex-end;align-items:center;gap:12px;color:var(--text-2);font-size:.875rem}
|
|
47
|
+
.seg{position:relative;display:flex;background:var(--fill);border-radius:999px;padding:3px}
|
|
48
|
+
.seg a{position:relative;z-index:1;padding:6px 20px;border-radius:999px;font-size:.9375rem;font-weight:500;color:var(--text-2);transition:color .2s ease}
|
|
49
|
+
.seg a[aria-current="page"]{color:var(--text);font-weight:600}
|
|
50
|
+
.seg i{position:absolute;top:3px;bottom:3px;left:0;width:var(--w,0);transform:translateX(var(--x,0));background:var(--thumb);border-radius:999px;box-shadow:0 1px 3px rgba(0,0,0,.14)}
|
|
51
|
+
.seg.live i{transition:transform .38s var(--spring),width .38s var(--spring)}
|
|
52
|
+
.icon-btn{display:grid;place-items:center;width:36px;height:36px;border:0;border-radius:50%;background:var(--fill);cursor:pointer;transition:transform .1s ease-out}
|
|
53
|
+
.icon-btn:active{transform:scale(.92)}
|
|
54
|
+
|
|
55
|
+
/* Page head */
|
|
56
|
+
#app{padding:40px 24px 96px}
|
|
57
|
+
.page{animation:arrive .36s var(--spring)}
|
|
58
|
+
@keyframes arrive{from{opacity:0;transform:translateY(10px)}}
|
|
59
|
+
.eyebrow{font-size:.9375rem;font-weight:600;color:var(--text-2)}
|
|
60
|
+
h1{font-size:clamp(2.5rem,6vw,3.5rem);font-weight:700;letter-spacing:-.025em;line-height:1.05;margin-top:4px}
|
|
61
|
+
h2{font-size:1.75rem;font-weight:700;letter-spacing:-.02em;line-height:1.15;margin:56px 0 16px}
|
|
62
|
+
.sub{color:var(--text-2);margin-top:8px}
|
|
63
|
+
.card{background:var(--surface);border-radius:22px;padding:24px;box-shadow:var(--shadow)}
|
|
64
|
+
.label{font-size:.8125rem;font-weight:600;color:var(--text-2)}
|
|
65
|
+
.empty{padding:20px 24px;color:var(--text-2)}
|
|
66
|
+
/* D-288: the 3h45m question floats over every page, so Plan or Schedule cannot hide it */
|
|
67
|
+
.notice{position:fixed;z-index:30;top:72px;left:50%;width:min(440px,calc(100vw - 32px));transform:translateX(-50%);display:grid;grid-template-columns:1fr auto;gap:6px 16px;align-items:center;padding:16px 18px;border-radius:20px;background:var(--pop);-webkit-backdrop-filter:blur(30px) saturate(180%);backdrop-filter:blur(30px) saturate(180%);box-shadow:0 0 0 1px var(--hair),0 18px 48px rgba(0,0,0,.22);animation:drop .45s var(--spring)}
|
|
68
|
+
@keyframes drop{from{opacity:0;transform:translate(-50%,-14px) scale(.96)}}
|
|
69
|
+
.notice b{font-size:1rem}
|
|
70
|
+
.notice p{grid-column:1;font-size:.875rem;color:var(--text-2)}
|
|
71
|
+
.notice .acts{grid-row:1/3;grid-column:2;display:flex;gap:8px}
|
|
72
|
+
.notice .btn{height:40px;padding:0 18px;font-size:.9375rem}
|
|
73
|
+
@media (max-width:560px){.notice{grid-template-columns:1fr}.notice .acts{grid-row:auto;grid-column:1}.notice .btn{flex:1}}
|
|
74
|
+
@media (prefers-reduced-transparency:reduce){.notice{background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none}}
|
|
75
|
+
|
|
76
|
+
/* Stopwatch and the week */
|
|
77
|
+
.hero{display:grid;grid-template-columns:1.35fr 1fr;gap:20px;margin-top:32px}
|
|
78
|
+
.hero>*,.cols>*,.pair>*,.watch-top>*{min-width:0}
|
|
79
|
+
.watch{display:flex;flex-direction:column;min-height:340px}
|
|
80
|
+
.watch-top{display:flex;justify-content:space-between;align-items:center;gap:12px}
|
|
81
|
+
.watch-top .label{flex:none}
|
|
82
|
+
.pickers{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;min-width:0}
|
|
83
|
+
.pickers>*{min-width:0}
|
|
84
|
+
.menu{position:relative}
|
|
85
|
+
.menu-btn{display:flex;align-items:center;gap:8px;max-width:100%;border:0;border-radius:999px;background:var(--fill);padding:8px 12px 8px 16px;font-size:.9375rem;cursor:pointer;transition:transform .1s ease-out,opacity .2s ease}
|
|
86
|
+
.menu-btn:active{transform:scale(.97)}
|
|
87
|
+
.menu-btn:disabled{opacity:.5;cursor:default}
|
|
88
|
+
.menu-btn b,.opt b{font-weight:600;white-space:nowrap}
|
|
89
|
+
.menu-btn span,.opt span{color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
|
|
90
|
+
.menu-btn svg{flex:none;color:var(--text-3)}
|
|
91
|
+
.pop{position:absolute;right:0;top:calc(100% + 8px);z-index:20;width:min(340px,calc(100vw - 64px));max-height:min(420px,60vh);overflow-y:auto;padding:6px;border-radius:16px;background:var(--pop);-webkit-backdrop-filter:blur(30px) saturate(180%);backdrop-filter:blur(30px) saturate(180%);box-shadow:0 0 0 1px var(--hair),0 18px 48px rgba(0,0,0,.22);transform-origin:top right;opacity:0;transform:scale(.9);visibility:hidden;transition:opacity .16s ease,transform .28s var(--spring),visibility 0s .2s}
|
|
92
|
+
.pop.open{opacity:1;transform:none;visibility:visible;transition-delay:0s}
|
|
93
|
+
.opt{display:grid;grid-template-columns:16px auto 1fr;gap:10px;align-items:center;width:100%;border:0;background:none;text-align:left;padding:9px 10px;border-radius:10px;font-size:.9375rem;cursor:pointer}
|
|
94
|
+
.opt:hover,.opt:focus-visible{background:var(--fill);outline:0}
|
|
95
|
+
.opt svg{color:var(--accent);opacity:0}
|
|
96
|
+
.opt[aria-selected="true"] svg{opacity:1}
|
|
97
|
+
.digits{flex:1;display:grid;place-items:center;font-size:clamp(3.5rem,10vw,6rem);font-weight:600;letter-spacing:-.035em;font-variant-numeric:tabular-nums;line-height:1;transition:color .3s ease}
|
|
98
|
+
.watch.running .digits{color:var(--green-text)}
|
|
99
|
+
.status{min-height:1.5em;text-align:center;color:var(--text-2);font-size:.9375rem;margin-bottom:20px}
|
|
100
|
+
.status.err{color:var(--red-text)}
|
|
101
|
+
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--green);margin-right:8px;animation:pulse 1.6s ease-in-out infinite}
|
|
102
|
+
@keyframes pulse{50%{opacity:.35}}
|
|
103
|
+
.btn{display:inline-grid;place-items:center;height:52px;padding:0 28px;border:0;border-radius:999px;background:var(--accent);color:#fff;font-weight:600;cursor:pointer;transition:transform .1s ease-out,background-color .2s ease,opacity .2s ease}
|
|
104
|
+
.btn:active{transform:scale(.97)}
|
|
105
|
+
.btn:disabled{opacity:.5;cursor:default}
|
|
106
|
+
.btn.stop{background:var(--red-soft);color:var(--red-text)}
|
|
107
|
+
.watch .btn{align-self:center;min-width:200px}
|
|
108
|
+
.watch-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:12px}
|
|
109
|
+
.watch-actions .btn{min-width:150px}
|
|
110
|
+
.status.ask{color:var(--orange-text);font-weight:500}
|
|
111
|
+
.wtabs{display:inline-flex;background:var(--fill);border-radius:999px;padding:3px;flex:none}
|
|
112
|
+
.wtab{border:0;background:none;padding:6px 16px;border-radius:999px;font-size:.9375rem;font-weight:500;color:var(--text-2);cursor:pointer;transition:color .2s ease,background-color .2s ease}
|
|
113
|
+
.wtab[aria-selected="true"]{background:var(--thumb);color:var(--text);font-weight:600;box-shadow:0 1px 3px rgba(0,0,0,.14)}
|
|
114
|
+
.runstrip{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:14px;padding:10px 14px;border-radius:14px;background:var(--fill)}
|
|
115
|
+
.runstrip .num{color:var(--green-text);font-weight:600;font-variant-numeric:tabular-nums}
|
|
116
|
+
.runstrip .btn{height:36px;min-width:0;padding:0 16px;margin-left:auto}
|
|
117
|
+
.runstrip .err{flex-basis:100%;color:var(--red-text);font-size:.875rem}
|
|
118
|
+
.logform{flex:1;display:flex;flex-direction:column;justify-content:center;gap:14px;padding-top:16px}
|
|
119
|
+
.lf-row{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end}
|
|
120
|
+
.lf-field{display:flex;flex-direction:column;gap:6px;font-size:.8125rem;font-weight:600;color:var(--text-2);min-width:0}
|
|
121
|
+
.lf-field input{font:inherit;font-size:.9375rem;font-weight:400;color:var(--text);border:0;background:var(--fill);border-radius:10px;padding:9px 12px;min-height:38px;font-variant-numeric:tabular-nums}
|
|
122
|
+
.lf-field input[name="minutes"]{width:7em}
|
|
123
|
+
.lf-hint{margin:0;color:var(--text-2);font-size:.8125rem}
|
|
124
|
+
.logform .status{margin:0}
|
|
125
|
+
.logform .pop{left:0;right:auto;transform-origin:top left}
|
|
126
|
+
|
|
127
|
+
.side{display:grid;gap:20px;grid-template-rows:1fr auto}
|
|
128
|
+
.week{display:grid;grid-template-columns:auto 1fr;gap:20px;align-items:center}
|
|
129
|
+
.ring{width:112px;height:112px;transform:rotate(-90deg)}
|
|
130
|
+
.ring circle{fill:none;stroke-width:12;stroke-linecap:round}
|
|
131
|
+
.ring .track{stroke:var(--fill)}
|
|
132
|
+
.ring.none .track{stroke-dasharray:4 10;stroke-linecap:butt}
|
|
133
|
+
.ring .fill{stroke:var(--accent);transition:stroke-dashoffset .9s var(--spring),stroke .3s ease}
|
|
134
|
+
.ring.met .fill{stroke:var(--green)}
|
|
135
|
+
.big{font-size:2rem;font-weight:700;letter-spacing:-.02em;line-height:1.1;font-variant-numeric:tabular-nums}
|
|
136
|
+
.muted{color:var(--text-2);font-size:.9375rem}
|
|
137
|
+
.risk{color:var(--orange-text);font-size:.9375rem;font-weight:500}
|
|
138
|
+
.bars{grid-column:1/-1;display:grid;grid-template-columns:repeat(7,1fr);gap:8px;align-items:end;height:72px;margin-top:4px}
|
|
139
|
+
.bars div{display:flex;flex-direction:column;justify-content:flex-end;align-items:center;gap:6px;height:100%;font-size:.75rem;color:var(--text-3)}
|
|
140
|
+
.bars b{display:block;width:100%;max-width:28px;min-height:4px;border-radius:6px;background:var(--fill-2)}
|
|
141
|
+
.bars .today b{background:var(--accent)}
|
|
142
|
+
.bars .today{color:var(--text);font-weight:600}
|
|
143
|
+
.quiet.edit{padding:4px 0;margin-top:2px}
|
|
144
|
+
.goal{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;margin-top:8px}
|
|
145
|
+
.goal input{width:5.5em;border:0;background:var(--fill);border-radius:10px;padding:6px 10px;font-variant-numeric:tabular-nums}
|
|
146
|
+
.goal .err{flex-basis:100%;color:var(--red-text);font-size:.875rem}
|
|
147
|
+
.tiles{display:grid;grid-template-columns:1fr 1fr;gap:20px}
|
|
148
|
+
.tile{padding:20px 24px}
|
|
149
|
+
|
|
150
|
+
/* Grouped lists */
|
|
151
|
+
.cols{display:grid;grid-template-columns:1fr 1.25fr;gap:20px;align-items:start}
|
|
152
|
+
.list{padding:0;overflow:hidden}
|
|
153
|
+
.list-head{display:flex;justify-content:space-between;align-items:baseline;padding:18px 24px 10px}
|
|
154
|
+
.list-head b{font-size:1.0625rem}
|
|
155
|
+
.head-end{display:flex;align-items:center;gap:10px}
|
|
156
|
+
.fold-btn{display:grid;place-items:center;width:28px;height:28px;border:0;border-radius:50%;background:var(--fill);color:var(--text-2);cursor:pointer;padding:0;transition:transform .1s ease-out}
|
|
157
|
+
.fold-btn:active{transform:scale(.92)}
|
|
158
|
+
.fold-btn svg{transform:rotate(90deg);transition:transform .3s var(--spring)}
|
|
159
|
+
.fold-btn.up svg{transform:rotate(-90deg)}
|
|
160
|
+
.row{display:grid;grid-template-columns:auto 1fr auto;gap:14px;align-items:center;padding:13px 24px;position:relative}
|
|
161
|
+
.row+.row::before{content:"";position:absolute;top:0;left:24px;right:0;height:1px;background:var(--hair)}
|
|
162
|
+
.row time{font-variant-numeric:tabular-nums;font-weight:600;font-size:.9375rem;min-width:3.2em}
|
|
163
|
+
.row time small{display:block;font-weight:400;color:var(--text-3);font-size:.8125rem}
|
|
164
|
+
.row .t{font-weight:500;line-height:1.3}
|
|
165
|
+
.row .m{font-size:.875rem;color:var(--text-2)}
|
|
166
|
+
.row.past{opacity:.45}
|
|
167
|
+
.tag{font-size:.75rem;font-weight:600;padding:3px 9px;border-radius:999px;background:var(--fill);color:var(--text-2);white-space:nowrap}
|
|
168
|
+
.tag.now{background:var(--accent-soft);color:var(--accent)}
|
|
169
|
+
.check{width:24px;height:24px;border-radius:50%;border:2px solid var(--text-3);background:none;cursor:pointer;display:grid;place-items:center;transition:transform .1s ease-out,background-color .2s ease,border-color .2s ease;padding:0;flex:none}
|
|
170
|
+
.check:active{transform:scale(.88)}
|
|
171
|
+
.check svg{opacity:0;transform:scale(.5);transition:opacity .2s ease,transform .3s var(--spring)}
|
|
172
|
+
.check[aria-pressed="true"]{background:var(--accent);border-color:var(--accent)}
|
|
173
|
+
.check[aria-pressed="true"] svg{opacity:1;transform:none}
|
|
174
|
+
.row.done .t{color:var(--text-3);text-decoration:line-through}
|
|
175
|
+
.quiet{border:0;background:none;color:var(--accent);font-size:.9375rem;cursor:pointer;padding:6px 4px}
|
|
176
|
+
.add{display:flex;gap:10px;padding:12px 24px 18px;border-top:1px solid var(--hair)}
|
|
177
|
+
.add input{flex:1;border:0;background:var(--fill);border-radius:12px;padding:10px 14px;min-width:0}
|
|
178
|
+
.add .menu{flex:none;display:flex;position:static}
|
|
179
|
+
/* the Tasks card lets the course menu spill out; the menu opens upward, above the form, lined up
|
|
180
|
+
with the form's right side so a phone shows all of it */
|
|
181
|
+
#taskrows{overflow:visible}
|
|
182
|
+
.add{position:relative}
|
|
183
|
+
.add .pop{top:auto;right:24px;bottom:calc(100% + 8px);transform-origin:bottom right}
|
|
184
|
+
.pair{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-top:20px}
|
|
185
|
+
.hon .muted{margin:2px 0 12px}
|
|
186
|
+
.hon .big{margin-top:4px}
|
|
187
|
+
.hon-rows{list-style:none;padding:0;margin:8px 0 0}
|
|
188
|
+
.hon-rows li{display:grid;grid-template-columns:auto auto 1fr;align-items:baseline;gap:4px 12px;padding:9px 0;border-top:1px solid var(--hair);font-size:.9375rem}
|
|
189
|
+
.hon-rows li small{grid-column:1/-1;color:var(--text-3);font-size:.8125rem}
|
|
190
|
+
.hon-rows em{font-style:normal;color:var(--text-2);text-align:right}
|
|
191
|
+
.hon-rows b{font-weight:600;font-variant-numeric:tabular-nums}
|
|
192
|
+
.hon-rows.plain li{display:flex;justify-content:space-between;gap:12px}
|
|
193
|
+
.hon-rows.plain li small{display:inline;margin-left:6px}
|
|
194
|
+
.hon .more{padding:10px 0 0;border-top:1px solid var(--hair);width:100%;text-align:left}
|
|
195
|
+
.hon .meta{font-size:.8125rem;color:var(--text-3);margin-top:8px}
|
|
196
|
+
.hon-sub{margin-top:14px}
|
|
197
|
+
|
|
198
|
+
/* Courses */
|
|
199
|
+
/* D-291: each card takes its row's height; the foot sits at the bottom, so the folds line up */
|
|
200
|
+
.courses{display:grid;grid-template-columns:repeat(auto-fill,minmax(310px,1fr));gap:20px}
|
|
201
|
+
.course{display:flex;flex-direction:column}
|
|
202
|
+
.course .foot{margin-top:auto;padding-top:16px}
|
|
203
|
+
.course h3{font-size:1.25rem;font-weight:600;letter-spacing:-.01em;line-height:1.25;margin:2px 0 4px}
|
|
204
|
+
.course .meta{font-size:.875rem;color:var(--text-2)}
|
|
205
|
+
.course .meta small{display:block;font-size:.8125rem;color:var(--text-3)}
|
|
206
|
+
.code{display:flex;align-items:center;gap:8px;font-size:.875rem;font-weight:600;color:var(--text-2)}
|
|
207
|
+
.code i{width:10px;height:10px;border-radius:50%;background:hsl(var(--h) 68% 52%)}
|
|
208
|
+
.stats{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:16px 0}
|
|
209
|
+
.stats b{display:block;font-size:1.375rem;font-weight:600;letter-spacing:-.015em;font-variant-numeric:tabular-nums}
|
|
210
|
+
.stats span{font-size:.8125rem;color:var(--text-2)}
|
|
211
|
+
.assess{list-style:none;padding:0;margin:14px 0 0}
|
|
212
|
+
.assess li{display:flex;justify-content:space-between;gap:12px;padding:8px 0;border-top:1px solid var(--hair);font-size:.9375rem}
|
|
213
|
+
.assess small{display:block;color:var(--text-2);font-size:.8125rem}
|
|
214
|
+
.assess em{font-style:normal;color:var(--text-2);white-space:nowrap}
|
|
215
|
+
.foot{margin:16px -24px -24px}
|
|
216
|
+
.foot>*{border-top:1px solid var(--hair);padding:0 24px}
|
|
217
|
+
.fold summary{list-style:none;cursor:pointer;padding:14px 0;display:grid;grid-template-columns:1fr auto auto;gap:10px;align-items:center;font-size:.9375rem;font-weight:500}
|
|
218
|
+
.fold summary::-webkit-details-marker{display:none}
|
|
219
|
+
.fold summary span{color:var(--text-2);font-variant-numeric:tabular-nums;font-weight:400}
|
|
220
|
+
.fold summary svg{transition:transform .3s var(--spring);color:var(--text-3)}
|
|
221
|
+
.fold[open] summary svg{transform:rotate(90deg)}
|
|
222
|
+
.fold p{font-size:.9375rem;color:var(--text-2);padding-bottom:16px}
|
|
223
|
+
.meter{grid-column:1/-1;height:6px;border-radius:3px;background:var(--fill);overflow:hidden}
|
|
224
|
+
.meter em{display:block;height:100%;border-radius:3px;background:var(--accent);transition:width .5s var(--spring)}
|
|
225
|
+
.paper{display:flex;align-items:center;gap:12px;padding:9px 0;font-size:.9375rem;cursor:pointer}
|
|
226
|
+
.paper:last-child{padding-bottom:18px}
|
|
227
|
+
.paper.done span{color:var(--text-3)}
|
|
228
|
+
.foot .nopapers,.foot .planlink{display:block;padding-top:14px;padding-bottom:14px;font-size:.9375rem}
|
|
229
|
+
.nopapers{color:var(--text-2)}
|
|
230
|
+
.planlink{font-weight:500}
|
|
231
|
+
|
|
232
|
+
/* Plan */
|
|
233
|
+
.chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:24px}
|
|
234
|
+
.chip{padding:6px 14px;border-radius:999px;background:var(--fill);color:var(--text-2);font-size:.875rem;font-weight:500;transition:transform .1s ease-out}
|
|
235
|
+
.chip:active{transform:scale(.96)}
|
|
236
|
+
.chip[aria-current="true"]{background:var(--text);color:var(--bg)}
|
|
237
|
+
/* D-302: a 2x2 grid; each lane spans two rows of it (heading, card), so the headings line up and
|
|
238
|
+
the two cards in a row stretch to one height */
|
|
239
|
+
.lanes{display:grid;grid-template-columns:1fr 1fr;column-gap:20px}
|
|
240
|
+
.lanes>.lane{display:grid;grid-row:span 2;grid-template-rows:subgrid;min-width:0}
|
|
241
|
+
.lane h2{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px}
|
|
242
|
+
.lane h2 small{font-size:1rem;font-weight:500;color:var(--text-2);letter-spacing:0}
|
|
243
|
+
.lane .list-head{padding-bottom:6px}
|
|
244
|
+
.rank{font-variant-numeric:tabular-nums;color:var(--text-3);font-weight:600;min-width:1.6em}
|
|
245
|
+
.system .err,.trials .err{color:var(--red-text);font-size:.875rem;margin-top:4px}
|
|
246
|
+
.why summary{cursor:pointer;font-size:.8125rem;color:var(--accent);margin-top:4px;list-style:none}
|
|
247
|
+
.why summary::-webkit-details-marker{display:none}
|
|
248
|
+
.why p{font-size:.875rem;color:var(--text-2);margin-top:4px}
|
|
249
|
+
|
|
250
|
+
/* Week grid */
|
|
251
|
+
.gridwrap{overflow-x:auto;padding:20px 20px 20px 8px}
|
|
252
|
+
.grid{display:grid;grid-template-columns:52px repeat(5,minmax(116px,1fr));min-width:680px}
|
|
253
|
+
.grid .dh{text-align:center;font-size:.875rem;font-weight:600;color:var(--text-2);padding-bottom:12px}
|
|
254
|
+
.grid .dh.today{color:var(--accent)}
|
|
255
|
+
.hours,.day{position:relative;height:calc(var(--hrs)*56px)}
|
|
256
|
+
.hours span{position:absolute;right:10px;transform:translateY(-50%);font-size:.75rem;color:var(--text-3);font-variant-numeric:tabular-nums}
|
|
257
|
+
.day{border-left:1px solid var(--hair);background:repeating-linear-gradient(to bottom,var(--hair) 0 1px,transparent 1px 56px)}
|
|
258
|
+
.blk{position:absolute;border-radius:10px;padding:6px 9px;background:hsl(var(--h) 70% 52%/.16);border-left:3px solid hsl(var(--h) 68% 50%);font-size:.75rem;line-height:1.3;overflow:hidden}
|
|
259
|
+
.blk b{display:block;font-size:.8125rem}
|
|
260
|
+
.blk span{color:var(--text-2)}
|
|
261
|
+
.nowline{position:absolute;left:0;right:0;height:2px;background:var(--accent);z-index:2}
|
|
262
|
+
.nowline::before{content:"";position:absolute;left:-4px;top:-3px;width:8px;height:8px;border-radius:50%;background:var(--accent)}
|
|
263
|
+
|
|
264
|
+
@media (max-width:860px){
|
|
265
|
+
.hero,.cols,.pair,.lanes{grid-template-columns:1fr}
|
|
266
|
+
.watch{min-height:300px}
|
|
267
|
+
}
|
|
268
|
+
@media (max-width:560px){
|
|
269
|
+
.wrap{padding:0 16px}
|
|
270
|
+
#app{padding:28px 16px 80px}
|
|
271
|
+
.bar .wrap{grid-template-columns:1fr auto}
|
|
272
|
+
.brand,.bar-end span{display:none}
|
|
273
|
+
.seg a{padding:6px 14px}
|
|
274
|
+
.watch-top{flex-wrap:wrap}
|
|
275
|
+
.pickers{justify-content:flex-start;width:100%}
|
|
276
|
+
h2{margin-top:44px}
|
|
277
|
+
.row,.list-head,.add{padding-left:16px;padding-right:16px}
|
|
278
|
+
.add .pop{right:16px}
|
|
279
|
+
.row+.row::before{left:16px}
|
|
280
|
+
.courses{grid-template-columns:1fr}
|
|
281
|
+
}
|
|
282
|
+
@media (prefers-reduced-motion:reduce){
|
|
283
|
+
*{animation-duration:.01ms!important;transition-duration:.15s!important}
|
|
284
|
+
.page{animation:none}
|
|
285
|
+
.btn:active,.check:active,.icon-btn:active,.menu-btn:active,.chip:active,.fold-btn:active{transform:none}
|
|
286
|
+
}
|
|
287
|
+
@media (prefers-reduced-transparency:reduce){.bar{background:var(--bg);-webkit-backdrop-filter:none;backdrop-filter:none}.pop{background:var(--surface);-webkit-backdrop-filter:none;backdrop-filter:none}}
|
|
288
|
+
@media (prefers-contrast:more){.card{border:1px solid var(--text-3)}.bar{background:var(--bg)}}
|
|
289
|
+
</style>
|
|
290
|
+
</head>
|
|
291
|
+
<body>
|
|
292
|
+
<header class="bar"><div class="wrap">
|
|
293
|
+
<div class="brand">Studysystem</div>
|
|
294
|
+
<nav class="seg" id="seg" aria-label="Pages"><i></i><a href="#/plan" data-p="plan">Plan</a><a href="#/today" data-p="today">Today</a><a href="#/schedule" data-p="schedule">Schedule</a></nav>
|
|
295
|
+
<div class="bar-end"><span id="barDate"></span>
|
|
296
|
+
<button class="icon-btn" type="button" data-act="theme" aria-label="Switch light or dark theme"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z"/></svg></button>
|
|
297
|
+
</div>
|
|
298
|
+
</div></header>
|
|
299
|
+
<div id="notice" role="alert"></div>
|
|
300
|
+
<main class="wrap" id="app"><p class="empty">Loading semester data…</p></main>
|
|
301
|
+
|
|
302
|
+
<script>
|
|
303
|
+
// The page shows what GET /state sends and ranks nothing (D-19, D-163). Look: D-283, D-285.
|
|
304
|
+
const $=s=>document.querySelector(s);
|
|
305
|
+
const esc=x=>String(x??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
|
306
|
+
const pad=n=>String(n).padStart(2,'0');
|
|
307
|
+
const isoDay=d=>`${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}`;
|
|
308
|
+
const TODAY=isoDay(new Date());
|
|
309
|
+
const fmt=d=>d?new Date(d+'T00:00:00').toLocaleDateString(undefined,{day:'numeric',month:'short'}):'date unknown';
|
|
310
|
+
const daysTo=d=>d?Math.round((new Date(d+'T00:00:00')-new Date(TODAY+'T00:00:00'))/86400000):null;
|
|
311
|
+
const hm=m=>m<60?m+'m':Math.floor(m/60)+'h'+(m%60?' '+m%60+'m':'');
|
|
312
|
+
const TICK='<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.5 6.2 5 8.6l4.5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
313
|
+
const WHITE_TICK=TICK.replace('currentColor','#fff');
|
|
314
|
+
const CHEV='<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><path d="M4.5 2.5 8 6l-3.5 3.5" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
315
|
+
const ARROWS='<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><path d="M3.5 4.5 6 2l2.5 2.5M3.5 7.5 6 10l2.5-2.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
316
|
+
const RING=326.73; // the ring's circumference: 2 x pi x 52
|
|
317
|
+
|
|
318
|
+
// ---- what the browser keeps: today's ticks, personal tasks, paper ticks, the picked course
|
|
319
|
+
function read(key,fallback){try{const v=JSON.parse(localStorage.getItem(key)||'null');return v&&typeof v==='object'&&!Array.isArray(v)?v:fallback}catch(e){return fallback}}
|
|
320
|
+
function write(key,value){try{value==null?localStorage.removeItem(key):localStorage.setItem(key,JSON.stringify(value))}catch(e){}}
|
|
321
|
+
const isMap=v=>v&&typeof v==='object'&&!Array.isArray(v);
|
|
322
|
+
let store=read('semcon.state.v2',{});
|
|
323
|
+
if(store.day!==TODAY){store.day=TODAY;store.items={}} // a plan tick lasts one day
|
|
324
|
+
if(!isMap(store.items))store.items={};
|
|
325
|
+
if(!isMap(store.papers))store.papers={}; // D-285: a paper tick stays
|
|
326
|
+
store.custom=Array.isArray(store.custom)?store.custom:[];
|
|
327
|
+
const saveStore=()=>write('semcon.state.v2',store);
|
|
328
|
+
saveStore();
|
|
329
|
+
try{const t=localStorage.getItem('semcon.theme');if(t==='dark'||t==='light')document.documentElement.dataset.theme=t}catch(e){}
|
|
330
|
+
|
|
331
|
+
// ---- state from the server
|
|
332
|
+
let raw=null,plan=[],courses=[],meetings=[],first=true,openFolds=new Set();
|
|
333
|
+
function adapt(s){
|
|
334
|
+
raw=s;courses=s.courses||[];meetings=s.timetable?.meetings||[];plan=[];
|
|
335
|
+
const lanes=s.plan?.current?.lanes;if(!lanes)return;
|
|
336
|
+
const course=id=>courses.find(c=>c.course_id===id)||null;
|
|
337
|
+
for(const lane of ['review','study','setup']){
|
|
338
|
+
const l=lanes[lane];if(!l)continue;
|
|
339
|
+
const grouped=new Set((l.entries||[]).flatMap(e=>e.topic_ids||[]));
|
|
340
|
+
for(const i of l.items||[]){
|
|
341
|
+
if(grouped.has(i.topic_id))continue;
|
|
342
|
+
plan.push({uid:lane+':'+(i.setup_key||i.topic_id||i.rank),lane,rank:i.rank,course:course(i.course_id),
|
|
343
|
+
what:lane==='setup'?i.reason:(i.topic_name||i.reason||'Study item'),chapter:i.chapter||null,why:i.reason||null,mins:i.estimated_minutes??null});
|
|
344
|
+
}
|
|
345
|
+
for(const e of l.entries||[]){ // one chapter's topics, grouped by the server (D-240)
|
|
346
|
+
const ids=e.topic_ids||[];
|
|
347
|
+
plan.push({uid:lane+':'+(e.material_id||ids[0]||e.rank),lane,rank:e.rank,course:course(e.course_id),
|
|
348
|
+
what:(e.topics||[]).join(', ')||e.chapter||'Study item',chapter:e.chapter||null,
|
|
349
|
+
why:(l.items||[]).filter(i=>ids.includes(i.topic_id)).map(i=>i.reason).filter(Boolean).join(' · ')||null,mins:e.estimated_minutes??null});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const status=it=>store.items[it.uid]?.status||'upcoming';
|
|
354
|
+
const hue=c=>(Math.max(0,courses.indexOf(c))*47+210)%360;
|
|
355
|
+
const page=()=>{const p=location.hash.replace('#/','').split(/[/?]/)[0];return ['plan','today','schedule'].includes(p)?p:'today'};
|
|
356
|
+
const param=k=>new URLSearchParams(location.hash.split('?')[1]||'').get(k);
|
|
357
|
+
// A request that never reaches the server (it is stopped) fails before any answer: say so plainly.
|
|
358
|
+
const DOWN={code:'server_down',message:'The dashboard server is not running.'};
|
|
359
|
+
// D-369: the port answers every program on this computer, so each request carries this browser's key.
|
|
360
|
+
// The study system opens the page with a one-time code; the page trades it for the key and keeps it.
|
|
361
|
+
const KEY='studysystem.key';let heldKey='';
|
|
362
|
+
const myKey=()=>{try{return localStorage.getItem(KEY)||heldKey}catch(e){return heldKey}};
|
|
363
|
+
async function enter(){
|
|
364
|
+
const m=location.hash.match(/^#open=([\w.]+)$/);if(!m)return;
|
|
365
|
+
history.replaceState(null,'','#/today');
|
|
366
|
+
let r;try{r=await fetch('/open',{method:'POST',headers:{'Content-Type':'application/json',Accept:'application/json'},body:JSON.stringify({code:m[1]})})}catch(x){return}
|
|
367
|
+
if(!r.ok)return;heldKey=(await r.json()).key;try{localStorage.setItem(KEY,heldKey)}catch(e){}
|
|
368
|
+
}
|
|
369
|
+
async function post(path,body){let r;try{r=await fetch(path,{method:'POST',headers:{'Content-Type':'application/json',Accept:'application/json','X-Study-Key':myKey()},body:JSON.stringify(body)})}catch(x){throw DOWN}const v=await r.json();if(!r.ok)throw v;return v}
|
|
370
|
+
|
|
371
|
+
// ---- the stopwatch (D-284): Start opens a session on the picked course, Stop logs its minutes
|
|
372
|
+
let session=read('semcon.session.v1',null),busy=false,note=null;
|
|
373
|
+
// D-287: the picker lists his main courses first, these two last, and starts on I3301 until he picks.
|
|
374
|
+
const LAST_COURSES=['DHR300','English L3'],DEFAULT_COURSE='I3301';
|
|
375
|
+
const pickList=()=>[...courses].sort((a,b)=>LAST_COURSES.includes(a.code)-LAST_COURSES.includes(b.code)); // a stable sort keeps code order
|
|
376
|
+
const picked=()=>courses.find(c=>c.code===store.course)||courses.find(c=>c.code===DEFAULT_COURSE)||pickList()[0]||null;
|
|
377
|
+
// D-287: the session's mode, his pick; Practice when he picks none. The server's five modes (MODES).
|
|
378
|
+
const MODES=[['practice','Practice','Solve problems'],['review-quiz','Review quiz','Test what you studied'],['exam-walkthrough','Past exam','Walk through a paper'],['mock','Mock exam','A timed full paper'],['explain-chapter','Learn a chapter','Read and understand']];
|
|
379
|
+
const DEFAULT_MODE='practice';
|
|
380
|
+
const pickedMode=()=>MODES.find(m=>m[0]===store.mode)||MODES.find(m=>m[0]===DEFAULT_MODE);
|
|
381
|
+
const modeName=id=>(MODES.find(m=>m[0]===id)||[id,id])[1];
|
|
382
|
+
const clock=()=>{const s=Math.max(0,Math.floor((Date.now()-session.t0)/1000));return [Math.floor(s/3600),Math.floor(s%3600/60),s%60].map(pad).join(':')};
|
|
383
|
+
const said=e=>(e?.message||'the server gave no reason')+(e?.fix?' '+e.fix:'');
|
|
384
|
+
// D-288: the server ends a session 4 hours after its start and then logs nothing (D-198). At 3h45m
|
|
385
|
+
// the page asks; with no answer it stops the session itself at 3h55m - five minutes early, because
|
|
386
|
+
// a browser runs a hidden tab's timers only about once a minute.
|
|
387
|
+
const ASK_AT=225*60,END_AT=235*60,EXPIRED_AT=240*60;
|
|
388
|
+
const elapsed=()=>session?Math.max(0,Math.floor((Date.now()-session.t0)/1000)):0;
|
|
389
|
+
let autoTried=false,askShown=false;
|
|
390
|
+
async function open(code,mode){const v=await post('/sessions',{code,mode});session={id:v.session_id,code,mode,t0:Date.now()};write('semcon.session.v1',session);autoTried=false;askShown=false}
|
|
391
|
+
async function start(){
|
|
392
|
+
const c=picked();if(!c||session||busy)return;
|
|
393
|
+
busy=true;note=null;draw();
|
|
394
|
+
try{await open(c.code,pickedMode()[0])}
|
|
395
|
+
catch(e){note={err:true,text:e?.code==='server_down'?'Could not start: the dashboard server is not running. Start it, then press Start again.':'Could not start: '+said(e)}}
|
|
396
|
+
busy=false;draw();
|
|
397
|
+
}
|
|
398
|
+
async function stop(how){
|
|
399
|
+
if(!session||busy)return;
|
|
400
|
+
if(elapsed()>=EXPIRED_AT){ // the server already ended it and logs nothing (D-198): end it here
|
|
401
|
+
note={err:true,text:`This session passed 4 hours, so it ended without logging. Log your real minutes on ${session.code} in your study chat.`};
|
|
402
|
+
session=null;write('semcon.session.v1',null);draw();return;
|
|
403
|
+
}
|
|
404
|
+
const s=session;busy=true;note=null;draw();
|
|
405
|
+
try{
|
|
406
|
+
const v=await post('/sessions/stop',{code:s.code,session_id:s.id,minutes:Math.round((Date.now()-s.t0)/60000)});
|
|
407
|
+
const logged=v.hours_entry_id?`Logged ${hm(v.minutes)} on ${s.code}.`:'Under 1 minute. Nothing logged.';
|
|
408
|
+
session=null;write('semcon.session.v1',null);
|
|
409
|
+
if(how==='continue'){
|
|
410
|
+
try{await open(s.code,s.mode||DEFAULT_MODE);note={text:logged+' A new session continues.'}}
|
|
411
|
+
catch(e){note={err:true,text:logged+' Could not start the next session: '+(e?.code==='server_down'?'the dashboard server is not running.':said(e))}}
|
|
412
|
+
}else note={text:how==='auto'?`Stopped before the 4-hour limit. ${logged} Press Start to keep going.`:logged};
|
|
413
|
+
}catch(e){
|
|
414
|
+
note={err:true,text:e?.code==='server_down'?'Could not stop: the dashboard server is not running. Your session is kept: start the server, then press Stop again.':'Could not stop: '+said(e)};
|
|
415
|
+
if(['session_expired','session_ended','not_found'].includes(e?.code)){session=null;write('semcon.session.v1',null)} // nothing left to stop
|
|
416
|
+
}
|
|
417
|
+
busy=false;draw();load().catch(()=>{});
|
|
418
|
+
}
|
|
419
|
+
setInterval(()=>{
|
|
420
|
+
if(!session)return;
|
|
421
|
+
const el=$('#digits');if(el)el.textContent=clock();const el2=$('#stripdigits');if(el2)el2.textContent=clock();
|
|
422
|
+
const t=elapsed();
|
|
423
|
+
if(t>=END_AT&&!busy&&!autoTried){autoTried=true;stop('auto')} // once: a failed stop stays shown
|
|
424
|
+
else if(t>=ASK_AT&&!askShown){askShown=true;draw()}
|
|
425
|
+
else paintNotice(); // the minutes so far, and gone past 4h
|
|
426
|
+
},500);
|
|
427
|
+
const watchCourse=()=>session?courses.find(x=>x.code===session.code)||{code:session.code,name:''}:picked();
|
|
428
|
+
function stopwatchView(left){
|
|
429
|
+
const c=watchCourse();
|
|
430
|
+
const m=session?[session.mode,modeName(session.mode||DEFAULT_MODE)]:pickedMode(),off=session||busy?'disabled':'';
|
|
431
|
+
const asking=session&&!note?.err&&elapsed()>=ASK_AT;
|
|
432
|
+
const line=session&¬e?.err?esc(note.text):asking?'Still studying? At 3h55m this session stops and logs itself.':session&¬e?`<i class="dot"></i>${esc(note.text)} Started ${esc(new Date(session.t0).toLocaleTimeString([], {hour:'2-digit',minute:'2-digit',hour12:false}))}.`:session?`<i class="dot"></i>Studying ${esc(session.code)}${session.mode?' · '+esc(modeName(session.mode)):''} · started ${esc(new Date(session.t0).toLocaleTimeString([], {hour:'2-digit',minute:'2-digit',hour12:false}))}`:esc(note?.text||'Pick a course and a mode, then press Start.');
|
|
433
|
+
return `<div class="watch-top">${left}
|
|
434
|
+
<div class="pickers">
|
|
435
|
+
<div class="menu"><button class="menu-btn" id="courseBtn" type="button" data-act="menu" data-id="course" aria-haspopup="listbox" aria-expanded="false" aria-label="Course to study" ${off}><b>${esc(c.code)}</b><span>${esc(c.name)}</span>${ARROWS}</button>
|
|
436
|
+
<div class="pop" id="coursePop" role="listbox" aria-label="Courses">${pickList().map(x=>`<button type="button" class="opt" role="option" data-act="pick" data-menu="course" data-id="${esc(x.code)}" aria-selected="${x===c}">${TICK}<b>${esc(x.code)}</b><span>${esc(x.name)}</span></button>`).join('')}</div></div>
|
|
437
|
+
<div class="menu"><button class="menu-btn" id="modeBtn" type="button" data-act="menu" data-id="mode" aria-haspopup="listbox" aria-expanded="false" aria-label="Session mode" ${off}><b>${esc(m[1])}</b>${ARROWS}</button>
|
|
438
|
+
<div class="pop" id="modePop" role="listbox" aria-label="Session modes">${MODES.map(([id,name,what])=>`<button type="button" class="opt" role="option" data-act="pick" data-menu="mode" data-id="${esc(id)}" aria-selected="${id===m[0]}">${TICK}<b>${esc(name)}</b><span>${esc(what)}${id===DEFAULT_MODE?' · default':''}</span></button>`).join('')}</div></div>
|
|
439
|
+
</div></div>
|
|
440
|
+
<div class="digits num" id="digits">${session?clock():'00:00:00'}</div>
|
|
441
|
+
<div class="status ${note?.err?'err':asking?'ask':''}" role="status">${line}</div>
|
|
442
|
+
${asking?`<div class="watch-actions"><button class="btn" type="button" data-act="continue" ${busy?'disabled':''}>Continue</button><button class="btn stop" type="button" data-act="stop" ${busy?'disabled':''}>Stop</button></div>`
|
|
443
|
+
:`<button class="btn ${session?'stop':''}" type="button" data-act="${session?'stop':'start'}" ${busy?'disabled':''}>${session?'Stop':'Start'}</button>`}`;
|
|
444
|
+
}
|
|
445
|
+
const MENUS=['course','mode','taskCourse','logCourse'];
|
|
446
|
+
function menu(name,open){for(const n of MENUS){const p=$('#'+n+'Pop'),b=$('#'+n+'Btn');if(!p||!b)continue;const on=open&&n===name;p.classList.toggle('open',on);b.setAttribute('aria-expanded',on);if(on)p.querySelector('[aria-selected="true"]')?.focus()}}
|
|
447
|
+
const openMenu=()=>MENUS.find(n=>$('#'+n+'Pop')?.classList.contains('open'))||null;
|
|
448
|
+
|
|
449
|
+
// ---- Today: log past hours in the stopwatch card (D-307, D-309)
|
|
450
|
+
// Two tabs; a running stopwatch stays in a strip on the Log tab
|
|
451
|
+
const MODE_NAME={stopwatch:'Stopwatch',log:'Log past hours'};
|
|
452
|
+
const watchMode=()=>store.watchTab==='log'?'log':'stopwatch';
|
|
453
|
+
const logDraft={code:null,minutes:'',date:null,time:'',busy:false,msg:null};
|
|
454
|
+
const logCourse=()=>pickList().find(c=>c.code===logDraft.code)||watchCourse();
|
|
455
|
+
function tabsHead(mode){
|
|
456
|
+
return `<div class="wtabs" role="tablist" aria-label="How to record time">${['stopwatch','log'].map(id=>`<button class="wtab" type="button" role="tab" id="wtab-${id}" aria-selected="${mode===id}" aria-controls="wpanel" tabindex="${mode===id?0:-1}" data-act="wtab" data-id="${id}">${MODE_NAME[id]}</button>`).join('')}</div>`;
|
|
457
|
+
}
|
|
458
|
+
function runStrip(){
|
|
459
|
+
return `<div class="runstrip"><i class="dot"></i><span class="num" id="stripdigits">${clock()}</span><span class="muted">${esc(session.code)}${session.mode?' · '+esc(modeName(session.mode)):''}</span><button class="btn stop" type="button" data-act="stop" ${busy?'disabled':''}>Stop</button>${note?.err?`<p class="err">${esc(note.text)}</p>`:''}</div>`;
|
|
460
|
+
}
|
|
461
|
+
function logView(left){
|
|
462
|
+
const c=logCourse(),d=logDraft,off=d.busy?'disabled':'';
|
|
463
|
+
const pop=pickList().map(x=>`<button type="button" class="opt" role="option" data-act="pick" data-menu="logCourse" data-id="${esc(x.code)}" aria-selected="${x.code===c.code}">${TICK}<b>${esc(x.code)}</b><span>${esc(x.name)}</span></button>`).join('');
|
|
464
|
+
return `<div class="watch-top">${left}</div>${session?runStrip():''}
|
|
465
|
+
<form class="logform" id="logform">
|
|
466
|
+
<div class="lf-row">
|
|
467
|
+
<div class="lf-field"><span id="lfCourseLabel">Course</span>
|
|
468
|
+
<div class="menu"><button class="menu-btn" id="logCourseBtn" type="button" data-act="menu" data-id="logCourse" aria-haspopup="listbox" aria-expanded="false" aria-labelledby="lfCourseLabel logCourseBtn" ${off}><b>${esc(c.code)}</b><span>${esc(c.name)}</span>${ARROWS}</button>
|
|
469
|
+
<div class="pop" id="logCoursePop" role="listbox" aria-label="Courses">${pop}</div></div></div>
|
|
470
|
+
<label class="lf-field">Minutes<input name="minutes" type="number" inputmode="numeric" min="1" max="720" step="1" required value="${esc(d.minutes)}" aria-label="Minutes studied, 1 to 720" ${off}></label>
|
|
471
|
+
</div>
|
|
472
|
+
<div class="lf-row">
|
|
473
|
+
<label class="lf-field">Date<input name="date" type="date" required max="${TODAY}" value="${esc(d.date||TODAY)}" aria-label="Date studied" ${off}></label>
|
|
474
|
+
<label class="lf-field">Time (optional)<input name="time" type="time" value="${esc(d.time)}" aria-label="Start time, optional" ${off}></label>
|
|
475
|
+
</div>
|
|
476
|
+
<p class="lf-hint">Date only: counted as ending that day (today: ending now).</p>
|
|
477
|
+
<div class="status ${d.msg?.err?'err':''}" role="status">${d.msg?esc(d.msg.text):''}</div>
|
|
478
|
+
<button class="btn" type="submit" ${off}>${d.busy?'Logging…':'Log'}</button>
|
|
479
|
+
</form>`;
|
|
480
|
+
}
|
|
481
|
+
function watch(){
|
|
482
|
+
const c=watchCourse();
|
|
483
|
+
if(!c)return `<div class="card watch"><div class="watch-top"><span class="label">Stopwatch</span></div><div class="digits num">00:00:00</div><div class="status">Add a course to use the stopwatch.</div></div>`;
|
|
484
|
+
const mode=watchMode(),cls=`card watch ${session?'running':''}`;
|
|
485
|
+
const left=tabsHead(mode);
|
|
486
|
+
return `<div class="${cls}" role="tabpanel" id="wpanel" aria-labelledby="wtab-${mode}">${mode==='log'?logView(left):stopwatchView(left)}</div>`;
|
|
487
|
+
}
|
|
488
|
+
async function logHours(f){
|
|
489
|
+
const d=logDraft,c=logCourse();if(d.busy||!c)return;
|
|
490
|
+
const fd=new FormData(f);d.minutes=String(fd.get('minutes')||'');d.date=String(fd.get('date')||'');d.time=String(fd.get('time')||'');
|
|
491
|
+
const minutes=Number(d.minutes),date=d.date||TODAY;
|
|
492
|
+
if(!Number.isInteger(minutes)||minutes<1||minutes>720){d.msg={err:true,text:'Not logged: minutes must be a whole number from 1 to 720.'};draw();return}
|
|
493
|
+
if(date>TODAY){d.msg={err:true,text:'Not logged: the date cannot be in the future.'};draw();return}
|
|
494
|
+
d.busy=true;d.msg=null;draw();
|
|
495
|
+
try{
|
|
496
|
+
await post('/hours',{code:c.code,minutes,started_at:d.time?`${date}T${d.time}`:date});
|
|
497
|
+
d.minutes='';d.msg={text:`Logged ${minutes} min on ${c.code} · ${fmt(date)}`};d.busy=false;
|
|
498
|
+
try{await load()}catch(x){d.msg.text+='. The page could not refresh: reload it.';draw()}
|
|
499
|
+
}catch(e){d.busy=false;d.msg={err:true,text:e?.code==='server_down'?'Not logged: the dashboard server is not running.':'Not logged: '+said(e)};draw()}
|
|
500
|
+
$('#logform input[name="minutes"]')?.focus();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// ---- Today: the week, today's minutes, the streak (D-286)
|
|
504
|
+
// D-290: "Edit target" writes a new capacity row from the Monday of this week, through POST /capacity.
|
|
505
|
+
const GOAL_CLOSED={open:false,draft:null,busy:false,err:null};
|
|
506
|
+
let goalEdit={...GOAL_CLOSED};
|
|
507
|
+
const monday=()=>{const d=new Date();d.setDate(d.getDate()-(d.getDay()+6)%7);return isoDay(d)};
|
|
508
|
+
async function saveGoal(hours){
|
|
509
|
+
goalEdit.busy=true;goalEdit.err=null;draw();
|
|
510
|
+
try{await post('/capacity',{hours_per_week:hours,from_date:monday()});goalEdit={...GOAL_CLOSED};await load()}
|
|
511
|
+
catch(e){goalEdit.busy=false;goalEdit.err=e?.code==='server_down'?'Not saved: the dashboard server is not running.':'Not saved: '+said(e);draw()}
|
|
512
|
+
}
|
|
513
|
+
function goalForm(hours){
|
|
514
|
+
if(!goalEdit.open)return `<button class="quiet edit" type="button" data-act="goal">${hours==null?'Set target':'Edit target'}</button>`;
|
|
515
|
+
const v=goalEdit.draft??(hours==null?'':String(hours)),off=goalEdit.busy?'disabled':'';
|
|
516
|
+
return `<form class="goal" id="goal"><input name="hours" type="number" inputmode="decimal" min="0.5" max="112" step="any" required value="${esc(v)}" aria-label="Weekly target in hours" ${off}><span class="muted">h/week</span><button class="quiet" type="submit" ${off}>Save</button><button class="quiet" type="button" data-act="goal-cancel" ${off}>Cancel</button>${goalEdit.err?`<p class="err">${esc(goalEdit.err)}</p>`:''}</form>`;
|
|
517
|
+
}
|
|
518
|
+
function weekCard(){
|
|
519
|
+
const t=raw.study_time,total=t.week_days.reduce((a,b)=>a+b,0),hours=raw.capacity?.declared_hours_per_week,target=hours==null?null:Math.round(hours*60);
|
|
520
|
+
const share=target?Math.min(1,total/target):0,top=Math.max(...t.week_days,target?target/7:60),wd=(new Date().getDay()+6)%7;
|
|
521
|
+
return `<div class="card week">
|
|
522
|
+
<svg class="ring ${target==null?'none':''} ${target&&total>=target?'met':''}" viewBox="0 0 120 120" aria-hidden="true"><circle class="track" cx="60" cy="60" r="52"/><circle class="fill" id="ringfill" cx="60" cy="60" r="52" stroke-dasharray="${RING}" stroke-dashoffset="${first?RING:RING*(1-share)}" data-to="${RING*(1-share)}"/></svg>
|
|
523
|
+
<div><div class="label">This week</div><div class="big num">${hm(total)}</div><div class="muted">${target==null?'No weekly target set':`of ${hm(target)} target · ${Math.round(total/target*100)}%`}</div>${goalForm(hours)}</div>
|
|
524
|
+
<div class="bars">${t.week_days.map((m,i)=>`<div class="${i===wd?'today':''}" title="${hm(m)}"><b style="height:${Math.round(m/top*100)}%"></b>${'MTWTFSS'[i]}</div>`).join('')}</div>
|
|
525
|
+
</div>`;
|
|
526
|
+
}
|
|
527
|
+
function tiles(){
|
|
528
|
+
const t=raw.study_time,n=Number(t.streak_days);
|
|
529
|
+
return `<div class="tiles">
|
|
530
|
+
<div class="card tile"><div class="label">Today</div><div class="big num">${hm(t.today_minutes)}</div><div class="muted">studied</div></div>
|
|
531
|
+
<div class="card tile"><div class="label">Streak</div><div class="big num">${n} ${n===1?'day':'days'}</div>${t.streak_at_risk?'<div class="risk">Study today to keep it</div>':`<div class="muted">${n?'in a row':'No streak yet'}</div>`}</div>
|
|
532
|
+
</div>`;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// ---- Today: classes and tasks. Setup items stay on the Plan page (D-285).
|
|
536
|
+
function classes(){
|
|
537
|
+
const wd=new Date().getDay()||7,now=pad(new Date().getHours())+':'+pad(new Date().getMinutes());
|
|
538
|
+
const xs=meetings.filter(m=>m.weekday===wd).sort((a,b)=>(a.start||'').localeCompare(b.start||''));
|
|
539
|
+
return `<div class="card list"><div class="list-head"><b>Classes</b><span class="muted">${xs.length} today</span></div>${xs.length?xs.map(m=>{
|
|
540
|
+
const c=courses.find(c=>c.course_id===m.course_id),kind=m.kind?m.kind[0].toUpperCase()+m.kind.slice(1):'Class';
|
|
541
|
+
return `<div class="row ${m.end&&m.end<=now?'past':''}"><time>${esc(m.start)}<small>${esc(m.end)}</small></time><div><div class="t">${esc(m.code||c?.code||'Class')}${c?' · '+esc(c.name):''}</div><div class="m">${esc(kind)} · ${m.room?esc(m.room):'room unknown'}</div></div>${m.start<=now&&now<m.end?'<span class="tag now">Now</span>':''}</div>`}).join(''):'<p class="empty">No classes today.</p>'}</div>`;
|
|
542
|
+
}
|
|
543
|
+
const LANE_NAME={review:'Review',study:'Study',setup:'Setup',custom:'Personal'};
|
|
544
|
+
// his own tasks, as Today shows them: open ones and ones ticked today (Plan reads them too, D-302)
|
|
545
|
+
const personal=()=>store.custom.filter(x=>!x.done||x.doneDay===TODAY).map(x=>({uid:'custom:'+x.id,custom:x,lane:'custom',what:x.title,course:courses.find(c=>c.code===x.course)||null,chapter:null,mins:x.mins??null}));
|
|
546
|
+
function todayTasks(){
|
|
547
|
+
return personal().concat(plan.filter(x=>x.lane!=='setup'&&status(x)!=='skipped'));
|
|
548
|
+
}
|
|
549
|
+
const isDone=it=>it.custom?!!it.custom.done:status(it)==='done';
|
|
550
|
+
const taskMeta=it=>[LANE_NAME[it.lane],it.course?.code,it.chapter,it.custom?(it.mins?it.mins+' min':null):(it.mins==null?'time unknown':it.mins+' min')].filter(Boolean).map(esc).join(' · ');
|
|
551
|
+
// D-301: a personal task can name a course, picked in the stopwatch's menu style; the menu keeps
|
|
552
|
+
// his last pick for the next task
|
|
553
|
+
let taskDraft='';
|
|
554
|
+
const taskCourse=()=>pickList().find(c=>c.code===store.taskCourse)||null;
|
|
555
|
+
const courseSelect=()=>{const on=taskCourse(),opt=(id,code,name)=>`<button type="button" class="opt" role="option" data-act="pick" data-menu="taskCourse" data-id="${esc(id)}" aria-selected="${(on?.code||'')===id}">${TICK}<b>${esc(code)}</b><span>${esc(name)}</span></button>`;
|
|
556
|
+
return `<div class="menu"><button class="menu-btn" id="taskCourseBtn" type="button" data-act="menu" data-id="taskCourse" aria-haspopup="listbox" aria-expanded="false" aria-label="Course for the task"><b>${esc(on?on.code:'No course')}</b>${ARROWS}</button>
|
|
557
|
+
<div class="pop" id="taskCoursePop" role="listbox" aria-label="Courses">${opt('','No course','')}${pickList().map(c=>opt(c.code,c.code,c.name)).join('')}</div></div>`};
|
|
558
|
+
// D-291: collapsed, the card shows one task - the first open one, or the first when all are done
|
|
559
|
+
function tasks(){
|
|
560
|
+
const all=todayTasks(),open=all.filter(x=>!isDone(x)).length,folded=!!store.tasksFolded&&all.length>1;
|
|
561
|
+
const xs=folded?[all.find(x=>!isDone(x))||all[0]]:all;
|
|
562
|
+
const toggle=all.length>1?`<button class="fold-btn ${folded?'':'up'}" type="button" data-act="fold-tasks" aria-expanded="${!folded}" aria-controls="taskrows" aria-label="${folded?`Show all ${all.length} tasks`:'Collapse to the first task'}" title="${folded?`Show all ${all.length}`:'Collapse'}">${CHEV}</button>`:'';
|
|
563
|
+
return `<div class="card list" id="taskrows"><div class="list-head"><b>Tasks</b><span class="head-end"><span class="muted">${open} open</span>${toggle}</span></div>${xs.length?xs.map(it=>`<div class="row ${isDone(it)?'done':''}"><button class="check" type="button" data-act="done" data-id="${esc(it.uid)}" aria-pressed="${isDone(it)}" aria-label="Mark done: ${esc(it.what)}">${WHITE_TICK}</button><div><div class="t">${esc(it.what)}</div><div class="m">${taskMeta(it)}</div></div>${isDone(it)?'':`<button class="quiet" type="button" data-act="skip" data-id="${esc(it.uid)}">Skip</button>`}</div>`).join(''):'<p class="empty">No open tasks. The plan shows nothing to study right now.</p>'}
|
|
564
|
+
<form class="add" id="add"><input name="title" required maxlength="120" placeholder="Add a task" aria-label="Personal task" value="${esc(taskDraft)}">${courseSelect()}<button class="quiet" type="submit">Add</button></form></div>`;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// ---- Today: the honesty panel - four numbers, never blended (D-12, D-304)
|
|
568
|
+
const hrs=h=>(Math.round(h*10)/10)+' h';
|
|
569
|
+
const honCard=(label,sub,body,title)=>`<div class="card hon"${title?` title="${esc(title)}"`:''}><div class="label">${label}</div><p class="muted">${sub}</p>${body}</div>`;
|
|
570
|
+
// folded, the card lists the first COVER_SHOWN courses, so it stands level with Adherence beside it
|
|
571
|
+
const COVER_SHOWN=4;
|
|
572
|
+
function coverageCard(){
|
|
573
|
+
const all=pickList(),more=all.length>COVER_SHOWN,open=!!store.coverageOpen;
|
|
574
|
+
const toggle=more?`<button class="quiet more" type="button" data-act="fold-coverage" aria-expanded="${open}" aria-controls="coverrows">${open?'Show fewer':`Show all ${all.length}`}</button>`:'';
|
|
575
|
+
const rows=(open||!more?all:all.slice(0,COVER_SHOWN)).map(c=>{const r=c.coverage;
|
|
576
|
+
return r?`<li title="${esc(r.tier_note)}"><span class="code" style="--h:${hue(c)}"><i></i>${esc(c.code)}</span><b class="num">${(r.value*100).toFixed(0)}%</b><em>${esc(r.denominator_tier)}</em><small>${esc(r.tier_note)} · plan of ${fmt(r.computed_at.slice(0,10))}</small></li>`
|
|
577
|
+
:`<li><span class="code" style="--h:${hue(c)}"><i></i>${esc(c.code)}</span><b class="num">—</b><em>${esc(c.coverage_tier||'unknown')}</em><small>unknown - no reading yet</small></li>`}).join('');
|
|
578
|
+
return honCard('Coverage at exam','How much of each course the plan reaches by its exam, one figure per course.',rows?`<ul class="hon-rows" id="coverrows">${rows}</ul>${toggle}`:'<p class="muted">No courses yet.</p>');
|
|
579
|
+
}
|
|
580
|
+
function adherenceCard(){
|
|
581
|
+
const a=raw.metrics?.adherence;
|
|
582
|
+
if(!a)return honCard('Adherence this week','Share of this week’s logged minutes that went to a shown plan item.','<div class="big num">—</div><div class="muted">no reading yet</div>');
|
|
583
|
+
const off=Object.entries(a.deviations||{}).filter(([,m])=>m>0),mi=a.missing_input||0;
|
|
584
|
+
const list=off.map(([r,m])=>`<li><span>${esc(r)}</span><em>${esc(m)} min</em></li>`).concat(mi?[`<li><span>missing input</span><em>${esc(mi)} min</em></li>`]:[]).join('');
|
|
585
|
+
return honCard('Adherence this week','Share of this week’s logged minutes that went to a shown plan item.',
|
|
586
|
+
`<div class="big num">${a.adherence==null?'—':Math.round(a.adherence*100)+'%'}</div><div class="muted">${a.adherence==null?'no minutes to score':`${esc(a.in_plan)} of ${esc(a.minutes-mi)} minutes went to a shown plan item`}</div>
|
|
587
|
+
<p class="meta">${a.week_start?'Week of '+fmt(a.week_start):'This week'}</p>${list?`<ul class="hon-rows plain">${list}</ul>`:'<p class="meta">No off-plan minutes.</p>'}${mi?'<p class="meta">Missing input is a gap in what was logged, not a miss.</p>':''}`);
|
|
588
|
+
}
|
|
589
|
+
function sensitivityCard(){
|
|
590
|
+
const g=raw.metrics?.guess_sensitivity;
|
|
591
|
+
if(!g)return honCard('Guess sensitivity','How much the top of the plan leans on inferred exam edges.','<div class="big num">—</div><div class="muted">not measurable yet</div>');
|
|
592
|
+
return honCard('Guess sensitivity','How much the top of the plan leans on inferred exam edges.',`<div class="big num">${g.changed==null?'—':esc(g.changed+' of '+g.shown)}</div><div class="muted">${g.changed==null?'not measurable yet':'top topics changed by dropping inferred exam edges'}</div>`,'the latest plan ranked again with every inferred exam edge dropped (D-280)');
|
|
593
|
+
}
|
|
594
|
+
function shortfallCard(){
|
|
595
|
+
const f=raw.shortfall,sub='Study hours needed against hours declared free, up to the last exam.';
|
|
596
|
+
if(!f)return honCard('Shortfall',sub,'<div class="big num">—</div><div class="muted">unknown - no reading yet</div>');
|
|
597
|
+
const known=f.gap!=null&&f.capacity!=null;
|
|
598
|
+
const verdict=!known?'unknown - no exam ahead':f.short?`short by ${hrs(-f.gap)}`:`no shortfall, ${hrs(f.gap)} to spare`;
|
|
599
|
+
const nc=(f.not_counted||[]).map(n=>`${esc(n.code)} (${esc(n.reason)})`).join(' · ');
|
|
600
|
+
const offers=(f.offers||[]).map(o=>`<li><span>${esc(o.kind)}${o.code?' · '+esc(o.code):''}</span><em>${hrs(o.hours)}</em></li>`).join('');
|
|
601
|
+
return honCard('Shortfall',sub,
|
|
602
|
+
`<div class="big num">${verdict}</div>
|
|
603
|
+
<ul class="hon-rows plain"><li><span>Need <small>${esc(f.need_tier)}</small></span><em>${f.need==null?'unknown':hrs(f.need)}</em></li><li><span>Capacity <small>${esc(f.capacity_tier)}</small></span><em>${f.capacity==null?'unknown':hrs(f.capacity)}</em></li></ul>
|
|
604
|
+
${nc?`<p class="meta">Not counted: ${nc}</p>`:''}${offers?`<p class="label hon-sub">Offers, in order</p><ul class="hon-rows plain">${offers}</ul>`:''}`);
|
|
605
|
+
}
|
|
606
|
+
const honesty=()=>`<h2>How the plan is doing</h2><p class="sub">Four separate numbers. The page never blends them into one score.</p><div class="pair">${coverageCard()}${adherenceCard()}</div><div class="pair">${sensitivityCard()}${shortfallCard()}</div>`;
|
|
607
|
+
|
|
608
|
+
// ---- Today: one card per course, with the papers he ticks as completed (D-285)
|
|
609
|
+
const paperName=p=>`${p.assessment_name.replace(/ exam$/i,'')} · ${new Date(p.session_date+'T00:00:00').toLocaleDateString(undefined,p.session_date_approx?{month:'short',year:'numeric'}:{day:'numeric',month:'short',year:'numeric'})} · ${p.session_type==='second'?'2nd':'1st'} session`;
|
|
610
|
+
const fold=(id,head,body)=>`<details class="fold" data-fold="${esc(id)}" ${openFolds.has(id)?'open':''}><summary>${head}</summary>${body}</details>`;
|
|
611
|
+
/* D-267: a taught chapter with no topic beside the topics no chapter reaches - a question, not an alarm */
|
|
612
|
+
function unconfirmed(c){const u=c.unconfirmed;if(!u||!u.chapters.length)return '';
|
|
613
|
+
return fold('u:'+c.course_id,`<b>No topic: ${u.chapters.map(x=>esc(x.chapter)).join(', ')}</b><span>${u.topics.length} ${u.topics.length===1?'topic':'topics'}</span>${CHEV}`,`<p>Does ${u.chapters.length===1?'it':'one of them'} teach any of these? ${u.topics.map(t=>esc(t.name)).join(' · ')}</p>`)}
|
|
614
|
+
function papers(c){const xs=c.past_papers||[];if(!xs.length)return '<p class="nopapers">No past papers yet</p>';
|
|
615
|
+
const done=xs.filter(p=>store.papers[p.past_exam_id]).length;
|
|
616
|
+
return fold('p:'+c.course_id,`<b>Past exams completed</b><span>${done} of ${xs.length}</span>${CHEV}<div class="meter"><em style="width:${done/xs.length*100}%"></em></div>`,
|
|
617
|
+
xs.map(p=>{const on=!!store.papers[p.past_exam_id],name=paperName(p);return `<label class="paper ${on?'done':''}"><button class="check" type="button" data-act="paper" data-id="${esc(p.past_exam_id)}" aria-pressed="${on}" aria-label="Completed: ${esc(name)}">${WHITE_TICK}</button><span>${esc(name)}</span></label>`}).join(''))}
|
|
618
|
+
function courseCards(){
|
|
619
|
+
if(!courses.length)return '<p class="empty">No courses yet.</p>';
|
|
620
|
+
return `<div class="courses">${pickList().map(c=>{ // D-291: DHR300 and English last, as in the picker (D-287)
|
|
621
|
+
const exams=(raw.assessment_slots||[]).filter(a=>a.course_id===c.course_id).sort((a,b)=>(a.date||'9').localeCompare(b.date||'9')),next=exams.find(a=>a.date&&a.date>=TODAY),left=next?daysTo(next.date):null;
|
|
622
|
+
const xs=plan.filter(x=>x.course===c),meta=[c.credits!=null?c.credits+' credits':null,c.instructor||null,c.target_grade!=null?'target '+c.target_grade:null].filter(Boolean).join(' · ');
|
|
623
|
+
const strat=c.conceded?'Conceded':(c.strategy&&c.strategy!=='default'?c.strategy:null);
|
|
624
|
+
return `<article class="card course"><div class="code" style="--h:${hue(c)}"><i></i>${esc(c.code)}</div><h3>${esc(c.name)}</h3>${meta?`<p class="meta">${esc(meta)}</p>`:''}
|
|
625
|
+
<div class="stats"><div><b>${hm(c.minutes_logged)}</b><span>logged</span></div><div><b>${left==null?'—':left+(left===1?' day':' days')}</b><span>${next?esc(next.name)+' · '+fmt(next.date):'no dated exam'}</span></div></div>
|
|
626
|
+
${strat?`<p class="meta">Strategy · ${esc(strat)}</p>`:''}
|
|
627
|
+
${exams.length?`<ul class="assess">${exams.map(a=>`<li><span>${esc(a.name)}<small>${fmt(a.date)} · ${a.weight!=null?esc(a.weight)+'%':'weight unknown'}</small></span><em>${a.mark==null?'ungraded':esc(a.mark)+'%'}</em></li>`).join('')}</ul>`:''}
|
|
628
|
+
<div class="foot">${unconfirmed(c)}${papers(c)}${xs.length?`<a class="planlink" href="#/plan?course=${encodeURIComponent(c.course_id)}">View ${xs.length} ranked ${xs.length===1?'task':'tasks'}</a>`:''}</div></article>`}).join('')}</div>`;
|
|
629
|
+
}
|
|
630
|
+
function todayPage(){
|
|
631
|
+
const next=(raw.assessment_slots||[]).filter(a=>a.date&&a.date>=TODAY).sort((a,b)=>a.date.localeCompare(b.date))[0],d=next?daysTo(next.date):null;
|
|
632
|
+
return `<div class="eyebrow">${esc(new Date().toLocaleDateString(undefined,{weekday:'long',day:'numeric',month:'long'}))}${next?` · ${d===0?'today:':d+(d===1?' day to':' days to')} ${esc(next.name)}`:''}</div><h1>Today</h1>
|
|
633
|
+
<div class="hero">${watch()}<div class="side">${weekCard()}${tiles()}</div></div>
|
|
634
|
+
<h2>Today’s schedule</h2><div class="cols">${classes()}${tasks()}</div>${honesty()}
|
|
635
|
+
<h2>Courses</h2>${courseCards()}`;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// ---- Plan: study, then review, then setup (D-285), each in the server's rank order
|
|
639
|
+
const LANES={study:['Study','Topics to learn, ranked by exam stakes and effort.'],review:['Review','Revision of topics you already studied.'],setup:['Setup','Get material in: past papers and chapters the plan still needs.']};
|
|
640
|
+
function planPage(){
|
|
641
|
+
const own=personal(),created=raw.plan?.current?.created_at,cf=param('course')||'all',withItems=courses.filter(c=>plan.some(x=>x.course===c)||own.some(x=>x.course===c));
|
|
642
|
+
const chip=(id,label)=>`<a class="chip" href="#/plan${id==='all'?'':'?course='+encodeURIComponent(id)}" aria-current="${cf===id}">${esc(label)}</a>`;
|
|
643
|
+
return `<div class="eyebrow">All ranked work · ${created?'refreshed '+fmt(created.slice(0,10)):'no plan stored yet'}</div><h1>Plan</h1>
|
|
644
|
+
<p class="sub">Study first, then review, then setup. The server ranks; this page only shows. Your own tasks sit beside Study, unranked.</p>
|
|
645
|
+
${withItems.length>1?`<div class="chips">${chip('all','All courses')}${withItems.map(c=>chip(c.course_id,c.code)).join('')}</div>`:''}
|
|
646
|
+
<div class="lanes">${rankedLane('study',cf)}${personalLane(own,cf)}${rankedLane('review',cf)}${rankedLane('setup',cf)}</div>${systemWork()}${trialsSwitch()}`;
|
|
647
|
+
}
|
|
648
|
+
// D-311: System work under the lanes. The server sends papers only on a surplus (D-310) and proposed
|
|
649
|
+
// rules always (D-368): this page is the only place to confirm one. An empty list means no block.
|
|
650
|
+
let workEdit={busy:null,err:null};
|
|
651
|
+
async function confirmDirective(id){
|
|
652
|
+
workEdit={busy:id,err:null};draw();
|
|
653
|
+
try{await post('/directives/confirm',{directive_id:id});workEdit={busy:null,err:null};await load()}
|
|
654
|
+
catch(e){workEdit={busy:null,err:{id,text:e?.code==='server_down'?'Not confirmed: the dashboard server is not running.':'Not confirmed: '+said(e)}};draw()}
|
|
655
|
+
}
|
|
656
|
+
function systemWork(){
|
|
657
|
+
const w=raw.system_work||{papers:[],directives:[]};
|
|
658
|
+
const lane=(name,desc,rows)=>rows.length?`<section class="lane system"><h2>${name}<small>${desc}</small></h2><div class="card list">${rows.join('')}</div></section>`:'';
|
|
659
|
+
const papers=w.papers.map(p=>`<div class="row"><span class="rank">–</span><div><div class="t">${esc(p.reason)}</div><div class="m">${esc(p.code)} · past papers · moves no marks</div></div><span></span></div>`);
|
|
660
|
+
const rules=w.directives.map(d=>{const busy=workEdit.busy===d.id,err=workEdit.err?.id===d.id?workEdit.err.text:null;
|
|
661
|
+
return `<div class="row"><span class="rank">–</span><div><div class="t">${esc(d.text)}</div><div class="m">Proposed rule for generated items · ${esc(d.applies_to)}</div>${err?`<p class="err">${esc(err)}</p>`:''}</div><button class="quiet" type="button" data-act="confirm" data-id="${esc(d.id)}" ${busy?'disabled':''}>${busy?'Confirming…':'Confirm'}</button></div>`});
|
|
662
|
+
return lane('Waiting for your yes','Rules your AI proposed for what it writes. Nothing uses one until you confirm it.',rules)
|
|
663
|
+
+lane('System work','The plan has hours to spare, so these show. They improve the system, not your marks.',papers);
|
|
664
|
+
}
|
|
665
|
+
// D-317: the trials switch, always on Plan - off by default (D-312). The same write as study_set_trials.
|
|
666
|
+
let trialsEdit={busy:false,err:null};
|
|
667
|
+
async function setTrials(on){
|
|
668
|
+
trialsEdit={busy:true,err:null};draw();
|
|
669
|
+
try{await post('/trials',{on});trialsEdit={busy:false,err:null};await load()}
|
|
670
|
+
catch(e){trialsEdit={busy:false,err:e?.code==='server_down'?'Not changed: the dashboard server is not running.':'Not changed: '+said(e)};draw()}
|
|
671
|
+
}
|
|
672
|
+
function trialsSwitch(){
|
|
673
|
+
const on=!!raw.settings?.trials_on,off=trialsEdit.busy?'disabled':'';
|
|
674
|
+
return `<section class="lane trials"><h2>Generated-question trials<small>${on?'On: each past-paper walkthrough hides one generated question and asks "real or generated?" after each answer.':'Off: walkthroughs show only the questions of the paper.'}</small></h2><div class="card list"><div class="row"><span class="rank">–</span><div><div class="t">${on?'Trials are on':'Trials are off'}</div><div class="m">They test the generator, not you. They add one question to every walkthrough answer.</div>${trialsEdit.err?`<p class="err">${esc(trialsEdit.err)}</p>`:''}</div><button class="quiet" type="button" data-act="trials" data-on="${on?'false':'true'}" ${off}>${trialsEdit.busy?'Saving…':on?'Turn off':'Turn on'}</button></div></div></section>`;
|
|
675
|
+
}
|
|
676
|
+
// D-302: Study and Personal side by side, Review and Setup under them; each row's cards share one height
|
|
677
|
+
function rankedLane(k,cf){
|
|
678
|
+
const [name,desc]=LANES[k],xs=plan.filter(x=>x.lane===k&&(cf==='all'||x.course?.course_id===cf)),hidden=raw.plan?.current?.lanes?.[k]?.hidden||0;
|
|
679
|
+
return `<section class="lane"><h2>${name}<small>${desc}</small></h2><div class="card list"><div class="list-head"><span class="muted">${xs.length} shown${hidden?` · ${esc(hidden)} more not shown by the server`:''}</span></div>${xs.length?xs.map(it=>{const st=status(it);
|
|
680
|
+
return `<div class="row"><span class="rank">${esc(it.rank??'–')}</span><div><div class="t">${esc(it.what)}</div><div class="m">${[it.course?it.course.code+' · '+it.course.name:null,it.chapter].filter(Boolean).map(esc).join(' · ')}</div>${it.why&&it.why!==it.what?`<details class="why"><summary>Why ranked</summary><p>${esc(it.why)}</p></details>`:''}</div>${st!=='upcoming'?`<span class="tag">${esc(st)}</span>`:k==='setup'?'':`<span class="tag">${it.mins==null?'time unknown':esc(it.mins)+' min'}</span>`}</div>`}).join(''):'<p class="empty">Nothing in this lane right now.</p>'}</div></section>`;
|
|
681
|
+
}
|
|
682
|
+
// D-302: his own tasks, filtered by the same chip, with no rank; ticking stays on Today
|
|
683
|
+
function personalLane(own,cf){
|
|
684
|
+
const xs=own.filter(x=>cf==='all'||x.course?.course_id===cf);
|
|
685
|
+
return `<section class="lane"><h2>Personal<small>Tasks you added on Today. Not ranked.</small></h2><div class="card list"><div class="list-head"><span class="muted">${xs.length} shown</span></div>${xs.length?xs.map(it=>
|
|
686
|
+
`<div class="row ${isDone(it)?'done':''}"><span class="rank">•</span><div><div class="t">${esc(it.what)}</div><div class="m">${it.course?esc(it.course.code+' · '+it.course.name):'No course'}</div></div>${isDone(it)?'<span class="tag">done</span>':''}</div>`).join('')
|
|
687
|
+
:`<p class="empty">${cf==='all'?'No personal tasks. Add one on Today.':'No personal tasks for this course.'}</p>`}</div></section>`;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// ---- Schedule: the week's classes
|
|
691
|
+
function schedulePage(){
|
|
692
|
+
const sem=raw.semester||{},left=sem.end?daysTo(sem.end):null,head=`<div class="eyebrow">Class timetable${sem.name?' · '+esc(sem.name):''} · ${left==null?'semester end unknown':Math.max(0,left)+' days to semester end'}</div><h1>Schedule</h1>`;
|
|
693
|
+
const min=t=>{const [h,m]=String(t||'').split(':').map(Number);return (h||0)*60+(m||0)},usable=meetings.filter(m=>m.start&&m.end&&m.weekday>=1&&m.weekday<=5);
|
|
694
|
+
if(!meetings.length)return head+'<p class="empty">The timetable has no meetings entered.</p>';
|
|
695
|
+
if(!usable.length)return head+'<p class="empty">Meeting times are not available.</p>';
|
|
696
|
+
const base=Math.floor(Math.min(...usable.map(m=>min(m.start)))/60),hrs=Math.max(4,Math.ceil(Math.max(...usable.map(m=>min(m.end)))/60)-base),wdNow=new Date().getDay()||7,now=new Date().getHours()*60+new Date().getMinutes();
|
|
697
|
+
// meetings that touch in time form one group; each takes the first free lane, and the group shares one width
|
|
698
|
+
const place=xs=>{let group=[],end=-1;const out=[],close=()=>{const n=Math.max(...group.map(g=>g.lane))+1;group.forEach(g=>out.push({...g,n}));group=[]};
|
|
699
|
+
[...xs].sort((a,b)=>min(a.start)-min(b.start)||min(a.end)-min(b.end)).forEach(m=>{if(group.length&&min(m.start)>=end){close();end=-1}const used=group.filter(g=>min(g.m.end)>min(m.start)).map(g=>g.lane);let lane=0;while(used.includes(lane))lane++;group.push({m,lane});end=Math.max(end,min(m.end))});
|
|
700
|
+
if(group.length)close();return out};
|
|
701
|
+
let h=`<div></div>${['Monday','Tuesday','Wednesday','Thursday','Friday'].map((d,i)=>`<div class="dh ${i+1===wdNow?'today':''}">${d}</div>`).join('')}<div class="hours" style="--hrs:${hrs}">${Array.from({length:hrs+1},(_,i)=>`<span style="top:${i*56}px">${pad(base+i)}:00</span>`).join('')}</div>`;
|
|
702
|
+
for(let wd=1;wd<=5;wd++){
|
|
703
|
+
const line=wd===wdNow&&now>=base*60&&now<=(base+hrs)*60?`<i class="nowline" style="top:${(now-base*60)/60*56}px"></i>`:'';
|
|
704
|
+
h+=`<div class="day" style="--hrs:${hrs}">${place(usable.filter(m=>m.weekday===wd)).map(({m,lane,n})=>{const c=courses.find(c=>c.course_id===m.course_id);
|
|
705
|
+
return `<div class="blk" style="--h:${hue(c)};top:${(min(m.start)-base*60)/60*56}px;height:${Math.max(30,(min(m.end)-min(m.start))/60*56-3)}px;left:calc(${lane/n*100}% + 3px);width:calc(${100/n}% - 6px)" title="${esc(c?.name||'')}"><b>${esc(m.code||c?.code||'Class')}</b><span>${esc(m.start)}–${esc(m.end)}${m.room?' · '+esc(m.room):''}</span></div>`}).join('')}${line}</div>`;
|
|
706
|
+
}
|
|
707
|
+
return head+`<div class="card list" style="margin-top:32px"><div class="gridwrap"><div class="grid">${h}</div></div></div>`;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// ---- drawing
|
|
711
|
+
function nav(){const s=$('#seg'),p=page();s.querySelectorAll('a').forEach(a=>a.dataset.p===p?a.setAttribute('aria-current','page'):a.removeAttribute('aria-current'));const on=s.querySelector('[aria-current]');s.style.setProperty('--x',on.offsetLeft+'px');s.style.setProperty('--w',on.offsetWidth+'px')}
|
|
712
|
+
let shown=null;
|
|
713
|
+
function notice(){
|
|
714
|
+
const asking=session&&!busy&&elapsed()>=ASK_AT&&elapsed()<EXPIRED_AT;
|
|
715
|
+
document.title=asking?'Still studying? · Studysystem':'Studysystem'; // seen from another browser tab
|
|
716
|
+
if(!asking)return '';
|
|
717
|
+
return `<div class="notice"><b>Still studying?</b><div class="acts"><button class="btn" type="button" data-act="continue">Continue</button><button class="btn stop" type="button" data-act="stop">Stop</button></div><p>${esc(session.code)} · ${esc(hm(Math.floor(elapsed()/60)))} so far. At 3h55m this session stops and logs itself.</p></div>`;
|
|
718
|
+
}
|
|
719
|
+
// The notice is put in once, then only its minutes line changes, so it does not drop in again.
|
|
720
|
+
function paintNotice(){
|
|
721
|
+
const n=notice(),box=$('#notice');if(box.dataset.html===n)return;
|
|
722
|
+
const old=box.querySelector('.notice p');
|
|
723
|
+
if(n&&old){const fresh=document.createElement('div');fresh.innerHTML=n;old.replaceWith(fresh.querySelector('p'))}
|
|
724
|
+
else box.innerHTML=n;
|
|
725
|
+
box.dataset.html=n;
|
|
726
|
+
}
|
|
727
|
+
function draw(){
|
|
728
|
+
nav();paintNotice();$('#barDate').textContent=new Date().toLocaleDateString(undefined,{weekday:'short',day:'numeric',month:'short'});
|
|
729
|
+
if(!raw)return;
|
|
730
|
+
const p=page(),key=p+'?'+(param('course')||''),app=$('#app'),at=document.activeElement?.dataset,keep=at&&(at.act==='done'||at.act==='paper')?[at.act,at.id]:null;
|
|
731
|
+
app.innerHTML=`<div class="${shown===key?'':'page'}">${p==='plan'?planPage():p==='schedule'?schedulePage():todayPage()}</div>`;shown=key;
|
|
732
|
+
if(keep)[...app.querySelectorAll(`[data-act="${keep[0]}"]`)].find(b=>b.dataset.id===keep[1])?.focus(); // a tick keeps the keyboard's place
|
|
733
|
+
if(first){first=false;setTimeout(()=>{const r=$('#ringfill');if(r)r.style.strokeDashoffset=r.dataset.to;$('#seg').classList.add('live')},80)}
|
|
734
|
+
}
|
|
735
|
+
document.addEventListener('click',e=>{
|
|
736
|
+
const b=e.target.closest('[data-act]');if(!b)return;const {act,id}=b.dataset;
|
|
737
|
+
if(act==='theme'){const dark=document.documentElement.dataset.theme?document.documentElement.dataset.theme==='dark':matchMedia('(prefers-color-scheme: dark)').matches,t=dark?'light':'dark';document.documentElement.dataset.theme=t;try{localStorage.setItem('semcon.theme',t)}catch(x){}return}
|
|
738
|
+
if(act==='goal'){goalEdit={...GOAL_CLOSED,open:true};draw();$('#goal input')?.select();return}
|
|
739
|
+
if(act==='goal-cancel'){goalEdit={...GOAL_CLOSED};draw();return}
|
|
740
|
+
if(act==='fold-tasks'){store.tasksFolded=!store.tasksFolded;saveStore();draw();$('[data-act="fold-tasks"]')?.focus();return}
|
|
741
|
+
if(act==='fold-coverage'){store.coverageOpen=!store.coverageOpen;saveStore();draw();$('[data-act="fold-coverage"]')?.focus();return}
|
|
742
|
+
if(act==='menu')return menu(id,openMenu()!==id);
|
|
743
|
+
if(act==='wtab'){store.watchTab=id;saveStore();draw();$('[data-act="wtab"][aria-selected="true"]')?.focus();return}
|
|
744
|
+
if(act==='pick'){const which=b.dataset.menu;if(which==='logCourse')logDraft.code=id;else{store[which]=id;saveStore()}if(which==='course'||which==='mode')note=null;draw();$('#'+which+'Btn')?.focus();return}
|
|
745
|
+
if(act==='confirm')return confirmDirective(id);
|
|
746
|
+
if(act==='trials')return setTrials(b.dataset.on==='true');
|
|
747
|
+
if(act==='start')return start();
|
|
748
|
+
if(act==='stop')return stop();
|
|
749
|
+
if(act==='continue')return stop('continue');
|
|
750
|
+
if(act==='paper'){e.preventDefault();const f=b.closest('details')?.dataset.fold;if(f)openFolds.add(f);store.papers[id]?delete store.papers[id]:store.papers[id]=true;saveStore();draw();return}
|
|
751
|
+
if(act==='done'||act==='skip'){
|
|
752
|
+
if(id.startsWith('custom:')){const t=store.custom.find(x=>x.id===id.slice(7));if(t){if(act==='skip')store.custom=store.custom.filter(x=>x!==t);else{t.done=!t.done;t.doneDay=TODAY}}}
|
|
753
|
+
else store.items[id]={status:act==='skip'?'skipped':status({uid:id})==='done'?'upcoming':'done'};
|
|
754
|
+
saveStore();draw();
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
document.addEventListener('pointerdown',e=>{if(!e.target.closest('.menu'))menu(null,false)});
|
|
758
|
+
document.addEventListener('keydown',e=>{
|
|
759
|
+
if((e.key==='ArrowLeft'||e.key==='ArrowRight')&&e.target.matches?.('[role="tab"]')){const t=[...e.target.parentNode.querySelectorAll('[role="tab"]')];t[(t.indexOf(e.target)+(e.key==='ArrowRight'?1:t.length-1))%t.length].click();return}
|
|
760
|
+
const name=openMenu();if(!name)return;const p=$('#'+name+'Pop');
|
|
761
|
+
const os=[...p.querySelectorAll('.opt')],i=os.indexOf(document.activeElement);
|
|
762
|
+
if(e.key==='ArrowDown'){e.preventDefault();os[Math.min(os.length-1,i+1)].focus()}
|
|
763
|
+
else if(e.key==='ArrowUp'){e.preventDefault();os[Math.max(0,i-1)].focus()}
|
|
764
|
+
else if(e.key==='Escape'){menu(null,false);$('#'+name+'Btn')?.focus()}
|
|
765
|
+
});
|
|
766
|
+
document.addEventListener('toggle',e=>{const id=e.target.dataset?.fold;if(id)e.target.open?openFolds.add(id):openFolds.delete(id)},true);
|
|
767
|
+
document.addEventListener('input',e=>{if(e.target.closest('#logform')&&e.target.name in logDraft){logDraft[e.target.name]=e.target.value;logDraft.msg=null}if(e.target.closest('#goal'))goalEdit.draft=e.target.value;if(e.target.closest('#add'))taskDraft=e.target.value}); // a redraw keeps what he typed
|
|
768
|
+
document.addEventListener('submit',e=>{if(e.target.id==='logform'){e.preventDefault();logHours(e.target);return}
|
|
769
|
+
if(e.target.id==='goal'){e.preventDefault();if(!goalEdit.busy)saveGoal(Number(new FormData(e.target).get('hours')));return}
|
|
770
|
+
if(e.target.id!=='add')return;e.preventDefault();const title=String(new FormData(e.target).get('title')||'').trim(),course=taskCourse()?.code||null;if(!title)return;taskDraft='';store.custom.unshift({id:Math.random().toString(36).slice(2),title,course,mins:null,done:false});saveStore();draw();$('#add input')?.focus()});
|
|
771
|
+
addEventListener('hashchange',()=>{if(location.hash.startsWith('#open=')){arrive();return}draw();scrollTo({top:0})});
|
|
772
|
+
addEventListener('resize',nav);
|
|
773
|
+
|
|
774
|
+
async function load(){const r=await fetch("/state",{headers:{Accept:'application/json','X-Study-Key':myKey()}});if(!r.ok)throw await r.json().catch(()=>Error('The state request failed'));adapt(await r.json());draw()}
|
|
775
|
+
nav();
|
|
776
|
+
// An error the server named (D-330: behind head, run study migrate) is shown in its own words.
|
|
777
|
+
const arrive=()=>enter().then(load).catch(e=>{$('#app').innerHTML=`<p class="empty">${esc(e.code?`${e.message}. ${e.fix}`:(e instanceof TypeError?'The dashboard server is not running':e.message)+'. Start it')}, then reload this page.</p>`});
|
|
778
|
+
arrive();
|
|
779
|
+
</script>
|
|
780
|
+
</body>
|
|
781
|
+
</html>
|