www/js/global.js

changeset 463
0efdafd23753
parent 462
c91175610f8a
child 465
dc3e14b976be
--- a/www/js/global.js	Thu Sep 05 14:43:04 2019 +0200
+++ b/www/js/global.js	Thu Sep 05 20:14:16 2019 +0200
@@ -871,7 +871,6 @@
 var i = Math.round(srm * 10);
 if(i<0)i=0;
 if(i>299)i=299;
-
 /* Table copied from Brouwhulp/BrewBuddy */
 var R=[
 250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,//0
@@ -883,13 +882,12 @@
 192,192,192,192,192,192,192,192,191,190,189,188,187,186,185,184,183,182,181,180,//12
 179,178,177,175,174,172,171,169,168,167,195,164,162,161,159,158,157,155,154,152,//14
 151,149,148,147,145,144,142,141,139,138,137,135,134,132,131,129,128,127,125,124,//16
-122,121,119,118,117,115,114,112,111,109,108,107,105,104,102,101, 99, 98, 97, 95,//18
- 94, 92, 91, 89, 88, 87, 85, 84, 82, 81, 79, 78, 77, 75, 74, 72, 71, 69, 68, 67,//20
- 65, 64, 62, 61, 59, 58, 57, 55, 54, 52, 51, 49, 48, 47, 45, 44, 43, 41, 39, 38,//22
- 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28,//24
- 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18,//26
- 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10,  9,  9,  8,  8];
-
+122,121,119,118,117,115,114,112,111,109,108,107,105,104,102,101,99,98,97,95,//18
+94,92,91,89,88,87,85,84,82,81,79,78,77,75,74,72,71,69,68,67,//20
+65,64,62,61,59,58,57,55,54,52,51,49,48,47,45,44,43,41,39,38,//22
+37,37,36,36,35,35,34,34,33,33,32,32,31,31,30,30,29,29,28,28,//24
+27,27,26,26,25,25,24,24,23,23,22,22,21,21,20,20,19,19,18,18,//26
+17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9,9,8,8];
 var G=[
 250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
 250,250,250,250,250,250,249,248,247,246,245,244,242,240,238,236,234,232,230,228,
@@ -897,40 +895,35 @@
 186,184,182,180,178,176,174,172,170,168,166,164,162,160,158,156,154,152,150,148,
 146,144,142,141,140,139,139,138,137,136,136,135,134,133,133,132,131,130,130,129,
 128,127,127,126,125,124,124,123,122,121,121,120,119,118,118,117,116,115,115,114,
-113,112,112,111,110,109,109,108,107,106,106,105,104,103,103,102,101,100,100, 99,
- 98, 97, 97, 96, 95, 94, 94, 93, 92, 91, 91, 90, 89, 88, 88, 87, 86, 85, 85, 84,
- 83, 82, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 72, 71, 70, 69, 69, 68,
- 67, 66, 66, 65, 64, 63, 63, 62, 61, 60, 60, 59, 58, 57, 57, 56, 55, 54, 54, 53,
- 52, 51, 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 39, 38,
- 37, 36, 36, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28, 27, 27, 26, 25, 24, 24, 23,
- 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16,
- 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10,  9,
-  9,  9,  8,  8,  8,  7,  7,  7,  6,  6,  6,  5,  5,  5,  4,  4,  4,  3,  3,  3];
-
+113,112,112,111,110,109,109,108,107,106,106,105,104,103,103,102,101,100,100,99,
+98,97,97,96,95,94,94,93,92,91,91,90,89,88,88,87,86,85,85,84,
+83,82,82,81,80,79,78,77,76,75,75,74,73,72,72,71,70,69,69,68,
+67,66,66,65,64,63,63,62,61,60,60,59,58,57,57,56,55,54,54,53,
+52,51,51,50,49,48,48,47,46,45,45,44,43,42,42,41,40,39,39,38,
+37,36,36,35,34,33,33,32,31,30,30,29,28,27,27,26,25,24,24,23,
+22,22,22,21,21,21,20,20,20,19,19,19,18,18,18,17,17,17,16,16,
+16,15,15,15,14,14,14,13,13,13,12,12,12,11,11,11,10,10,10,9,
+9,9,8,8,8,7,7,7,6,6,6,5,5,5,4,4,4,3,3,3];
 var B=[
 210,204,199,193,188,182,177,171,166,160,155,149,144,138,133,127,122,116,111,105,
-100, 94, 89, 83, 78, 72, 67, 61, 56, 50, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47,
- 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52,
- 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 52, 51,
- 51, 51, 51, 50, 50, 50, 50, 49, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 41,
- 41, 40, 39, 39, 38, 37, 37, 36, 35, 34, 33, 32, 31, 29, 28, 27, 26, 25, 24, 23,
- 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10,  9,  8,  9,  9, 10, 10, 11, 11, 12,
- 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22,
- 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 15, 15,
- 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10,  9,  9,  9,  8,
-  8,  8,  7,  7,  7,  6,  6,  6,  5,  5,  5,  4,  4,  4,  3,  3,  3,  2,  2,  2];
-
+100,94,89,83,78,72,67,61,56,50,45,45,45,46,46,46,46,47,47,47,
+47,48,48,48,48,49,49,49,49,50,50,50,50,51,51,51,51,52,52,52,
+52,53,53,53,53,54,54,54,54,55,55,55,55,56,56,56,56,56,56,56,
+56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
+56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
+56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,
+56,56,56,55,55,55,55,54,54,54,54,53,53,53,53,52,52,52,52,51,
+51,51,51,50,50,50,50,49,49,48,47,47,46,45,45,44,43,43,42,41,
+41,40,39,39,38,37,37,36,35,34,33,32,31,29,28,27,26,25,24,23,
+21,20,19,18,17,16,15,13,12,11,10,9,8,9,9,10,10,11,11,12,
+12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,
+21,21,21,20,20,20,19,19,19,18,18,18,17,17,17,17,16,16,15,15,
+15,14,14,14,13,13,13,12,12,12,11,11,11,10,10,10,9,9,9,8,
+8,8,7,7,7,6,6,6,5,5,5,4,4,4,3,3,3,2,2,2];
 var color=R[i]*65536+G[i]*256+B[i];
 var result=color.toString(16).toUpperCase();
