';
}
*/
document.body.innerHTML = myBody;
// This is for the user file-upload button.
// See readFile_brew3.js
// Usually, "file" refers to the one on the server.
// Here, it refers to the user's computer.
document.getElementById('userFiles').addEventListener('change',
handleFileSelect, false);
// Have it remember which file we have chosen.
//var selectedFile = document.getElementById("files");
//console.log('file ' + selectedFile.value + ' is chosen with index '
// + selectedFile.selectedIndex + ', old name is ' + selectedName
// + ' with old index ' + selectedIndex);
// Set the current file to the one we previously selected.
document.getElementById("files").selectedIndex = selectedIndex;
// Set the selected ingredients to the ones in the recipe.
for (k=0; k 0.0) {
if (searchName == 'water') {
// convert to gallons
waterSum += getActualAmountGal(Number(myRecipe[j].amount), units);
} else if (searchName == 'calcium chloride') {
// Is this the first time? Or do we already have the correct units?
if ((calciumChloride_units == 'none') ||
(calciumChloride_units == myRecipe[j].units)) {
calciumChloride_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
calciumChloride_g = true;
} else if (myRecipe[j].units == "tsp") {
calciumChloride_g = false;
} else {
calciumChloride_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
} else {
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (calciumChloride_g) {
// We had grams last time, so convert now.
amount = amount * CalciumChlorideTspEquiv;
} else {
// We had tsp last time. Convert the OLD value to grams.
CalciumChloride = CalciumChloride * CalciumChlorideTspEquiv;
calciumChloride_g = true;
}
}
CalciumChloride += amount;
} else if ((searchName.indexOf('gypsum') > -1) ||
(searchName.indexOf('calcium sulfate') > -1)) {
//console.log(' Found enrty for gypsum');
// Is this the first time? Or do we already have the correct units?
if ((gypsum_units == 'none') ||
(gypsum_units == myRecipe[j].units)) {
gypsum_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
gypsum_g = true;
} else if (myRecipe[j].units == "tsp") {
gypsum_g = false;
} else {
gypsum_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
//console.log(' First time, so now units are ' + gypsum_units);
} else {
//console.log(' problem. Units for this ingredient are different '
// + gypsum_units + ' vs ' + myRecipe[j].units);
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (gypsum_g) {
// We had grams last time, so convert now.
//console.log(' amount is ' + amount);
amount = amount * GypsumTspEquiv;
//console.log(' converted amount is ' + amount);
} else {
// We had tsp last time. Convert the OLD value to grams.
//console.log(' old sum is ' + Gypsum);
Gypsum = Gypsum * GypsumTspEquiv;
//console.log(' new sum is converted to ' + Gypsum);
gypsum_g = true;
}
}
Gypsum += amount;
} else if ((searchName.indexOf('sodium bicarbonate') > -1) ||
(searchName.indexOf('baking soda') > -1)) {
//console.log(' found ' + searchName + ' aka baking soda');
// Is this the first time? Or do we already have the correct units?
if ((bakingSoda_units == 'none') ||
(bakingSoda_units == myRecipe[j].units)) {
bakingSoda_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
bakingSoda_g = true;
} else if (myRecipe[j].units == "tsp") {
bakingSoda_g = false;
} else {
bakingSoda_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
} else {
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (bakingSoda_g) {
// We had grams last time, so convert now.
amount = amount * BakingSodaTspEquiv;
} else {
// We had tsp last time. Convert the OLD value to grams.
BakingSoda = BakingSoda * BakingSodaTspEquiv;
bakingSoda_g = true;
}
}
BakingSoda += amount;
} else if ((searchName.indexOf('epsom salt') > -1) ||
(searchName.indexOf('magnesium sulfate') > -1)) {
// Is this the first time? Or do we already have the correct units?
if ((epsomSalt_units == 'none') ||
(epsomSalt_units == myRecipe[j].units)) {
epsomSalt_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
epsomSalt_g = true;
} else if (myRecipe[j].units == "tsp") {
epsomSalt_g = false;
} else {
epsomSalt_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
} else {
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (epsomSalt_g) {
// We had grams last time, so convert now.
amount = amount * EpsomSaltTspEquiv;
} else {
// We had tsp last time. Convert the OLD value to grams.
EpsomSalt = EpsomSalt * EpsomSaltTspEquiv;
epsomSalt_g = true;
}
}
EpsomSalt += amount;
} else if ((searchName == 'burton water salts') ||
(searchName == 'burton salts')) {
// Is this the first time? Or do we already have the correct units?
if ((burtonSalt_units == 'none') ||
(burtonSalt_units == myRecipe[j].units)) {
burtonSalt_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
burtonSalt_g = true;
} else if (myRecipe[j].units == "tsp") {
burtonSalt_g = false;
} else {
burtonSalt_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
} else {
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (burtonSalt_g) {
// We had grams last time, so convert now.
amount = amount * BurtonTspEquiv;
} else {
// We had tsp last time. Convert the OLD value to grams.
BurtonSalt = BurtonSalt * BurtonTspEquiv;
burtonSalt_g = true;
}
}
BurtonSalt += amount;
} else if ((searchName.indexOf('calcium carbonate') > -1) ||
(searchName.indexOf('chalk') > -1)) {
// Is this the first time? Or do we already have the correct units?
if ((chalk_units == 'none') ||
(chalk_units == myRecipe[j].units)) {
chalk_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
chalk_g = true;
} else if (myRecipe[j].units == "tsp") {
chalk_g = false;
} else {
chalk_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
} else {
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (chalk_g) {
// We had grams last time, so convert now.
amount = amount * ChalkTspEquiv;
} else {
// We had tsp last time. Convert the OLD value to grams.
Chalk = Chalk * ChalkTspEquiv;
chalk_g = true;
}
}
Chalk += amount;
} else if ((searchName.indexOf('table salt') > -1) ||
(searchName.indexOf('sodium chloride') > -1)) {
// Is this the first time? Or do we already have the correct units?
if ((salt_units == 'none') ||
(salt_units == myRecipe[j].units)) {
salt_units = myRecipe[j].units; // Remember for next time
if (myRecipe[j].units == "g") {
salt_g = true;
} else if (myRecipe[j].units == "tsp") {
salt_g = false;
} else {
salt_g = false;
amount = getActualAmountTsp(Number(myRecipe[j].amount), units,
searchName);
//console.log("Water treatments should be specified in grams/tsp.");
}
} else {
// We have a problem. Units for this ingredient are different
// than what we saw for it earlier, e.g. 0.5 tsp Salt + 0.5 g Salt.
// So we need to translate as best we can.
if (salt_g) {
// We had grams last time, so convert now.
amount = amount * SaltTspEquiv;
} else {
// We had tsp last time. Convert the OLD value to grams.
TableSalt = TableSalt * SaltTspEquiv;
salt_g = true;
}
}
TableSalt += amount;
}
}
//console.log('At end of scan.');
}
//console.log(' brew3: calling pop-up with Baking soda value ' + BakingSoda);
// *** End scan, conversion, and sum for water adjustments
if (waterSum > 0)
waterAmount = waterSum;
//console.log('Add buttons.');
}
//
// Show the details for OG and SRM calculations.
//
function detailsPopup() {
// Make sure to update details first.
updateRecipe();
myWin=window.open('','beer recipe data',
'width=700,height=500'
+',menubar=1'
+',toolbar=1'
+',status=0'
+',scrollbars=1'
+',resizable=1')
myWin.document.writeln(''
+''
+'OG and SRM calculation details'
+''
+ detail_str
+ detail_SRM
+''
)
myWin.document.close();
}
//
// Call a function in the water.js file to show water data, and maybe change it.
//
function estimateWaterPopup() {
// First, summarize our ingredients in terms of
// gypsum, calcium carbonate, etc.
estimateWater();
var content = '';
content += Water_getBody();
content += 'Save and Close';
content += 'Cancel';
//console.log('call window.');
myWin=window.open('','beer recipe data',
'width=700,height=500'
+',menubar=1'
+',toolbar=1'
+',status=0'
+',scrollbars=1'
+',resizable=1')
myWin.document.writeln(''
+''
+'Other recipe data'
+''
+ content
+''
)
myWin.document.close();
}
//
// guess the water amount needed
// grain absorbs approximately 0.12 gallons of water per pound
// TotalWaterNeeded - (grain) * 0.12 gal per pound = boil volume
// TotalWaterNeeded = (grain) * 0.12 gal per pound + boil volume + 0.25
// also, figure out how many quarts/pound it is.
//
function estimateMashVolume() {
// Update all mash volume variables, as best as we can.
if (BoilVolume > batchSize) {
// Approximate how long the boil will take.
boildown = BoilVolume - WortVolume;
// Assume we lose 1/2 gallon per hour.
boildown = boildown * 60 / EVAP_RATE;
// Put time in hours (boilHours), minutes (boildown)
if (boildown >= 60) {
boilHours = Math.floor(boildown / 60);
boildown = Math.floor(boildown - boilHours * 60);
} else {
boilHours = 0;
}
}
oneQtPerLb = totalMalts * 0.25;
absorb = (totalMalts * ABSORB_RATE);
mashRec = (Math.floor(1.5 * oneQtPerLb * 10.0)/10.0);
MinWaterNeeded = Math.floor((absorb + Number(BoilVolume))*100.0)/100.0;
// I recommend an extra quart, thus the 0.25 below.
TotalWaterNeeded = Math.floor((0.25 + absorb + Number(BoilVolume))*100.0)/100.0;
}
//
// guess the water amount needed, and show it as a window.
//
function estimateMashVolumePopup() {
// Update out volume-related variables.
estimateMashVolume();
var str = '
Mash Volume
';
str += 'You have ' + totalMalts + ' pounds of grain. ';
str += ' The boil volume is ' + BoilVolume;
str += ', your batch size is ' + batchSize;
str += ' and your wort volume is ' + WortVolume + '. ';
if (BoilVolume <= batchSize)
str += ' Boil volume is less than or equal to the batch size. ';
else {
if (boilHours >= 1) {
str += ' It will take about ' + boilHours + ' hours and ' + boildown
+ ' minutes to reach the desired batch size. ';
} else {
str += ' It will take about ' + Math.floor(boildown)
+ ' minutes to reach the desired batch size. ';
}
}
str += ' For the mash, you want between 1 and 2 quarts per pound of grain.'
+ ' Thus, the mash should have between '
+ (Math.floor(oneQtPerLb * 10.0)/10.0) + ' and '
+ (Math.floor(2 * oneQtPerLb * 10.0)/10.0) + ' gallons of water. ';
str += ' Using an absorption rate of ' + ABSORB_RATE
+ ' gallons per pound, ';
str += ' the grain will absorb about '
+ (Math.floor(absorb * 100.0)/100.0) + ' gallons. ';
str += ' So (neglecting any trub loss) you will need at least '
+ MinWaterNeeded + ' gallons of water. ';
// TotalWaterNeeded = MinWaterNeeded + 0.25;
str += ' I recommend adding a quart extra, for a total of '
+ TotalWaterNeeded + ' gallons of water. ';
str += ' For example, you could mash with ' + mashRec
+ ' gallons, then sparge with '
+ (Math.floor(10*(TotalWaterNeeded - mashRec))/10.0)
+ ' gallons. ';
//document.getElementById("status").innerHTML = str;
mashVolumePopup('Mash Volume', str);
}
function checkAccess_and_showPage() {
check4access(cookieToken);
showPage();
// Get a list of files?
// Do this AFTER showPage, since showPage defines "myDropDown", which we
// need.
if (DEBUG_No_Network) {
console.log('Not getting file list since DEBUG_No_Network is true.');
} else
ls();
}
// end hide -->