www/js/rec_edit.js

changeset 428
a5d4467c9201
parent 406
0ad967f2d6ee
child 474
7b7df475e67d
--- a/www/js/rec_edit.js	Thu Jun 20 22:16:05 2019 +0200
+++ b/www/js/rec_edit.js	Fri Jun 21 16:55:36 2019 +0200
@@ -271,6 +271,7 @@
 		dataRecord.est_og = estimate_sg(sugarsf + addedS, parseFloat(dataRecord.batch_size));
 		$('#est_og').val(dataRecord.est_og);
 		$('#est_og2').val(dataRecord.est_og);
+		var org = dataRecord.est_og;
 
 		// Estimate SG in kettle before boil
 		preboil_sg = estimate_sg(sugarsm, parseFloat(dataRecord.boil_size));
@@ -318,10 +319,16 @@
 		}
 		$('#est_fg').val(dataRecord.est_fg);
 		$('#est_fg2').val(dataRecord.est_fg);
+		var fig = dataRecord.est_fg;
 
 		dataRecord.est_abv = abvol(dataRecord.est_og, dataRecord.est_fg);
 		$("#est_abv").val(dataRecord.est_abv);
 		$("#est_abv2").val(dataRecord.est_abv);
+
+		// Calculate the calories in kcal/l (from brouwhulp)
+		var alc = 1881.22 * fig * (org - fig) / (1.775 - org);
+		var sug = 3550 * fig * (0.1808 * org + 0.8192 * fig - 1.0004);
+		$("#kcal").val(Math.round((alc + sug) / (12 * 0.0295735296)));
 	};
 
 	function hopFlavourContribution(bt, vol, use, amount) {
@@ -2809,13 +2816,13 @@
 	$("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
 	$("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
 	$("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
-	$("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
+	$("#st_letter").jqxInput({ theme: theme, width: 90, height: 23 });
 	$("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
 	$("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
 	$("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'});
 	$("#st_category").jqxInput({ theme: theme, width: 250, height: 23 });
 	$("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
-	$("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_category_number").jqxNumberInput( Smal0dec );
 	$("#st_type").jqxTooltip({ content: 'Het bierstijl type.'});
 	$("#st_type").jqxInput({ theme: theme, width: 250, height: 23 });
 
@@ -2834,18 +2841,18 @@
 	$("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
 
 	$("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
-	$("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#est_abv").jqxNumberInput( Smal1dec );
 	$("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
-	$("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_abv_min").jqxNumberInput( Smal1dec );
 	$("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
-	$("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_abv_max").jqxNumberInput( Smal1dec );
 
 	$("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
 	$("#est_color").jqxNumberInput( Show0dec );
 	$("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
-	$("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_color_min").jqxNumberInput( Smal0dec );
 	$("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
-	$("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_color_max").jqxNumberInput( Smal0dec );
 	$("#color_method").jqxDropDownList({
 		theme: theme,
 		source: ColorMethodAdapter,
@@ -2855,13 +2862,12 @@
 		height: 23,
 		autoDropDownHeight: true
 	});
-
 	$("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
 	$("#est_ibu").jqxNumberInput( Show0dec );
 	$("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
-	$("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_ibu_min").jqxNumberInput( Smal0dec );
 	$("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
-	$("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_ibu_max").jqxNumberInput( Smal0dec );
 	$("#ibu_method").jqxDropDownList({
 		theme: theme,
 		source: IBUmethodAdapter,
@@ -2872,13 +2878,14 @@
 		autoDropDownHeight: true,
 		dropDownVerticalAlignment: 'top'
 	});
-
+	$("#kcal").jqxTooltip({ content: 'Energie-inhoud in kcal/liter.' });
+	$("#kcal").jqxNumberInput( Smal0dec );
 	$("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
-	$("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#est_carb").jqxNumberInput( Smal1dec );
 	$("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
-	$("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_carb_min").jqxNumberInput( Smal1dec );
 	$("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
-	$("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_carb_max").jqxNumberInput( Smal1dec );
 
 	// Tab 2, Vergistbaar
 	$("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
@@ -3163,7 +3170,7 @@
 
 	// Tab 3, Hoppen
 	$("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
-	$("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#est_ibu2").jqxNumberInput( Smal0dec );
 	$("#hop_flavour").jqxProgressBar({
 		width: 300,
 		height: 23,
@@ -3480,7 +3487,7 @@
 	$("#est_fg2").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
 	$("#est_fg2").jqxNumberInput( Show3dec );
 	$("#est_abv2").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
-	$("#est_abv2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#est_abv2").jqxNumberInput( Smal1dec );
 	$("#popupYeast").jqxWindow({
 		width: 800,
 		height: 300,

mercurial