diff options
author | cyfraeviolae <cyfraeviolae> | 2023-01-11 22:46:45 -0500 |
---|---|---|
committer | cyfraeviolae <cyfraeviolae> | 2023-01-11 22:46:45 -0500 |
commit | 91759579d0fcd4acb48e7a209e8f79796fb67aaa (patch) | |
tree | 73e99ddc7914ec06902dce0ca5d0d4d68ef37eb9 /static |
init
Diffstat (limited to 'static')
-rw-r--r-- | static/data.js | 1 | ||||
-rw-r--r-- | static/favicon.ico | bin | 0 -> 318 bytes | |||
-rw-r--r-- | static/script.js | 68 | ||||
-rw-r--r-- | static/styles.css | 3 |
4 files changed, 72 insertions, 0 deletions
diff --git a/static/data.js b/static/data.js new file mode 100644 index 0000000..130842d --- /dev/null +++ b/static/data.js @@ -0,0 +1 @@ +let data = {"Bases": [{"name": "Arugula", "serving_size": 48, "calories": 15, "calories_from_fat": 9, "total_fat": 1, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 15, "total_carbs": 2, "dietary_fiber": 1, "sugars": 1, "protein": 1}, {"name": "Baby Spinach", "serving_size": 53, "calories": 15, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 40, "total_carbs": 2, "dietary_fiber": 1, "sugars": 0, "protein": 1}, {"name": "Chopped Romaine", "serving_size": 75, "calories": 15, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 5, "total_carbs": 2, "dietary_fiber": 2, "sugars": 1, "protein": 1}, {"name": "Shredded Kale", "serving_size": 43, "calories": 20, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 15, "total_carbs": 4, "dietary_fiber": 2, "sugars": 1, "protein": 2}, {"name": "Spring Mix", "serving_size": 48, "calories": 10, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Warm Quinoa", "serving_size": 100, "calories": 160, "calories_from_fat": 27, "total_fat": 3, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 167, "total_carbs": 28, "dietary_fiber": 4, "sugars": 2, "protein": 6}, {"name": "Warm Wild Rice", "serving_size": 95, "calories": 155, "calories_from_fat": 18, "total_fat": 2, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 150, "total_carbs": 31, "dietary_fiber": 2, "sugars": 0, "protein": 3}], "Signature ingredients": [{"name": "Apples", "serving_size": 29, "calories": 15, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 4, "dietary_fiber": 1, "sugars": 3, "protein": 0}, {"name": "Basil", "serving_size": 7, "calories": 0, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Black Lentils", "serving_size": 55, "calories": 60, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 65, "total_carbs": 7, "dietary_fiber": 4, "sugars": 1, "protein": 8}, {"name": "Chickpeas", "serving_size": 43, "calories": 45, "calories_from_fat": 14, "total_fat": 2, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 250, "total_carbs": 7, "dietary_fiber": 0, "sugars": 0, "protein": 2}, {"name": "Cilantro", "serving_size": 5, "calories": 0, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Crispy Rice", "serving_size": 26, "calories": 80, "calories_from_fat": 14, "total_fat": 2, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 260, "total_carbs": 14, "dietary_fiber": 0, "sugars": 1, "protein": 2}, {"name": "Cucumbers", "serving_size": 40, "calories": 5, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Fresh Herbs (TX)", "serving_size": 5, "calories": 0, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Hummus", "serving_size": 47, "calories": 80, "calories_from_fat": 41, "total_fat": 5, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 180, "total_carbs": 7, "dietary_fiber": 0, "sugars": 0, "protein": 4}, {"name": "Parmesan Crisps", "serving_size": 20, "calories": 100, "calories_from_fat": 72, "total_fat": 8, "saturated_fat": 5, "trans_fat": 0, "cholesterol": 25, "sodium": 480, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 6}, {"name": "Olives", "serving_size": 39, "calories": 40, "calories_from_fat": 36, "total_fat": 4, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 250, "total_carbs": 2, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Raw Pecans", "serving_size": 14, "calories": 90, "calories_from_fat": 81, "total_fat": 9, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 1, "dietary_fiber": 1, "sugars": 0, "protein": 1}, {"name": "Raw Beets", "serving_size": 40, "calories": 15, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 30, "total_carbs": 3, "dietary_fiber": 1, "sugars": 3, "protein": 1}, {"name": "Raw Carrots", "serving_size": 23, "calories": 10, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 15, "total_carbs": 2, "dietary_fiber": 1, "sugars": 1, "protein": 0}, {"name": "Red Onions", "serving_size": 7, "calories": 5, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Roasted Almonds", "serving_size": 14, "calories": 80, "calories_from_fat": 54, "total_fat": 6, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 3, "dietary_fiber": 2, "sugars": 1, "protein": 3}, {"name": "Roasted Sweet Potatoes", "serving_size": 39, "calories": 65, "calories_from_fat": 9, "total_fat": 1, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 301, "total_carbs": 13, "dietary_fiber": 2, "sugars": 7, "protein": 1}, {"name": "Shredded Cabbage", "serving_size": 25, "calories": 10, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 5, "total_carbs": 2, "dietary_fiber": 1, "sugars": 1, "protein": 0}, {"name": "Spicy Broccoli", "serving_size": 33, "calories": 25, "calories_from_fat": 9, "total_fat": 1, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 120, "total_carbs": 3, "dietary_fiber": 1, "sugars": 1, "protein": 1}, {"name": "Sunflower Seeds", "serving_size": 13, "calories": 70, "calories_from_fat": 54, "total_fat": 6, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 55, "total_carbs": 2, "dietary_fiber": 1, "sugars": 0, "protein": 2}, {"name": "Tomatoes", "serving_size": 46, "calories": 10, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 10, "total_carbs": 2, "dietary_fiber": 1, "sugars": 1, "protein": 1}, {"name": "Tortilla Chips", "serving_size": 16, "calories": 80, "calories_from_fat": 36, "total_fat": 4, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 10, "total_carbs": 10, "dietary_fiber": 1, "sugars": 0, "protein": 1}, {"name": "Za'atar Breadcrumbs", "serving_size": 15, "calories": 65, "calories_from_fat": 18, "total_fat": 2, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 201, "total_carbs": 9, "dietary_fiber": 1, "sugars": 0, "protein": 3}], "Premium ingredients": [{"name": "Avocado", "serving_size": 87, "calories": 160, "calories_from_fat": 117, "total_fat": 13, "saturated_fat": 3, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 8, "dietary_fiber": 9, "sugars": 0, "protein": 3}, {"name": "Blackened Catfish", "serving_size": 77, "calories": 125, "calories_from_fat": 72, "total_fat": 8, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 53, "sodium": 276, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 13}, {"name": "Blackened Chicken", "serving_size": 80, "calories": 140, "calories_from_fat": 54, "total_fat": 6, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 99, "sodium": 334, "total_carbs": 1, "dietary_fiber": 1, "sugars": 0, "protein": 21}, {"name": "Blue Cheese", "serving_size": 30, "calories": 110, "calories_from_fat": 81, "total_fat": 9, "saturated_fat": 6, "trans_fat": 0, "cholesterol": 25, "sodium": 340, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 6}, {"name": "Goat Cheese", "serving_size": 34, "calories": 90, "calories_from_fat": 63, "total_fat": 7, "saturated_fat": 5, "trans_fat": 0, "cholesterol": 15, "sodium": 160, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 7}, {"name": "Hard Boiled Egg", "serving_size": 50, "calories": 70, "calories_from_fat": 45, "total_fat": 5, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 190, "sodium": 70, "total_carbs": 1, "dietary_fiber": 0, "sugars": 1, "protein": 7}, {"name": "Hot Roasted Sweet Potatoes", "serving_size": 72, "calories": 85, "calories_from_fat": 22, "total_fat": 2, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 220, "total_carbs": 15, "dietary_fiber": 2, "sugars": 2, "protein": 2}, {"name": "Parmesan Crisps", "serving_size": 20, "calories": 100, "calories_from_fat": 72, "total_fat": 8, "saturated_fat": 5, "trans_fat": 0, "cholesterol": 25, "sodium": 480, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 6}, {"name": "Pickled Carrots + Celery", "serving_size": 30, "calories": 5, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 250, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Roasted Chicken", "serving_size": 78, "calories": 110, "calories_from_fat": 18, "total_fat": 2, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 58, "sodium": 254, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 21}, {"name": "Roasted Tofu", "serving_size": 75, "calories": 100, "calories_from_fat": 63, "total_fat": 7, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 250, "total_carbs": 2, "dietary_fiber": 1, "sugars": 0, "protein": 7}, {"name": "Roasted Shrimp (MIA)", "serving_size": 79, "calories": 65, "calories_from_fat": 9, "total_fat": 1, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 133, "sodium": 271, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 14}, {"name": "Roasted Shrimp (TX)", "serving_size": 70, "calories": 65, "calories_from_fat": 9, "total_fat": 1, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 133, "sodium": 271, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 14}, {"name": "Roasted Steelhead", "serving_size": 86, "calories": 170, "calories_from_fat": 90, "total_fat": 10, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 50, "sodium": 172, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 20}, {"name": "Salmon", "serving_size": 86, "calories": 170, "calories_from_fat": 90, "total_fat": 10, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 50, "sodium": 172, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 20}, {"name": "Shaved Parmesan", "serving_size": 12, "calories": 45, "calories_from_fat": 36, "total_fat": 4, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 0, "sodium": 150, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 3}, {"name": "Turkey Meatballs", "serving_size": 85, "calories": 90, "calories_from_fat": 18, "total_fat": 2, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 43, "sodium": 300, "total_carbs": 7, "dietary_fiber": 1, "sugars": 1, "protein": 11}, {"name": "Warm Portobello Mix", "serving_size": 65, "calories": 110, "calories_from_fat": 72, "total_fat": 8, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 498, "total_carbs": 6, "dietary_fiber": 3, "sugars": 0, "protein": 5}], "Dressings": [{"name": "Balsamic Vinegar", "serving_size": 15, "calories": 15, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 3, "dietary_fiber": 0, "sugars": 2, "protein": 0}, {"name": "Balsamic Vinaigrette", "serving_size": 30, "calories": 150, "calories_from_fat": 126, "total_fat": 14, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 0, "sodium": 210, "total_carbs": 6, "dietary_fiber": 0, "sugars": 3, "protein": 0}, {"name": "Caesar Dressing", "serving_size": 30, "calories": 100, "calories_from_fat": 90, "total_fat": 10, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 10, "sodium": 330, "total_carbs": 2, "dietary_fiber": 0, "sugars": 0, "protein": 1}, {"name": "Extra Virgin Olive Oil", "serving_size": 15, "calories": 130, "calories_from_fat": 126, "total_fat": 14, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Green Goddess Ranch", "serving_size": 30, "calories": 145, "calories_from_fat": 135, "total_fat": 15, "saturated_fat": 3, "trans_fat": 0, "cholesterol": 10, "sodium": 300, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 1}, {"name": "Hot Honey Mustard Sauce", "serving_size": 30, "calories": 120, "calories_from_fat": 90, "total_fat": 10, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 240, "total_carbs": 7, "dietary_fiber": 0, "sugars": 4, "protein": 0}, {"name": "Lemon Squeeze", "serving_size": 15, "calories": 0, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Lime Cilantro Jalape\u00f1o Vinaigrette", "serving_size": 30, "calories": 110, "calories_from_fat": 108, "total_fat": 12, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 50, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Lime Squeeze", "serving_size": 15, "calories": 5, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Miso Sesame Ginger Dressing", "serving_size": 30, "calories": 120, "calories_from_fat": 108, "total_fat": 12, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 200, "total_carbs": 0, "dietary_fiber": 0, "sugars": 2, "protein": 1}, {"name": "Nuoc Cham Dressing", "serving_size": 30, "calories": 25, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 870, "total_carbs": 5, "dietary_fiber": 0, "sugars": 4, "protein": 1}, {"name": "Pesto Vinaigrette", "serving_size": 30, "calories": 85, "calories_from_fat": 81, "total_fat": 9, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 125, "total_carbs": 1, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Spicy Cashew Dressing", "serving_size": 30, "calories": 100, "calories_from_fat": 81, "total_fat": 9, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 200, "total_carbs": 4, "dietary_fiber": 1, "sugars": 2, "protein": 1}, {"name": "Ceviche Dressing", "serving_size": 30, "calories": 80, "calories_from_fat": 54, "total_fat": 6, "saturated_fat": 1, "trans_fat": 0, "cholesterol": 0, "sodium": 220, "total_carbs": 6, "dietary_fiber": 0, "sugars": 0, "protein": 0}, {"name": "Sweetgreen Hot Sauce", "serving_size": 28, "calories": 10, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 170, "total_carbs": 2, "dietary_fiber": 1, "sugars": 1, "protein": 1}, {"name": "Sesame Teriyaki Dressing", "serving_size": 30, "calories": 140, "calories_from_fat": 117, "total_fat": 13, "saturated_fat": 2, "trans_fat": 0, "cholesterol": 0, "sodium": 630, "total_carbs": 4, "dietary_fiber": 0, "sugars": 3, "protein": 2}, {"name": "Crushed Red Pepper", "serving_size": 1, "calories": 0, "calories_from_fat": 0, "total_fat": 0, "saturated_fat": 0, "trans_fat": 0, "cholesterol": 0, "sodium": 0, "total_carbs": 0, "dietary_fiber": 0, "sugars": 0, "protein": 0}]} diff --git a/static/favicon.ico b/static/favicon.ico Binary files differnew file mode 100644 index 0000000..4e0f88c --- /dev/null +++ b/static/favicon.ico diff --git a/static/script.js b/static/script.js new file mode 100644 index 0000000..ced777c --- /dev/null +++ b/static/script.js @@ -0,0 +1,68 @@ +"use strict"; + +var html = `` +for (var table in data) { + var s = `` + for (var idx in data[table]) { + let tag = table + '|' + idx + s += `<input type="checkbox" id="ingredient${tag}" x-ingredient="${tag}"> + <label for="ingredient${tag}">${data[table][idx].name}</label>` + } + html += `<fieldset><legend>${table}</legend>${s}</fieldset>` +} +html += `<fieldset><legend>Dressing amount</legend> + <input type="radio" name="dressing-amount" id="light" value="light"> + <label for="light">Light</label><br> + <input type="radio" name="dressing-amount" id="medium" value="medium"> + <label for="medium">Medium</label><br> + <input type="radio" name="dressing-amount" id="heavy" value="heavy"> + <label for="heavy">Heavy</label><br> + </fieldset>` + +nutrition = document.getElementById('nutrition') +form = document.getElementById('form') +form.innerHTML = html + +let multipliers = {'none': 0, 'light': 1, 'medium': 2, 'heavy': 3} + +function calculateNutrition() { + let total = {} + let dressingAmount = form.elements['dressing-amount'].value || 'none' + for (var el of document.querySelectorAll('input:checked')) { + if (el.getAttribute('type') == 'radio') { + continue + } + let tag = el.getAttribute('x-ingredient') + let table = tag.split('|')[0] + let idx = tag.split('|')[1] + let row = data[table][idx] + for (var [name, val] of Object.entries(row)) { + if (typeof val == 'string') { + continue + } + if (!total[name]) { + total[name] = 0 + } + let multiplier = 1 + if (table == 'Dressings') { + multiplier = multipliers[dressingAmount] + } + if (multiplier > 0) { + total[name] += multiplier*val + } + } + } + return total +} + +form.addEventListener('change', function() { + let total = calculateNutrition() + var s = ` + Calories: ${total.calories}<br> + Carbohydrates (g): ${total.total_carbs}<br> + Dietary fiber (g): ${total.dietary_fiber}<br> + Fat (g): ${total.total_fat}<br> + Protein (g): ${total.protein}<br> + ` + nutrition.innerHTML = s +}) diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..f388180 --- /dev/null +++ b/static/styles.css @@ -0,0 +1,3 @@ +label { + margin-right: 18px; +} |