-
Notifications
You must be signed in to change notification settings - Fork 4
/
loadjs.js
27 lines (23 loc) · 1.1 KB
/
loadjs.js
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
function loadDataFromTables(targetArray) { //targetArray generation
//load data from local tables.js and generating static cols
var divPageStats = document.getElementById("pageStats");
divPageStats.innerHTML = "Loading data...";
var food = gl_food;
var ifep = gl_fepmod;
var sats = gl_sat;
for (var fi = 0; fi < food.length; fi++) {
if (food[fi][1].length > 0) { //if food has variable ingredients...
for (var j = 0; j < ifep.length; ) { // ...then cycle through all FEP mods records
if (ifep[j][0] == food[fi][0]) {
targetArray.push([ ifep[j][0], ifep[j][1], ifep[j][2], sumFEP(ifep[j][2]), food[fi][4], (sumFEP(ifep[j][2]) / food[fi][4]), sats[food[fi][0]] ]);
ifep.splice(j, 1); //remove found FEP mods record to exclude it from future cycles
} else {
j++;
}
}
} else { // ...else just add food as one single row (Name, Ings, FEP, F, H, F/H, V)
targetArray.push([ food[fi][0], food[fi][1], food[fi][2], sumFEP(food[fi][2]), food[fi][4], (sumFEP(food[fi][2]) / food[fi][4]), sats[food[fi][0]] ]);
}
}
refreshView();
}