Can switch between Wait and Brewday states. Only display valid mash efficiency results.

Mon, 04 Mar 2019 19:47:47 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 04 Mar 2019 19:47:47 +0100
changeset 318
882d4da1f236
parent 317
454851b335ad
child 319
60002c09f78a

Can switch between Wait and Brewday states. Only display valid mash efficiency results.

www/js/prod_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/prod_edit.js	Mon Mar 04 15:33:34 2019 +0100
+++ b/www/js/prod_edit.js	Mon Mar 04 19:47:47 2019 +0100
@@ -884,10 +884,11 @@
 
 
 	function calcMashEfficiency() {
-//		console.log("calcMashEfficiency()");
+		if (parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')) < 1.002)
+			return;
 		var c = sg_to_plato(est_mash_sg);
 		var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
-//		console.log("c "+ c + "  m " + m + "  in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
+		//console.log("calcMashEfficiency() c "+ c + "  m " + m + "  in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
 		if (c > 0.5)
 			$("#brew_mash_efficiency").val(100 * m / c);
 		else
@@ -907,10 +908,9 @@
 			}
 		}
 		var tot = sg_to_plato(dataRecord.brew_preboil_sg) * (dataRecord.brew_preboil_volume / 1.04) * dataRecord.brew_preboil_sg * 10 / 1000;
+		var result = 0;
 		if (m > 0)
-			var result = Math.round((tot / m * 100) * 10) / 10;
-		else
-			var result = 0;
+			result = Math.round((tot / m * 100) * 10) / 10;
 		if (result < 0)
 			result = 0;
 		//console.log("calcEfficiencyBeforeBoil(): "+result);
@@ -934,10 +934,9 @@
 		}
 		var tot = sg_to_plato(dataRecord.brew_aboil_sg) * (dataRecord.brew_aboil_volume / 1.04) * dataRecord.brew_aboil_sg * 10 / 1000;
 		tot -= b;	// total sugars in wort  minus added sugars.
+		var result = 0;
 		if (m > 0)
-			var result = Math.round((tot / m * 100) * 10) / 10;
-		else
-			var result = 0;
+			result = Math.round((tot / m * 100) * 10) / 10;
 		if (result < 0)
 			result = 0;
 		//console.log("calcEfficiencyAfterBoil(): "+result);
@@ -1717,6 +1716,8 @@
 			newstage = 1;
 		if (newstage == 1 && parseFloat($("#brew_date_start").val()) > 2000)
 			newstage = 2;	// Brewday
+		if (newstage == 2 && ($("#brew_date_start").val() == ''))
+			newstage = 1;	// No brewday
 		if (newstage == 2 && parseFloat($("#brew_date_end").val()) > 2000)
 			newstage = 3;	// Primary
 		if (newstage == 3 && parseFloat($("#primary_end_date").val()) > 2000)
@@ -1751,7 +1752,7 @@
 		if (newstage == 9 && parseFloat($("#taste_date").val()) > 2000)
 			newstage = 10;	// Ready
 
-		if (newstage > dataRecord.stage) {
+		if (newstage != dataRecord.stage) {
 			console.log("calcStage() old: "+dataRecord.stage+" new: "+newstage);
 			dataRecord.stage = newstage;
 		}

mercurial