105 } |
105 } |
106 console.log("calcIBUs(): " + total_ibus); |
106 console.log("calcIBUs(): " + total_ibus); |
107 $('#est_ibu').val(total_ibus); |
107 $('#est_ibu').val(total_ibus); |
108 }; |
108 }; |
109 |
109 |
|
110 function calcFermentablesFromOG(OG) { |
|
111 |
|
112 console.log("calcFermentablesFromOG("+OG+")"); |
|
113 var i; |
|
114 var efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')); |
|
115 var rows = $('#fermentableGrid').jqxGrid('getrows'); |
|
116 var sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
|
117 var tot = 0; |
|
118 var d; |
|
119 for (i = 0; i < rows.length; i++) { |
|
120 row = rows[i]; |
|
121 d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
|
122 if (row.f_added == "Mash") |
|
123 d = efficiency / 100 * d; |
|
124 tot += d; |
|
125 } |
|
126 |
|
127 var totmass = 0; |
|
128 if (tot) |
|
129 totmass = sug / tot; |
|
130 |
|
131 if (totmass) { |
|
132 for (i = 0; i < rows.length; i++) { |
|
133 row = rows[i]; |
|
134 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", row.f_percentage / 100 * totmass); |
|
135 } |
|
136 } |
|
137 //CalcWaterBalance; |
|
138 }; |
|
139 |
|
140 function calcABV() { |
|
141 $("#est_abv").val(abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal')))); |
|
142 }; |
|
143 |
110 function calcInit () { |
144 function calcInit () { |
111 console.log("calc.init()"); |
145 console.log("calc.init()"); |
112 // $('#est_og').on('change', function (event) { calcFermentables(); }); |
|
113 $('#color_method').on('change', function (event) { calcFermentables(); }); |
146 $('#color_method').on('change', function (event) { calcFermentables(); }); |
114 $('#ibu_method').on('change', function (event) { |
147 $('#ibu_method').on('change', function (event) { |
115 calcFermentables(); |
148 calcFermentables(); |
116 calcIBUs(); |
149 calcIBUs(); |
117 }); |
150 }); |
475 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
508 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
476 } |
509 } |
477 }); |
510 }); |
478 |
511 |
479 // delete selected fermentable. |
512 // delete selected fermentable. |
480 // Precentage aanpassen basis mout. |
|
481 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
513 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
482 $("#fdeleterowbutton").on('click', function () { |
514 $("#fdeleterowbutton").on('click', function () { |
483 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
515 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
484 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
516 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
485 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
517 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1400 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' }); |
1434 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' }); |
1401 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true, symbol: 'L', symbolPosition: 'right' }); |
1435 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true, symbol: 'L', symbolPosition: 'right' }); |
1402 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
1436 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
1403 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
1437 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
1404 |
1438 |
1405 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 1.9, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
1439 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); |
|
1440 $('#est_og').on('change', function (event) { |
|
1441 console.log("est_og change:"+event.args.value+" by:"+event.args.type); |
|
1442 calcFermentablesFromOG(event.args.value); // Adjust fermentables amounts |
|
1443 calcFermentables(); // Update the recipe details |
|
1444 calcABV(); // and ABV |
|
1445 calcIBUs(); // and the IBU's. |
|
1446 }); |
1406 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1447 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1407 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1448 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1408 |
1449 |
1409 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); |
1450 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); |
1410 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1451 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |