www/js/global.js

changeset 220
14e349ff2a10
parent 217
318aab371497
child 221
a8aabb63fbcc
--- a/www/js/global.js	Sun Jan 27 23:35:19 2019 +0100
+++ b/www/js/global.js	Tue Jan 29 21:52:08 2019 +0100
@@ -125,6 +125,21 @@
 };
 var HopFormAdapter = new $.jqx.dataAdapter(HopFormSource);
 
+var HopUseData = [
+	{ id: 0, en: 'Mash',       nl: 'maischhop' },
+	{ id: 1, en: 'First wort', nl: 'first wort hop' },
+	{ id: 2, en: 'Boil',       nl: 'koken' },
+	{ id: 3, en: 'Aroma',      nl: 'vlamuit' },
+	{ id: 4, en: 'Whirlpool',  nl: 'whirlpool' },
+	{ id: 5, en: 'Dry hop',    nl: 'koudhop' }
+];
+var HopUseSource = {
+	localdata: HopUseData,
+	datatype: "array",
+	datafields: [{ name: 'id' }, { name: 'en' }, { name: 'nl' }]
+};
+var HopUseAdapter = new $.jqx.dataAdapter(HopUseSource);
+
 var YeastTypeData = [
 	{ id: 0, en: 'Lager',     nl: 'ondergist' },
 	{ id: 1, en: 'Ale',       nl: 'bovengist' },
@@ -154,6 +169,19 @@
 };
 var YeastFormAdapter = new $.jqx.dataAdapter(YeastFormSource);
 
+var YeastUseData = [
+	{ id: 0, en: 'Primary',   nl: 'Hoofdgisting' },
+	{ id: 1, en: 'Secondary', nl: 'Nagisting' },
+	{ id: 2, en: 'Tertiary',  nl: 'Lagering' },
+	{ id: 3, en: 'Bottle',    nl: 'Bottelen' }
+];
+var YeastUseSource = {
+	localdata: YeastUseData,
+	datatype: "array",
+	datafields: [{ name: 'id' }, { name: 'en' }, { name: 'nl' }, { name: 'cells' }]
+};
+var YeastUseAdapter = new $.jqx.dataAdapter(YeastUseSource);
+
 var FlocculationData = [
 	{ id: 0, en: 'Low',       nl: 'laag' },
 	{ id: 1, en: 'Medium',    nl: 'medium' },
@@ -342,6 +370,12 @@
 };
 var BaseTypeAdapter = new $.jqx.dataAdapter(BaseTypeSource);
 
+var SpargeSourceData = [
+	{ id: 0, en: 'Source 1', nl: 'Bron 1' },
+	{ id: 1, en: 'Source 2', nl: 'Bron 2' },
+	{ id: 2, en: 'Mixed',    nl: 'Gemengd' }
+];
+
 
 // options for editors
 
@@ -360,6 +394,9 @@
 var Spin2dec5 = {
 	inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05
 };
+var Spin3dec5 = {
+	        inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.005
+};
 var SpinpH = {
 	inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 1, max: 14, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1
 };
@@ -400,7 +437,7 @@
 		{ name: 'category_number', type: 'number' },
 		{ name: 'style_letter', type: 'string' },
 		{ name: 'style_guide', type: 'string' },
-		{ name: 'type', type: 'string' },
+		{ name: 'type', type: 'int' },
 		{ name: 'og_min', type: 'float' },
 		{ name: 'og_max', type: 'float' },
 		{ name: 'fg_min', type: 'float' },
@@ -434,13 +471,13 @@
 		{ name: 'tun_volume', type: 'float' },
 		{ name: 'tun_weight', type: 'float' },
 		{ name: 'tun_specific_heat', type: 'float' },
-		{ name: 'tun_material', type: 'string' },
+		{ name: 'tun_material', type: 'int' },
 		{ name: 'tun_height', type: 'float' },
 		{ name: 'top_up_water', type: 'float' },
 		{ name: 'trub_chiller_loss', type: 'float' },
 		{ name: 'evap_rate', type: 'float' },
 		{ name: 'boil_time', type: 'float' },
-		{ name: 'calc_boil_volume', type: 'bool' },
+		{ name: 'calc_boil_volume', type: 'int' },
 		{ name: 'top_up_kettle', type: 'float' },
 		{ name: 'hop_utilization', type: 'float' },
 		{ name: 'notes', type: 'string' },
