-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
413 lines (403 loc) · 14.6 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<html>
<head>
<link rel="stylesheet" href="styles.css" />
<meta name="theme-color" content="#40798c" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no"
/>
<!-- font -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Righteous&display=swap"
rel="stylesheet"
/>
<script type="text/javascript" src="moment.js"></script>
<script type="text/javascript" src="idbkeyval.js"></script>
<script type="text/javascript" src="levenshteinDistance.js"></script>
<script type="text/javascript" src="csvDownload.js"></script>
<script defer type="text/javascript" src="nutrients.js"></script>
<script defer type="text/javascript" src="settings.js"></script>
<script defer type="text/javascript" src="foodLog.js"></script>
<script defer type="text/javascript" src="index.js"></script>
<!-- favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png" />
<link rel="manifest" href="site.webmanifest" />
<!-- Primary Meta Tags -->
<!-- Meta Tags Generated with https://metatags.io -->
<title>Spiky Bites - Free nutritional tracker</title>
<meta name="title" content="Spiky Bites - Free nutritional tracker" />
<meta
name="description"
content="An easy and free to use nutritional tracker! Start today!!"
/>
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta
property="og:url"
content="https://ethanjurman.github.io/spiky-bites/"
/>
<meta
property="og:title"
content="Spiky Bites - Free nutritional tracker"
/>
<meta
property="og:description"
content="An easy and free to use nutritional tracker! Start today!!"
/>
<meta
property="og:image"
content="https://raw.githubusercontent.com/ethanjurman/spiky-bites/main/images/spiky-bites-metabanner.png"
/>
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta
property="twitter:url"
content="https://ethanjurman.github.io/spiky-bites/"
/>
<meta
property="twitter:title"
content="Spiky Bites - Free nutritional tracker"
/>
<meta
property="twitter:description"
content="An easy and free to use nutritional tracker! Start today!!"
/>
<meta
property="twitter:image"
content="https://raw.githubusercontent.com/ethanjurman/spiky-bites/main/images/spiky-bites-metabanner.png"
/>
</head>
<body>
<datalist id="nutrients"></datalist>
<div id="screen">
<!-- food add -->
<div class="content-wrapper" id="food-add-screen">
<div class="grid-search-wrapper">
<button class="page-button" onclick="showPage('food-log')">
<img
src="images/lists_icon.svg"
alt="food log icon"
style="filter: brightness(0)"
/>
</button>
<input
type="text"
id="search"
placeholder="Food Search"
oninput="adjustSearchFontSize()"
onchange="searchFoods()"
/>
<button
id="search-view-grid"
class="page-button"
onclick="updateFoodItemListingStyle('1fr 1fr 1fr')"
style="display: none"
>
<img
src="images/grids_icon.svg"
alt="pencil icon"
style="filter: brightness(0)"
/>
</button>
<button
id="search-view-list"
class="page-button"
onclick="updateFoodItemListingStyle('1fr')"
style="display: none"
>
<img
src="images/rows_icon.svg"
alt="pencil icon"
style="filter: brightness(0)"
/>
</button>
<button class="page-button" onclick="showPage('food-create')">
<img
src="images/edit_icon.svg"
alt="pencil icon"
style="filter: brightness(0)"
/>
</button>
<button class="page-button" onclick="showPage('settings')">
<img
src="images/settings_icon.svg"
alt="gear icon"
style="filter: brightness(0)"
/>
</button>
</div>
<div id="grid-food-items-wrapper"></div>
<div id="grid-food-items-spinner" style="display: none">
<img src="images/progress_spinner_icon.svg" alt="progress spinner" />
</div>
<div id="network-failed" style="display: none">
We couldn't connect to USDA. Did you provide an API key? Go to
settings and set that up!
<img src="images/spiky_bites_down.svg" alt="hedgehog upside down" />
</div>
<div id="no-results" style="display: none">
We couldn't find any results for that search!
<img src="images/spiky_bites_sad.svg" alt="hedgehog sad" />
</div>
<div id="goal-tracker" style="display: none"></div>
</div>
<!-- settings -->
<div class="content-wrapper" id="settings-screen" style="display: none">
<button class="page-button" onclick="showPage('food-add')">
<img
src="images/arrow_back_icon.svg"
alt="back arrow"
style="filter: brightness(0)"
/>
</button>
<div>
<label
>USDA API KEY:
<input type="text" id="api-key-input" onchange="saveApiKey()" />
</label>
<div>Need an API Key?</div>
<a href="https://fdc.nal.usda.gov/api-key-signup.html"
>Go here to request one from USDA</a
>
<div id="color-setting-wrapper">
<div>App Colors</div>
<div id="color-input-wrapper">
<input
onchange="updateColor('background')"
type="color"
id="background-color"
/>
<input
onchange="updateColor('button')"
type="color"
id="button-color"
/>
<input
onchange="updateColor('text')"
type="color"
id="text-color"
/>
</div>
<button onclick="resetColors()">defaults</button>
</div>
<div style="margin-top: 24px; font-size: larger">
Nutrients To Track
</div>
<div>This will show those items up in your food logs</div>
<div id="goals-settings-container"></div>
<button id="goal-add-button" onclick="addGoal()">Add Nutrient</button>
<div style="margin-top: 24px">
<p>Spiky Bites is a project developed by Ethan Jurman</p>
<p>
license and code can be found here: <br />
<a href="https://github.com/ethanjurman/spiky-bites"
>https://github.com/ethanjurman/spiky-bites</a
>
</p>
<p>
Data submitted by users is not stored remotely or saved to a
server, instead data is saved locally on the device using
IndexedDB. This is a personal project, and I make no guarantees
for long-term support.
</p>
<p>
Thanks to the USDA for their API! Without it, this project would
not have been possible. Citation for the resource here:
</p>
<div>
U.S. Department of Agriculture, Agricultural Research Service.
FoodData Central, 2019. fdc.nal.usda.gov.
</div>
</div>
<hr style="margin-top: 24px; margin-bottom: 24px" />
<div id="clear-data-question" style="margin-bottom: 12px">
<button onclick="showClearDataItem()" class="danger">
Clear data
</button>
</div>
<div style="margin-bottom: 12px; display: none" id="clear-data-item">
<div>
Are you absolutely sure? There won't be a way to recover your data
afterwards
</div>
<div id="clear-data-options-wrapper">
<button onclick="hideClearDataItem()">No</button>
<button onclick="clearAllData()" class="danger">
Yes, Clear my data!
</button>
</div>
</div>
</div>
<div style="height: 100%"></div>
</div>
<!-- edit food entry -->
<div class="content-wrapper" id="food-edit-screen" style="display: none">
<div class="grid-search-wrapper">
<button class="page-button" onclick="showPage('food-add')">
<img
src="images/arrow_back_icon.svg"
alt="back arrow"
style="filter: brightness(0)"
/>
</button>
<input type="text" id="food-edit-name" placeholder="Food Item" />
</div>
<div
id="serving-size-wrapper"
class="flex-wrapper"
style="display: none"
>
<div>Serving Sizes:</div>
<div id="food-edit-amount-options"></div>
</div>
<div id="food-edit-amount-wrapper">
<div></div>
<input
type="number"
id="food-edit-amount"
placeholder="Amount"
value="100"
onchange="updateFoodValuesFromAmount()"
/>
<select
name="measure"
id="food-edit-amount-unit"
onchange="updateMeasure()"
>
<option value="mg">milligrams (mg)</option>
<option value="g" selected>grams (g)</option>
<option value="kg">kilograms (kg)</option>
<option value="oz">ounces (oz)</option>
<option value="lb">pound (lb)</option>
<option value="tsp">teaspoon (tsp)</option>
<option value="tbsp">tablespoon (tbsp)</option>
<option value="fl_oz">fluid ounces (fl oz)</option>
<option value="ml">milliliters (ml)</option>
<option value="c">cup (c)</option>
<option value="pt">pint (pt)</option>
<option value="qt">quart (qt)</option>
<option value="L">liter (L)</option>
<option value="gal">gallon (gal)</option>
<option value="dash">dash</option>
<option value="pinch">pinch</option>
<option value="slice">slice</option>
<option value="piece">piece</option>
<option value="clove">clove</option>
<option value="stick">stick</option>
<option value="can">can</option>
<option value="bottle">bottle</option>
<option value="pkg">package (pkg)</option>
<option value="serving">serving</option>
<option value="bowls">bowls</option>
</select>
<button id="sync" style="display: none" onclick="updateSync(false)">
<img
src="images/sync_icon.svg"
style="filter: brightness(0)"
alt="sync arrows"
/>
</button>
<button
id="sync-disabled"
style="display: none"
onclick="updateSync(true)"
>
<img
src="images/sync_disabled_icon.svg"
style="filter: brightness(0)"
alt="sync arrows with a line through them"
/>
</button>
</div>
<div id="nutrition-edit"></div>
<div id="spacer" style="flex: 1"></div>
<div>
<div class="button-row" id="food-item-edit-button-row">
<div style="display: grid; grid-template-rows: 1fr 1fr">
<input
class="save-date"
type="datetime-local"
name="save-date"
onchange="updateDates(event)"
/>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr">
<button
id="remove-button"
class="danger"
onclick="removeFoodItem()"
>
Remove
</button>
<button id="save-new-button" onclick="saveDuplicateFoodItem()">
Log Again
</button>
<button id="save-button" onclick="saveCurrentFoodItem(false)">
Update
</button>
</div>
</div>
</div>
<div class="button-row" id="food-item-save-button-row">
<div style="display: grid">
<input
class="save-date"
type="datetime-local"
name="save-date"
onchange="updateDates(event)"
/>
<button id="save-button" onclick="saveCurrentFoodItem()">
Add to Log
</button>
</div>
</div>
</div>
</div>
<!-- food log -->
<div class="content-wrapper" id="food-log-screen" style="display: none">
<div id="food-log-top-wrapper">
<button class="page-button" onclick="showPage('food-add')">
<img
src="images/arrow_back_icon.svg"
alt="back arrow"
style="filter: brightness(0)"
/>
</button>
<div id="load-date-wrapper">
Download CSV:
<button id="download-button" onclick="downloadAsCSV()">
<img
src="images/download_icon.svg"
alt="back arrow"
style="filter: brightness(0)"
/>
</button>
</div>
<div id="load-date-wrapper">
Load from date:
<input
type="date"
id="food-log-date-input"
name="log-date"
onchange="updateLogDate()"
/>
</div>
</div>
<div id="food-log-wrapper"></div>
<div id="no-food-log-items" style="display: none">
<p>
This is where you'll find a list of all the food you've logged here!
</p>
<p>
If you haven't logged any items, then you should go back... and do
that!
</p>
<img src="images/spiky_bites_sad.svg" alt="sad spiky bites" />
</div>
</div>
</div>
</body>
</html>