-if(result.length<6) {
-result='0'+result;
-}
-result='#'+result;
-return result;
+if(result.length<6)result='0'+result;
+return '#'+result;
 }
 
 
@@ -940,59 +933,46 @@
 function brix_to_sg(brix){if(my_brix_correction>0)return plato_to_sg(brix/my_brix_correction);else return plato_to_sg(brix);}
 function sg_to_brix(sg){return sg_to_plato(sg)*my_brix_correction;}
 
-
-
 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);
-	}
-	return Round(sg,4);
+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);}
+return Round(sg,4);
 }
 
 
 
-function estimate_fg(percSugar, percCara, WGratio, TotTme, Temp, attenuation, og) {
+function estimate_fg(percSugar,percCara,WGratio,TotTme,Temp,attenuation,og){
 
-	var	BD;
+var BD;
 
-	if (percSugar > 40)
-		percSugar = 0;
-	if (percCara > 50)
-		percCara = 0;
-	if ((WGratio > 0) && (TotTme > 0)) {
-		BD = WGratio;
-		if (BD < 2)
-			BD = 2;
-		if (BD > 5.5)
-			BD = 5.5;
-		if (Temp < 60)
-			Temp = 60;
-		if (Temp > 72)
-			Temp = 72;
-	} else {
-		BD = 3.5;
-		Temp = 67;
-		TotTme = 75;
-	}
-	if (attenuation < 30)
-		attenuation = 77;
+if(percSugar>40)percSugar=0;
+if(percCara>50)percCara=0;
+if((WGratio>0)&&(TotTme>0)){
+BD=WGratio;
+if(BD<2)BD=2;
+if(BD>5.5)BD=5.5;
+if(Temp<60)Temp=60;
+if(Temp>72)Temp=72;
+}else{
+BD=3.5;
+Temp=67;
+TotTme=75;
+}
+if(attenuation<30)attenuation=77;
 
-	// 0.00825 Attenuation factor yeast
-	// 0.00817 Attenuation factor water/grain ration
-	// -0.00684 Attenuation factor mash temperature
-	// 0.00026 Attenuation factor total mash time  (at some places this is 0.0026 this is wrong!)
-	// -0.00356 Attenuation factor percentage crystal malt
-	// 0.00553 Attenuation factor percentage simple sugars
-	// 0.547 Attenuation factor constant
-	var AttBeer = 0.00825 * attenuation + 0.00817 * BD - 0.00684 * Temp + 0.00026 * TotTme - 0.00356 * percCara + 0.00553 * percSugar + 0.547;
-	var fg = Round(1 + (1 - AttBeer) * (og - 1),4);
+// 0.00825 Attenuation factor yeast
+// 0.00817 Attenuation factor water/grain ration
+// -0.00684 Attenuation factor mash temperature
+// 0.00026 Attenuation factor total mash time  (at some places this is 0.0026 this is wrong!)
+// -0.00356 Attenuation factor percentage crystal malt
+// 0.00553 Attenuation factor percentage simple sugars
+// 0.547 Attenuation factor constant
+var AttBeer=0.00825*attenuation+0.00817*BD-0.00684*Temp+0.00026*TotTme-0.00356*percCara+0.00553*percSugar+0.547;
+var fg=Round(1+(1-AttBeer)*(og-1),4);
 
-	console.log("estimate_fg("+percSugar+","+percCara+","+BD+","+TotTme+","+Temp+","+attenuation+","+og+") AttBeer:"+AttBeer+" fg:"+fg);
-	return fg;
+console.log("estimate_fg("+percSugar+","+percCara+","+BD+","+TotTme+","+Temp+","+attenuation+","+og+") AttBeer:"+AttBeer+" fg:"+fg);
+return fg;
 }
 
 

mercurial