@@ -464,10 +501,10 @@
         datafields: [
                 { name: 'record', type: 'number' },
                 { name: 'name', type: 'string' },
-                { name: 'type', type: 'string' },
+                { name: 'type', type: 'int' },
                 { name: 'yield', type: 'float' },
                 { name: 'color', type: 'float' },
-                { name: 'add_after_boil', type: 'bool' },
+                { name: 'add_after_boil', type: 'int' },
                 { name: 'origin', type: 'string' },
                 { name: 'supplier', type: 'string' },
                 { name: 'coarse_fine_diff', type: 'float' },
@@ -475,8 +512,8 @@
                 { name: 'diastatic_power', type: 'float' },
                 { name: 'protein', type: 'float' },
                 { name: 'max_in_batch', type: 'float' },
-                { name: 'recommend_mash', type: 'bool' },
-                { name: 'graintype', type: 'string' },
+                { name: 'recommend_mash', type: 'int' },
+                { name: 'graintype', type: 'int' },
                 { name: 'di_ph', type: 'float' },
                 { name: 'inventory', type: 'float' },
         	{ name: 'cost', type: 'float' }
@@ -507,7 +544,7 @@
 		{ name: 'record', type: 'number' },
 		{ name: 'name', type: 'string' },
 		{ name: 'origin', type: 'string' },
-		{ name: 'type', type: 'string' },
+		{ name: 'type', type: 'int' },
 		{ name: 'alpha', type: 'float' },
 		{ name: 'beta', type: 'float' },
 		{ name: 'humulene', type: 'float' },
@@ -515,8 +552,8 @@
 		{ name: 'cohumulone', type: 'float' },
 		{ name: 'myrcene', type: 'float' },
 		{ name: 'hsi', type: 'float' },
-		{ name: 'useat', type: 'string' },
-		{ name: 'form', type: 'string' },
+		{ name: 'useat', type: 'int' },
+		{ name: 'form', type: 'int' },
 		{ name: 'total_oil', type: 'float' },
 		{ name: 'inventory', type: 'float' },
 		{ name: 'cost', type: 'float' }
@@ -546,9 +583,9 @@
 	datafields: [
 		{ name: 'record', type: 'number' },
 		{ name: 'name', type: 'string' },
-		{ name: 'type', type: 'string' },
-		{ name: 'use_use', type: 'string' },
-		{ name: 'amount_is_weight', type: 'bool' },
+		{ name: 'type', type: 'int' },
+		{ name: 'use_use', type: 'int' },
+		{ name: 'amount_is_weight', type: 'int' },
 		{ name: 'time', type: 'float' },
 		{ name: 'inventory', type: 'float' },
 		{ name: 'cost', type: 'float' }
@@ -578,8 +615,8 @@
 	datafields: [
 		{ name: 'record', type: 'number' },
 		{ name: 'name', type: 'string' },
-		{ name: 'type', type: 'string' },
-		{ name: 'form', type: 'string' },
+		{ name: 'type', type: 'int' },
+		{ name: 'form', type: 'int' },
 		{ name: 'laboratory', type: 'string' },
 		{ name: 'product_id', type: 'string' },
 		{ name: 'min_temperature', type: 'float' },
@@ -613,7 +650,7 @@
 	datafields: [
 		{ name: 'record', type: 'number' },
 		{ name: 'name', type: 'string' },
-		{ name: 'unlimited_stock', type: 'bool' },
+		{ name: 'unlimited_stock', type: 'int' },
 		{ name: 'calcium', type: 'float' },
 		{ name: 'sulfate', type: 'float' },
 		{ name: 'chloride', type: 'float' },
@@ -778,11 +815,11 @@
  */
 function kw_to_srm(colormethod, c) {
 
-	if (colormethod == "Morey")
+	if (colormethod == 0)	// Morey
 		return 1.4922 * Math.pow(c, 0.6859);
-	if (colormethod == "Mosher")
+	if (colormethod == 1)	// Mosher
 		return 0.3 * c + 4.7;
-	if (colormethod == "Daniels")
+	if (colormethod == 2)	// Daniels
 		return 0.2 * c + 8.4;
 }
 
@@ -808,22 +845,22 @@
 	var pfactor = 1.0;
 	var ibu     = 0;
 
-	if ((Use == "Dry Hop") || (Use == "Dry hop") || (Use == "Whirlpool") || (Use == "Aroma")) {
+	if ((Use == 3) || (Use == 4) || (Use == 5)) {	// Aroma, Whirlpool or Dry hop.
 		fmoment = 0.0;
-	} else if (Use == "Mash") {
-		fmoment += my_factor_mashhop / 100;		// Brouwhulp
-	} else if ((Use == "First Wort") || (Use == "First wort"))  {
-		fmoment += my_factor_fwh  / 100;		// Brouwhulp, Louis, Ozzie
+	} else if (Use == 0) {				// Mash
+		fmoment += my_factor_mashhop / 100;	// Brouwhulp
+	} else if (Use == 1) {				// First wort
+		fmoment += my_factor_fwh  / 100;	// Brouwhulp, Louis, Ozzie
 	}
 
-	if (Form == "Pellet") {
+	if (Form == 0) {	// Pellet
 		pfactor += my_factor_pellet / 100;
 	}
-	if (Form == "Plug" ) {
+	if (Form == 1 ) {	// Plug
 		pfactor += my_factor_plug / 100;
 	}
 
-	if (Method == "Tinseth") {
+	if (Method == 0) {	// Tinseth
 		/* http://realbeer.com/hops/research.html */
 		var AddedAlphaAcids = (alpha * mass * 1000) / liters;
 		var Bigness_factor = 1.65 * Math.pow( 0.000125, gravity - 1);
@@ -831,10 +868,10 @@
 		var utiisation = Bigness_factor * BoilTime_factor;
 		ibu = Math.round(utiisation * AddedAlphaAcids * fmoment * pfactor * 10) / 10.0;
 	}
-	if (Method == "Daniels") {
+	if (Method == 2) {	// Daniels
 		var boilfactor;
 		var sgfactor;
-		if (Form == "Leaf")
+		if (Form == 2)	// Leaf
 			boilfactor = -(0.0041*time*time)+(0.6162*time)+1.5779;
 		else
 			boilfactor = -(0.0051*time*time)+(0.7835*time)+1.9348;
@@ -844,7 +881,7 @@
 			sgfactor = (gravity - 1050) / 200;
 		ibu = Math.round(fmoment * ((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor))) * 10) / 10;
 	}
-	if (Method == "Rager") {
+	if (Method == 1) {	// Rager
 		var boilfactor;
 		var sgfactor;
 		boilfactor = fmoment * 18.11 + 13.86 * Math.tanh((time * 31.32) / 18.27);

mercurial