www/js/rec_edit.js

changeset 138
59874681fc13
parent 137
dfbf43b2797e
child 139
eb1ac7487710
--- a/www/js/rec_edit.js	Tue Dec 11 12:49:53 2018 +0100
+++ b/www/js/rec_edit.js	Tue Dec 11 15:01:37 2018 +0100
@@ -52,6 +52,8 @@
 	var     psugar = 0;     // Percentage real sugars
 	var     pcara = 0;      // Percentage cara/crystal malts
 	var	svg = 77;	// Default attenuation
+	var	hop_flavour = 0;
+	var	hop_aroma = 0;
 
 	console.log("record:" + my_record + "  return:" + my_return + "  theme:" + theme);
 	$("#jqxLoader").jqxLoader({
@@ -100,16 +102,17 @@
 		var result;
 
 		if ((use == "First Wort") || (use == "First wort")) {
-			result = 0.15 * amount * 1000;		// assume 15% flavourcontribution for fwh
+			result = 0.15;		// assume 15% flavourcontribution for fwh
 		} else if (bt > 50) {
-			result = 0.10 * amount * 1000;		// assume 10% flavourcontribution as a minimum
+			result = 0.10;		// assume 10% flavourcontribution as a minimum
 		} else {
-			result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2)) * amount * 1000;
-			if (result < (0.10 * amount * 1000))
-				result = 0.10 * amount * 1000;	// assume 10% flavourcontribution as a minimum
+			result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2));
+			if (result < 0.10)
+				result = 0.10;	// assume 10% flavourcontribution as a minimum
 		}
-		console.log("hopFlavourContribution("+bt+","+vol+","+use+","+amount+"): "+(result / vol));
-		return result / vol;
+		result = (result * amount * 1000) / vol;
+	//	console.log("hopFlavourContribution("+bt+","+vol+","+use+","+amount+"): "+result);
+		return result;
 	}
 
 	function hopAromaContribution(bt, vol, use, amount) {
@@ -118,36 +121,39 @@
 		if (bt > 20) {
 			result = 0;
 		} else if (bt > 7.5) {
-			result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2)) * amount * 1000;
+			result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2));
 		} else if (use == "Boil") {
-			result = amount * 1000;
+			result = 1;
 		} else if (use == "Aroma") {
-			result = 1.2 * amount * 1000;
+			result = 1.2;
 		} else if (use == "Whirlpool") {
-			result = 1.2 * amount * 1000;
+			result = 1.2;
 		} else if ((use == "Dry Hop") || (use == "Dry hop")) {
-			result = 1.33 * amount * 1000;
+			result = 1.33;
 		}
-		console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+(result / vol));
-		return result / vol;
+		result = (result * amount * 1000) / vol;
+	//	console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+result);
+		return result;
 	}
 
 	function calcIBUs() {
 		var total_ibus = 0;
+		hop_aroma = hop_flavour = 0;
 		var rows = $('#hopGrid').jqxGrid('getrows');
 		for (var i = 0; i < rows.length; i++) {
 			var row = rows[i];
 			total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')),
 					parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), $("#ibu_method").val());
-			hopFlavourContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')),
+			hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')),
 						row.h_useat, parseFloat(row.h_amount));
-			hopAromaContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')),
-					                                                row.h_useat, parseFloat(row.h_amount));
+			hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')),
+					        row.h_useat, parseFloat(row.h_amount));
 		}
 		total_ibus = Math.round(total_ibus);
-		console.log("calcIBUs(): " + total_ibus);
+		console.log("calcIBUs(): " + total_ibus + "  flavour: " + hop_flavour + "  aroma: " + hop_aroma);
 		dataRecord.est_ibu = total_ibus;
 		$('#est_ibu').val(total_ibus);
+		$('#est_ibu2').val(total_ibus);
 	};
 
 	function calcSVG() {
@@ -332,6 +338,7 @@
 	$("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
 	$("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
 	$("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
+	$("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
 	$("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
 	$("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
 
@@ -438,6 +445,7 @@
 			$("#st_color_max").val(dataRecord.st_color_max);
 			$("#color_method").val(dataRecord.color_method);
 			$("#est_ibu").val(dataRecord.est_ibu);
+			$("#est_ibu2").val(dataRecord.est_ibu);
 			$("#st_ibu_min").val(dataRecord.st_ibu_min);
 			$("#st_ibu_max").val(dataRecord.st_ibu_max);
 			$("#ibu_method").val(dataRecord.ibu_method);
@@ -1552,6 +1560,7 @@
 	$("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 });
 
 	$("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
 	$("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
 	$("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
 	$("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' });
@@ -1563,6 +1572,7 @@
 	$("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
 	$("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
 	$("#mash_sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
+	// Hop flavour and aroma gauges
 
 	// Tabs inside the popup window.
 	$('#jqxTabs').jqxTabs({

mercurial