Compress code

Fri, 28 Jun 2019 09:36:03 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 28 Jun 2019 09:36:03 +0200
changeset 430
6fa1d64f7f16
parent 429
0d2cf505957c
child 431
a4cde20e4ced

Compress code

www/js/global.js file | annotate | diff | comparison | revisions
--- a/www/js/global.js	Thu Jun 27 13:50:27 2019 +0200
+++ b/www/js/global.js	Fri Jun 28 09:36:03 2019 +0200
@@ -774,32 +774,10 @@
 
 
 
-/*
- * Alcohol By Volume
- */
 function abvol(og,fg){
-
-	if(((og-fg)<0)||(fg<0.9))
-		return 0;
-
-	/*
-	 * Formule van Hans Halberstadt. De constante factor is afhankelijk van de
-	 * zwaarte van het wort.
-	 */
-	var factor=og*3157*Math.pow(10,-5)+9.716*Math.pow(10,-2);
-	return (og*1000-fg*1000)*factor;
-
-	/*
-	 * Dit lijkt goed en wordt in veel moderne software gebruikt, maar...
-	 * dit klopt niet. Busted door Hans Halberstadt. 
-	 * return (76.08 * (og-fg) / (1.775-og)) * (fg / 0.794); // Daniels
-	 */
-
-	/*
-	 * Brouwhulp, houdt geen rekening met zwaardere bieren.
-	 * if ((4.749804 - fg) != 0)
-	 *	return 486.8693 * (og - fg) / (4.749804 - fg);
-	 */
+if(((og-fg)<0)||(fg<0.9))return 0;
+var factor=og*3157*Math.pow(10,-5)+9.716*Math.pow(10,-2);
+return (og*1000-fg*1000)*factor;
 }
 
 
@@ -974,42 +952,22 @@
 
 
 
-function sg_to_plato(sg) {
-	// http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/
-	return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868;
-}
-
-
-
-function plato_to_sg(plato) {
-	return 1 + (plato / (258.6 - ((plato / 258.2) * 227.1)));
-}
+function sg_to_plato(sg){return ((135.997*sg-630.272)*sg+1111.14)*sg-616.868;}
+function plato_to_sg(plato){return 1+(plato/(258.6-((plato/258.2)*227.1)));}
+function brix_to_sg(brix){return plato_to_sg(brix/my_brix_correction);}
+function sg_to_brix(sg){return sg_to_plato(sg)*my_brix_correction;}
 
 
 
-function brix_to_sg(brix) {
-	return plato_to_sg(brix / my_brix_correction);
-}
-
-
-
-function sg_to_brix(sg) {
-	return sg_to_plato(sg) * my_brix_correction;
-}
-
-
-
-function estimate_sg(sugars, batch_size) {
+function estimate_sg(sugars,batch_size){
 	var plato = 100 * sugars / batch_size;
-
 	var sg = plato_to_sg(plato);
 	for (var i = 0; i < 20; i++) {
 		if (sg > 0)
 			plato = 100 * sugars / (batch_size * sg);
 		sg = plato_to_sg(plato);
 	}
-//	console.log("estimate_sg(" + sugars + "," + batch_size + ") : " + sg);
-	return sg;
+	return Math.round(sg * 10000) / 10000;
 }
 
 

mercurial