"+foods[i].name+" | "+foods[i].intake.energy.toFixed(2)+" | "+foods[i].intake.protein.toFixed(2)+" | "+foods[i].intake.iron.toFixed(2)+" | "+foods[i].intake.vitA.toFixed(2)+" | "+foods[i].intake.thiamine.toFixed(2)+" | "+foods[i].intake.riboflavin.toFixed(2)+" | "+foods[i].intake.vitC.toFixed(2)+" | ");
+ }
+ $("#show-value").append("Total | "+total.intake.energy.toFixed(2)+" | "+total.intake.protein.toFixed(2)+" | "+total.intake.iron.toFixed(2)+" | "+total.intake.vitA.toFixed(2)+" | "+total.intake.thiamine.toFixed(2)+" | "+total.intake.riboflavin.toFixed(2)+" | "+total.intake.vitC.toFixed(2)+" |
");
+
+ $("#show-compare").html("Nutrient | Requirement | Intake | Deficeiency / Excess |
");
+ $("#show-summary").html("");
+ if(total.diff.energy.state=="+"){
+ $("#show-compare").append("Energy | "+total.requirement.energy.toFixed(2)+" | "+total.intake.energy.toFixed(2)+" | "+total.diff.energy.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Energy consumption is excess by "+((total.diff.energy.value*100)/total.requirement.energy).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Energy | "+total.requirement.energy.toFixed(2)+" | "+total.intake.energy.toFixed(2)+" | "+total.diff.energy.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Energy consumption is deficient by "+((total.diff.energy.value*100)/total.requirement.energy).toFixed(2)+"%");
+ }
+ if(total.diff.protein.state=="+"){
+ $("#show-compare").append("Protein | "+total.requirement.protein.toFixed(2)+" | "+total.intake.protein.toFixed(2)+" | "+total.diff.protein.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Protein consumption is excess by "+((total.diff.protein.value*100)/total.requirement.protein).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Protein | "+total.requirement.protein.toFixed(2)+" | "+total.intake.protein.toFixed(2)+" | "+total.diff.protein.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Protein consumption is deficient by "+((total.diff.protein.value*100)/total.requirement.protein).toFixed(2)+"%");
+ }
+ if(total.diff.iron.state=="+"){
+ $("#show-compare").append("Iron | "+total.requirement.iron.toFixed(2)+" | "+total.intake.iron.toFixed(2)+" | "+total.diff.iron.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Iron consumption is excess by "+((total.diff.iron.value*100)/total.requirement.iron).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Iron | "+total.requirement.iron.toFixed(2)+" | "+total.intake.iron.toFixed(2)+" | "+total.diff.iron.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Iron consumption is deficient by "+((total.diff.iron.value*100)/total.requirement.iron).toFixed(2)+"%");
+ }
+ if(total.diff.vitA.state=="+"){
+ $("#show-compare").append("Vitamin A | "+total.requirement.vitA.toFixed(2)+" | "+total.intake.vitA.toFixed(2)+" | "+total.diff.vitA.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Vitamin A consumption is excess by "+((total.diff.vitA.value*100)/total.requirement.vitA).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Vitamin A | "+total.requirement.vitA.toFixed(2)+" | "+total.intake.vitA.toFixed(2)+" | "+total.diff.vitA.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Vitamin A consumption is deficient by "+((total.diff.vitA.value*100)/total.requirement.vitA).toFixed(2)+"%");
+ }
+ if(total.diff.thiamine.state=="+"){
+ $("#show-compare").append("Thiamine | "+total.requirement.thiamine.toFixed(2)+" | "+total.intake.thiamine.toFixed(2)+" | "+total.diff.thiamine.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Thiamine consumption is excess by "+((total.diff.thiamine.value*100)/total.requirement.thiamine).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Thiamine | "+total.requirement.thiamine.toFixed(2)+" | "+total.intake.thiamine.toFixed(2)+" | "+total.diff.thiamine.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Thiamine consumption is deficient by "+((total.diff.thiamine.value*100)/total.requirement.thiamine).toFixed(2)+"%");
+ }
+ if(total.diff.riboflavin.state=="+"){
+ $("#show-compare").append("Riboflavin | "+total.requirement.riboflavin.toFixed(2)+" | "+total.intake.riboflavin.toFixed(2)+" | "+total.diff.riboflavin.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Riboflavin consumption is excess by "+((total.diff.riboflavin.value*100)/total.requirement.riboflavin).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Riboflavin | "+total.requirement.riboflavin.toFixed(2)+" | "+total.intake.riboflavin.toFixed(2)+" | "+total.diff.riboflavin.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Riboflavin consumption is deficient by "+((total.diff.riboflavin.value*100)/total.requirement.riboflavin).toFixed(2)+"%");
+ }
+ if(total.diff.vitC.state=="+"){
+ $("#show-compare").append("Vitamin C | "+total.requirement.vitC.toFixed(2)+" | "+total.intake.vitC.toFixed(2)+" | "+total.diff.vitC.value.toFixed(2)+" excess |
");
+ $("#show-summary").append("Vitamin C consumption is excess by "+((total.diff.vitC.value*100)/total.requirement.vitC).toFixed(2)+"%");
+ }
+ else{
+ $("#show-compare").append("Vitamin C | "+total.requirement.vitC.toFixed(2)+" | "+total.intake.vitC.toFixed(2)+" | "+total.diff.vitC.value.toFixed(2)+" deficient |
");
+ $("#show-summary").append("Vitamin C consumption is deficient by "+((total.diff.vitC.value*100)/total.requirement.vitC).toFixed(2)+"%");
+ }
+}
+
+function enum_date(){
+ for(i=2010; i<=2020; i++){
+ if(i==2014){
+ $("#date-year").append("");
+ }
+ else{
+ $("#date-year").append("");
+ }
+ }
+ for(i=1; i<=12; i++){
+ if(i==10){
+ $("#date-month").append("");
+ }
+ else{
+ $("#date-month").append("");
+ }
+ }
+ adjust_day(10);
+}
+
+function adjust_day(month){
+ lim=31;
+ if(month==2){
+ lim=28;
+ }
+ else if(month==4||month==6||month==9||month==11){
+ lim=30;
+ }
+ day=$("#date-day").val();
+ $("#date-day").html("");
+ if(day>lim){
+ day=lim;
+ }
+ for(i=1; i<=lim; i++){
+ if(i==day){
+ $("#date-day").append("");
+ }
+ else{
+ $("#date-day").append("");
+ }
+ }
+}
+
+function display_member(mem, i){
+ html=''
+ +'
'
+ +'
';
+ if(mem.age>=18 && mem.age<=45 && mem.sex=="Female"){
+ if(mem.state=="npnl"){
+ state="";
+ }
+ else if(mem.state=="preg"){
+ state="Pregnant";
+ }
+ else if(mem.state=="lactb6"){
+ state="Lactating, below 6 months";
+ }
+ else if(mem.state=="lacto6"){
+ state="Lactating, over 6 months";
+ }
+ if(state!=""){
+ html=html+'';
+ }
+ }
+ html=html+'
';
+ return html;
+}
+
+function display_food(item, i){
+ html=''+item.name+' | '+item.amount+' | |
';
+ return html;
+}
+
+function draw_bar_diagram(){
+ data={
+ labels: ["Energy", "Protein", "Iron", "Vitamine A", "Thiamine", "Riboflavin", "Vitamin C"],
+ datasets: [
+ {
+ label: "dataset",
+ fillColor: "rgba(151,187,205,0.5)",
+ strokeColor: "rgba(151,187,205,0.8)",
+ highlightFill: "rgba(151,187,205,0.75)",
+ highlightStroke: "rgba(151,187,205,1)",
+ data: [parseFloat(((total.intake.energy*100)/total.requirement.energy).toFixed(2)), parseFloat(((total.intake.protein*100)/total.requirement.protein).toFixed(2)), parseFloat(((total.intake.iron*100)/total.requirement.iron).toFixed(2)), parseFloat(((total.intake.vitA*100)/total.requirement.vitA).toFixed(2)), parseFloat(((total.intake.thiamine*100)/total.requirement.thiamine).toFixed(2)), parseFloat(((total.intake.riboflavin*100)/total.requirement.riboflavin).toFixed(2)), parseFloat(((total.intake.vitC*100)/total.requirement.vitC).toFixed(2))]
+ }
+ ]
+ };
+
+
+ var ctx=$("#bar-diagram").get(0).getContext("2d");
+ var diagram=new Chart(ctx).Bar(data);
+}