Skip to content

Commit

Permalink
Readded screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhealey committed Aug 25, 2018
1 parent 9697d9e commit 65fa024
Show file tree
Hide file tree
Showing 84 changed files with 1,521 additions and 904 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
deliverables/
images/
master images/
Binary file modified platforms/android/.gradle/4.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/taskHistory/fileSnapshots.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/taskHistory/taskHistory.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/4.1/taskHistory/taskHistory.lock
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public final class BuildConfig {
public static final String APPLICATION_ID = "com.waist.line";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 20100;
public static final String VERSION_NAME = "2.1.0";
public static final int VERSION_CODE = 20200;
public static final String VERSION_NAME = "2.2.0";
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ var diary = {
date: undefined,
consumption:{}, //Nutrition consumed for current diary date

setCategory : function(index)
{
diary.category = index;
},

populate : function()
{
return new Promise(function(resolve, reject){
Expand Down Expand Up @@ -97,6 +102,7 @@ var diary = {
//One list per meal
for (var i = 0; i < lists.length; i++)
{
if (lists[i] == undefined) continue; //Skip unused lists - occurs if user skips a meal type in the diary settings
html = "";
html += "<ons-list modifier='inset'>";
html += lists[i];
Expand Down Expand Up @@ -457,3 +463,7 @@ $(document).on("tap", "#diary-page #nextDate", function(e){
diary.setDate(diary.date)
.then(diary.populate());
});

$(document).on("tap", "#diary-page #record-weight", function(e){
diary.recordWeight(diary.date);
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ons-toolbar modifier="material">
<div class="left"><ons-toolbar-button tappable onclick="menu.open()"><ons-icon icon="md-menu"></ons-icon></ons-toolbar-button></div>
<div class="center" data-localize="diary.title">Diary</div>
<div class="right"><ons-toolbar-button id="record-weight" onclick="diary.recordWeight(diary.date);"><ons-icon icon="fa-balance-scale"></ons-icon></ons-toolbar-button></div>
<div class="right"><ons-toolbar-button id="record-weight"><ons-icon icon="fa-balance-scale"></ons-icon></ons-toolbar-button></div>
</ons-toolbar>

<ons-card id="date-selector" style="text-align:center;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ <h4 id="name"><i></i></h4>

<p><ons-input type="number" id="quantity" step="any" required="true" placeholder="Quantity" float value="1"></ons-input></p>
<p><ons-input type="number" id="calories" step="any" placeholder="Calories" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="protein" step="any" placeholder="Protein (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="carbs" step="any" placeholder="Carbs (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="fat" step="any" placeholder="Fat (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="salt" step="any" placeholder="Salt (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="saturated-fat" step="any" placeholder="Saturated Fat(g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="carbs" step="any" placeholder="Carbs (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="sugar" step="any" placeholder="Sugar (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="protein" step="any" placeholder="Protein (g)" float readonly value="0"></ons-input></p>
<p><ons-input type="number" id="salt" step="any" placeholder="Salt (g)" float readonly value="0"></ons-input></p>
<!--Category menu will be inserted here by JS on show/init-->
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var foodList = {
list:[],
images:[], //Place to store image uris when uploading a product to Open Food Facts
lastPageId:null, //ID of the page that got us to this page, if there was one
editFormData:{}, //When edit form is populated store a copy of its data here for reference
nutriments:["calories", "fat", "saturated-fat", "carbs", "sugar", "protein", "salt"],

fillListFromDB : function()
{
Expand Down Expand Up @@ -94,14 +96,25 @@ var foodList = {
$("#edit-food-item #barcode").val(data.barcode);
$("#edit-food-item #name").val(unescape(data.name));
$("#edit-food-item #brand").val(unescape(data.brand));
$("#edit-food-item #original-portion").val(parseFloat(data.portion));
$("#edit-food-item #portion").val(parseFloat(data.portion));
$("#edit-food-item #unit").val(data.portion.replace(/[^a-z]/gi, ''));
$("#edit-food-item #calories").val(data.nutrition.calories);
$("#edit-food-item #protein").val(data.nutrition.protein);
$("#edit-food-item #carbs").val(data.nutrition.carbs);
$("#edit-food-item #fat").val(data.nutrition.fat);
$("#edit-food-item #saturated-fat").val(data.nutrition["saturated-fat"]);
$("#edit-food-item #sugar").val(data.nutrition.sugar);
$("#edit-food-item #salt").val(data.nutrition.salt);
$("#edit-food-item #salt").val(parseFloat(data.nutrition.salt).toFixed(2));

//Store form data in global object
var formData = $("#edit-food-item #edit-item-form").serializeArray();

foodList.editFormData = {};
for (i = 0; i < formData.length; i++)
{
foodList.editFormData[formData[i].name] = formData[i].value;
}

//Display image
if (data.image_url && data.image_url != "undefined" && navigator.connection.type != "none" && app.storage.getItem("show-images") === "true")
Expand Down Expand Up @@ -136,6 +149,21 @@ var foodList = {
}
},

changePortion : function(newPortion)
{
var f = "#edit-food-item #edit-item-form"; //jQuery Selector for form
var formData = foodList.editFormData; //Get reference form data

//Adjust value of each nutriment based on new portion
for (i = 0; i < foodList.nutriments.length; i++) //Each nutriment
{
var n = foodList.nutriments[i]; //Get nutriment name
var v = (formData[n] / formData.portion) * newPortion //New value

n == "calories" ? $(f + " #"+n).val(parseInt(v)) : $(f + " #"+n).val(v.toFixed(2));
}
},

processEditForm : function()
{
return new Promise(function(resolve, reject){
Expand All @@ -154,6 +182,7 @@ var foodList = {
"protein":parseFloat(form.protein.value),
"carbs":parseFloat(form.carbs.value),
"fat":parseFloat(form.fat.value),
"saturated-fat":parseFloat(form["saturated-fat"].value),
"sugar":parseFloat(form.sugar.value),
"salt":parseFloat(form.salt.value),
};
Expand Down Expand Up @@ -197,7 +226,7 @@ var foodList = {

cordova.plugins.barcodeScanner.scan(function(scanData){

//var code = "9310072001128"; //Test barcode
//var code = "40084077"; //Test barcode
var code = scanData.text;
var request = new XMLHttpRequest();

Expand Down Expand Up @@ -299,41 +328,61 @@ var foodList = {
{
var item = {};

var brands = product.brands || "";
var n = brands.indexOf(','); //Only first brand should be displayed, use this to get rid of any after ,

item.name = escape(product.product_name);
item.brand = escape(brands.substring(0, n != -1 ? n : brands.length)); //Should only be 1 brand per product
item.image_url = escape(product.image_url);
item.barcode = product.code;

//Get best match for portion/serving size
if (product.serving_size)
if (product.nutrition_data_per == "serving" || (product.serving_size && product.nutriments.energy_serving))
{
item.portion = product.serving_size.replace(/\s+/g, ''); //Remove white space
item.nutrition = {
calories: product.nutriments.energy_serving,
protein: product.nutriments.proteins_serving,
carbs: product.nutriments.carbohydrates_serving,
sugar: product.nutriments.sugars_serving,
fat: product.nutriments.fat_serving,
"saturated-fat": product.nutriments["saturated-fat_serving"],
salt: product.nutriments.salt_serving
}
}
else if (product.nutrition_data_per)
else if (product.nutrition_data_per == "100g" && product.nutriments.energy_100g)
{
item.portion = product.nutrition_data_per;
item.portion = "100g";
item.nutrition = {
calories: product.nutriments.energy_100g,
protein: product.nutriments.proteins_100g,
carbs: product.nutriments.carbohydrates_100g,
sugar: product.nutriments.sugars_100g,
fat: product.nutriments.fat_100g,
"saturated-fat": product.nutriments["saturated-fat_100g"],
salt: product.nutriments.salt_100g
}
}
else if (product.quantity)
else if (product.quantity) //If all else fails
{
item.portion = product.quantity;
}

var brands = product.brands || "";
var n = brands.indexOf(','); //Only first brand should be displayed, use this to get rid of any after ,

item.name = escape(product.product_name);
item.brand = escape(brands.substring(0, n != -1 ? n : brands.length)); //Should only be 1 brand per product
item.image_url = escape(product.image_url);
item.barcode = product.code;
item.nutrition = {
calories: parseInt(product.nutriments.energy_value),
protein: product.nutriments.proteins,
carbs: product.nutriments.carbohydrates,
fat: product.nutriments.fat,
salt: product.nutriments.salt,
sugar: product.nutriments.sugars
item.nutrition = {
calories: product.nutriments.energy_value,
protein: product.nutriments.proteins,
carbs: product.nutriments.carbohydrates,
sugar: product.nutriments.sugars,
fat: product.nutriments.fat,
"saturated-fat": product.nutriments["saturated-fat"],
salt: product.nutriments.salt
}
}

//Kilojules to kcalories
if (product.nutriments.energy_unit == "kJ")
{
item.calories = parseInt(item.calories / 4.15);
}

return item;
},

Expand Down Expand Up @@ -459,6 +508,7 @@ var foodList = {
var name = $("#upload-item-form #name").val();
var brand = $("#upload-item-form #brand").val();
var serving_size = $("#upload-item-form #serving_size").val();
var unit = $("#upload-item-form #unit").val();
var calories = $("#upload-item-form #calories").val();

//First check that there is an internet connection
Expand All @@ -468,7 +518,7 @@ var foodList = {
return false;
}

if (name != "" && brand != "" && serving_size && calories != "" && !isNaN(calories)) {
if (name != "" && brand != "" && serving_size != "" && unit != "" && calories != "" && !isNaN(calories)) {
return true;
} else {
ons.notification.alert(app.strings["dialogs"]["required-fields"]);
Expand Down Expand Up @@ -509,6 +559,9 @@ $(document).on("init", "#food-list-page", function(e){

$(document).on("keyup", "#food-list-page #filter", function(e){

$("#food-list-page ons-toolbar-button#submit").hide(); //Hide submit button until items are checked
$("#food-list-page ons-toolbar-button#scan").show(); //show scan button

if (this.value == "") //Search box cleared, reset the list
{
foodList.fillListFromDB()
Expand Down Expand Up @@ -559,15 +612,47 @@ $(document).on("tap", "#food-list-page #submit", function(e) {

if (checked.length > 0) //At least 1 item was selected
{
if (foodList.lastPageId == "diary-page")
if (foodList.lastPageId == "diary-page" || foodList.lastPageId == null)
{
//Add each item to diary
for (var i = 0; i < checked.length; i++)
if (foodList.lastPageId == null) //No last page
{
//Allow user to select diary category
var categories = JSON.parse(app.storage.getItem("meal-names"));
var options = [];
for (var i = 0; i < categories.length; i++)
{
if (categories[i] == "") continue; //Skip unset meal names
options[i] = categories[i];
}

//Ask the user to select the type of image
ons.openActionSheet({
title: 'What meal is this?',
buttons: options
})
.then(function(input){

diary.setCategory(input); //Set the diary category

//Add each item to diary
for (var i = 0; i < checked.length; i++)
{
var data = JSON.parse(checked[i].offsetParent.attributes.data.value); //Parse data from checkbox attribute
diary.addEntry(data);
}
nav.resetToPage("activities/diary/views/diary.html"); //Switch to diary page
});
}
else //Food list was accessed through diary page so category is already set
{
var data = JSON.parse(checked[i].offsetParent.attributes.data.value); //Parse data from checkbox attribute
diary.addEntry(data);
//Add each item to diary
for (var i = 0; i < checked.length; i++)
{
var data = JSON.parse(checked[i].offsetParent.attributes.data.value); //Parse data from checkbox attribute
diary.addEntry(data);
}
nav.resetToPage("activities/diary/views/diary.html"); //Switch to diary page
}
nav.resetToPage("activities/diary/views/diary.html"); //Switch to diary page
}
else if (foodList.lastPageId == "edit-meal")
{
Expand Down Expand Up @@ -607,12 +692,17 @@ $(document).on("init", "#edit-food-item", function(e){
foodList.localizeEditForm()
});

//Edit form portion
$(document).on("keyup", "#edit-food-item #portion", function(e){
foodList.changePortion(this.value);
});

//Edit form submit button action
$(document).on("tap", "#edit-food-item #submit", function(e) {

var name = $('#edit-food-item #name').val();
var portion = $('#edit-food-item #portion').val();
var calories = parseFloat($('#edit-food-item #calories').val());
var calories = $('#edit-food-item #calories').val();

//Form validation
if (name != "" && portion != "" && calories != "" && !isNaN(calories)) {
Expand Down Expand Up @@ -686,6 +776,12 @@ $(document).on("tap", "#upload-food-item #submit", function(e){
}
});

$(document).on("keyup", "#upload-food-item #portion, #upload-food-item #unit", function(e){
var portion = $("#upload-food-item #portion").val();
var unit = $("#upload-food-item #unit").val();
$("#upload-food-item #serving_size").val(portion + unit);
});

//Delete an image
$(document).on("hold", "#upload-food-item #images ons-carousel-item", function(){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
<ons-col></ons-col>
</ons-row>
<p><ons-input type="number" inputmode="numeric" pattern="[0-9]*" name="calories" id="calories" required="true" placeholder="Calories*" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="protein" id="protein" placeholder="Protein(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="carbs" id="carbs" placeholder="Carbs(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="fat" id="fat" placeholder="Fat(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="saturated-fat" id="saturated-fat" placeholder="Saturated Fat(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="carbs" id="carbs" placeholder="Carbs(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="sugar" id="sugar" placeholder="Sugar(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="protein" id="protein" placeholder="Protein(g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="salt" id="salt" placeholder="Salt(g)" float></ons-input></p>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@

<ons-card>
<div style="text-align: left; margin-top: 2em; margin-left:1em;">
<form onsubmit="foodList.updateEntry(); return false;" id="upload-item-form">
<form onsubmit="return false;" id="upload-item-form">
<p><ons-input type="text" name="code" id="barcode" required="true" placeholder="Barcode*" float readonly></ons-input></p>
<p><ons-input type="text" name="product_name" id="name" required="true" placeholder="Name*" float></ons-input></p>
<p><ons-input type="text" name="brands" id="brand" required="true" placeholder="Brand*" float></ons-input></p>
<p><ons-input type="text" name="serving_size" id="serving_size" required="true" placeholder="Serving Size*" float></ons-input></p>
<ons-row>
<ons-col style="padding-right:0.25em;"><ons-input type="number" inputmode="decimal" step="any" id="portion" required="true" placeholder="Portion*" float></ons-input></ons-col>
<ons-col style="padding-left:0.25em;"><ons-input type="text" pattern="[A-Za-z]*" id="unit" required="true" placeholder="Unit*" float></ons-input></ons-col>
<ons-col></ons-col>
</ons-row>
<p><ons-input type="number" name="nutriment_energy" inputmode="numeric" pattern="[0-9]*" id="calories" required="true" placeholder="Calories per serving*" float></ons-input></p>
<p><ons-input type="number" name="nutriment_proteins" inputmode="decimal" step="any" id="protein" placeholder="Protein per serving (g)" float></ons-input></p>
<p><ons-input type="number" name="nutriment_carbohydrates" inputmode="decimal" step="any" id="carbs" placeholder="Carbs per serving (g)" float></ons-input></p>
<p><ons-input type="number" name="nutriment_fat" inputmode="decimal" step="any" id="fat" placeholder="Fat per serving (g)" float></ons-input></p>
<p><ons-input type="number" inputmode="decimal" step="any" name="saturated-fat" id="saturated-fat" placeholder="Saturated Fat(g)" float></ons-input></p>
<p><ons-input type="number" name="nutriment_carbohydrates" inputmode="decimal" step="any" id="carbs" placeholder="Carbs Per Serving(g)" float></ons-input></p>
<p><ons-input type="number" name="nutriment_sugars" inputmode="decimal" step="any" id="sugar" placeholder="Sugar per serving (g)" float></ons-input></p>
<p><ons-input type="number" name="nutriment_proteins" inputmode="decimal" step="any" id="protein" placeholder="Protein per serving (g)" float></ons-input></p>
<p><ons-input type="number" name="nutriment_salt" inputmode="decimal" step="any" id="salt" placeholder="Salt per serving (g)" float></ons-input></p>
<input type="hidden" name="nutrition_data_per" value="serving"></input>
<input type="hidden" name="serving_size" id="serving_size" value="100g"></input> <!--Combination of serving and unit-->
<input type="hidden" name="nutriment_energy_unit" value="kcal"></input>
<input type="hidden" name="comment" id="comment"></input>
<input type="hidden" name="user_id" value="waistline-app"></input>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ $(document).on("show", "ons-page#meals", function(){
.then(function(){meals.renderMealsList(meals.list)});
});

//Double on meal item
//Double tap on meal item
$(document).on("dblclick", "#meals #meal-list ons-list-item", function(){

var control = this;
Expand Down Expand Up @@ -368,6 +368,8 @@ $(document).on("tap", "#edit-meal #submit", function(){

$(document).on("keyup", "#meals #filter", function(e){

$("#meals #submit").hide();

if (this.value == "") //Search box cleared, reset the list
{
meals.fillListFromDB()
Expand Down
Loading

0 comments on commit 65fa024

Please sign in to comment.