-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
256 lines (228 loc) · 7.75 KB
/
index.html
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
---
layout: default
description: Charts and stuff
---
<link rel="stylesheet" type="text/css" href="vendor/slick-carousel/slick.css">
<link rel="stylesheet" type="text/css" href="assets/slick-theme.css">
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/lodash/lodash.js"></script>
<script src="vendor/moment/moment.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="vendor/bootstrap-sass/javascripts/bootstrap.js"></script>
<script src="vendor/slick-carousel/slick.js"></script>
<script src="vendor/mathjs/math.min.js"></script>
<script src="js/data.js"></script>
<script src="js/charts.js"></script>
<script src="js/headerShrink.js"></script>
<script src="js/milestonesCarousel.js"></script>
<div data-spy="scroll" data-target=".navbar" data-offset="150">
<nav class="row kpis navbar-nav navbar-fixed-top">
<div class="container-fluid">
<div class="nav col-xs-2 kpi">
<a href="#age">
{% if site.data.baby.picture_url %}
<img src="{{ site.data.baby.picture_url }}" class="img-responsive circle" alt="Baby">
{% elsif site.data.baby.gender == 'female' %}
<img src="assets/images/baby-1.png" class="img-responsive" alt="Baby">
{% else %}
<img src="assets/images/baby.png" class="img-responsive" alt="Baby">
{% endif %}
</a>
<h4 class="kpi-metric hidden-xs" id="ageKPI"></h4>
<span class="kpi-description text-muted hidden-xs" id="ageKPIUnits"></span>
</div>
<div class="nav col-xs-2 kpi">
<a href="#sleep">
<img src="assets/images/crib-toy.png" class="img-responsive" alt="Sleep">
</a>
<h4 class="kpi-metric hidden-xs" id="sleepHoursKPI"></h4>
<span class="kpi-description text-muted hidden-xs">Hours sleeping</span>
</div>
<div class="nav col-xs-2 kpi">
<a href="#feedings">
<img src="assets/images/feeding-bottle-1.png" class="img-responsive" alt="Feeding">
</a>
<h4 class="kpi-metric hidden-xs" id="feedingsKPI"></h4>
<span class="kpi-description text-muted hidden-xs">Feedings</span>
</div>
<div class="nav col-xs-2 kpi">
<a href="#diapers">
<img src="assets/images/diaper.png" class="img-responsive" alt="Diaper">
</a>
<h4 class="kpi-metric hidden-xs" id="diapersKPI"></h4>
<span class="kpi-description text-muted hidden-xs">Diapers changed</span>
</div>
<div class="nav col-xs-2 kpi">
<a href="#baths">
<img src="assets/images/bathtub.png" class="img-responsive" alt="Bath">
</a>
<h4 class="kpi-metric hidden-xs" id="bathsKPI"></h4>
<span class="kpi-description text-muted hidden-xs">Baths</span>
</div>
<div class="nav col-xs-2 kpi">
<a href="#growth">
<img src="assets/images/body.png" class="img-responsive" alt="Growth">
</a>
<h4 class="kpi-metric hidden-xs" id="growthKPI"></h4>
<span class="kpi-description text-muted hidden-xs">
Bigger
</span>
</div>
</div>
</nav>
<div class="sections">
<div id="age" class="container-fluid section firstSection">
{% if site.data.milestones.size > 0 %}
<div class="row">
<div class="col-xs-12">
<h2>Milestones</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="milestones">
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-xs-12">
<h2>Recent Events</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="timeline" class="google-chart"></div>
</div>
</div>
</div>
<div id="sleep" class="container-fluid section">
<div class="row">
<div class="col-xs-12">
<h2>Night Sleeps</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="nightSleepChart" class="google-chart"></div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h2>Total Sleep</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="sleepChart" class="google-chart"></div>
</div>
</div>
</div>
<div id="feedings" class="container-fluid section">
<div class="row">
<div class="col-xs-12">
<h2>Feeding Frequency</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="feedingsChart" class="google-chart"></div>
</div>
</div>
</div>
<div id="diapers" class="container-fluid section">
<div class="row">
<div class="col-xs-12">
<h2>Diapers</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="diapersChart" class="google-chart"></div>
</div>
</div>
</div>
<div id="growth" class="container-fluid section">
<div class="row">
<div class="col-xs-12">
<h2>Weight compared to 25th and 75th percentiles</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="weightChart" class="google-chart"></div>
</div>
</div>
</div>
<div id="medicines" class="container-fluid section">
<div class="row">
<div class="col-xs-12">
<h2>Medicines</h2>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div id="medicinesChart" class="google-chart"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart', 'timeline']});
google.charts.setOnLoadCallback(createCharts);
var urlParams = new URLSearchParams(window.location.search);
var startDate = urlParams.get('start') && moment(urlParams.get('start'));
var endDate = urlParams.get('end') && moment(urlParams.get('end'));
var dataDateFormat = '{{site.data.config.dataDateFormat}}';
var dataDateTimeFormat = '{{site.data.config.dataDateTimeFormat}}';
var metadata = new Metadata({{ site.data.baby | jsonify }});
var sleeps = new Sleeps({{ site.data.sleeps | jsonify }}, dataDateTimeFormat);
var feeds = new Feeds({{ site.data.feeds | jsonify }}, dataDateTimeFormat);
var excretions = new Excretions({{ site.data.excretions | jsonify }}, dataDateTimeFormat);
var journals = new Journals({{ site.data.journal_entries | jsonify }}, dataDateTimeFormat);
var medicines = new Medicines({{ site.data.medicines | jsonify }}, dataDateTimeFormat);
var medicineRecords = new MedicineRecords({{ site.data.medicine_records | jsonify }}, dataDateTimeFormat);
var growths = new Growths({{ site.data.growths | jsonify }}, dataDateFormat);
{% if site.data.baby.gender == 'female' %}
var weightPercentiles = new GrowthPercentiles({{ site.data.who_growth_percentiles_girls | jsonify }});
{% else %}
var weightPercentiles = new GrowthPercentiles({{ site.data.who_growth_percentiles_boys | jsonify }});
{% endif %}
$("#ageKPI").html(metadata.age.value);
$("#ageKPIUnits").html(metadata.age.unit);
$("#sleepHoursKPI").html(Math.round(sleeps.totalHours));
$("#feedingsKPI").html(feeds.data.length);
$("#diapersKPI").html(excretions.data.length);
$("#bathsKPI").html(_.filter(journals.data, {type: "Bath"}).length);
$("#growthKPI").html(growths.weightChange.toFixed(1) + "x");
var milestones = {{ site.data.milestones | jsonify }};
var milestonesCarousel;
if (milestones && milestones.length) {
milestonesCarousel = new MilestonesCarousel(milestones, $("#milestones"), metadata);
}
function init() {
addHeaderShrink();
if (milestonesCarousel) {
milestonesCarousel.draw();
}
}
window.onload = init();
var charts = [];
function createCharts() {
charts.push(new TimelineChart(document.getElementById('timeline'), sleeps, feeds, excretions, journals));
charts.push(new NightSleepChart(document.getElementById('nightSleepChart'), sleeps));
charts.push(new SleepChart(document.getElementById('sleepChart'), sleeps));
charts.push(new FeedingsChart(document.getElementById('feedingsChart'), feeds));
charts.push(new DiapersChart(document.getElementById('diapersChart'), excretions));
charts.push(new WeightChart(document.getElementById('weightChart'), growths));
charts.push(new MedicinesChart(document.getElementById('medicinesChart'), medicines, medicineRecords, startDate, endDate));
drawCharts();
}
function drawCharts() {
_.each(charts, function (chart) {
chart.draw();
});
}
$(window).resize(drawCharts);
</script>