85 if (row.f_added == "Mash") { |
83 if (row.f_added == "Mash") { |
86 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d; |
84 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d; |
87 sugarsm += d; |
85 sugarsm += d; |
88 } |
86 } |
89 sugarsf += d; |
87 sugarsf += d; |
90 colorw += row.f_amount * ebc_to_srm(row.f_color) / g_batch_size * 8.34436; |
88 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat($("#batch_size").jqxNumberInput('decimal')) * 8.34436; |
91 } |
89 } |
92 if (to_100 != my_100) |
90 if (to_100 != my_100) |
93 console.log("change to_100 to:"+my_100); |
91 console.log("change to_100 to:"+my_100); |
94 to_100 = my_100; |
92 to_100 = my_100; |
95 $('#est_og').val(estimate_sg(sugarsf, g_batch_size)); |
93 $('#est_og').val(estimate_sg(sugarsf, parseFloat($("#batch_size").jqxNumberInput('decimal')))); |
96 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
94 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
97 $('#est_color').val(kw_to_ebc($("#color_method").val(), colorw)); |
95 $('#est_color').val(kw_to_ebc($("#color_method").val(), colorw)); |
98 }; |
96 }; |
99 |
97 |
100 function calcIBUs() { |
98 function calcIBUs() { |
143 $("#est_abv").val(abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal')))); |
141 $("#est_abv").val(abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal')))); |
144 }; |
142 }; |
145 |
143 |
146 function calcInit () { |
144 function calcInit () { |
147 console.log("calc.init()"); |
145 console.log("calc.init()"); |
|
146 |
148 $('#color_method').on('change', function (event) { calcFermentables(); }); |
147 $('#color_method').on('change', function (event) { calcFermentables(); }); |
149 $('#ibu_method').on('change', function (event) { |
148 $('#ibu_method').on('change', function (event) { |
150 calcFermentables(); |
149 calcFermentables(); |
151 calcIBUs(); |
150 calcIBUs(); |
152 }); |
151 }); |
153 $('#batch_size').on('change', function (event) { |
152 $('#batch_size').on('change', function (event) { |
154 console.log("batch_size change:"+event.args.value+" old:"+g_batch_size); |
153 console.log("batch_size change:"+event.args.value+" old:"+dataRecord.batch_size); |
155 var new_boil = Math.round((parseFloat(event.args.value) + parseFloat($("#boil_size").jqxNumberInput('decimal')) - g_batch_size) * 10) / 10; |
154 var new_boil = parseFloat(event.args.value) + dataRecord.boil_size - dataRecord.batch_size; |
156 $("#boil_size").val(new_boil); |
155 dataRecord.boil_size = new_boil; |
|
156 $("#boil_size").val(Math.round(new_boil * 100) / 100); |
|
157 dataRecord.batch_size = parseFloat(event.args.value); |
157 calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG |
158 calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG |
158 calcFermentables(); |
159 calcFermentables(); |
159 calcABV(); |
160 calcABV(); |
160 // TODO: adjust the hops, miscs, yeast, water. |
161 // TODO: adjust the hops, miscs, yeast, water. |
161 calcIBUs(); |
162 calcIBUs(); |
162 }); |
163 }); |
163 $('#boil_time').on('change', function (event) { |
164 $('#boil_time').on('change', function (event) { |
164 console.log("boil_time change:"+event.args.value); |
165 console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); |
|
166 var old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); |
|
167 var new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); |
|
168 var new_boil = parseFloat(dataRecord.batch_size) + new_evap; |
|
169 // console.log("old_evap:"+old_evap+" new_evap:"+new_evap+" new_boil:"+new_boil); |
|
170 dataRecord.boil_time = parseFloat(event.args.value); |
|
171 dataRecord.boil_size = new_boil; |
|
172 $("#boil_size").val(Math.round(new_boil * 100) / 100); |
|
173 calcFermentables(); |
|
174 calcABV(); |
|
175 // TODO: adjust the hops, miscs, yeast, water. |
|
176 calcIBUs(); |
165 }); |
177 }); |
166 $('#efficiency').on('change', function (event) { |
178 $('#efficiency').on('change', function (event) { |
167 console.log("efficiency change:"+event.args.value); |
179 console.log("efficiency change:"+event.args.value); |
168 calcFermentables(); |
180 calcFermentables(); |
169 calcABV(); |
181 calcABV(); |
1455 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); |
1467 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); |
1456 $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
1468 $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
1457 $("#st_type").jqxInput({ theme: theme, width: 90, height: 23 }); |
1469 $("#st_type").jqxInput({ theme: theme, width: 90, height: 23 }); |
1458 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); |
1470 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); |
1459 $("#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' }); |
1471 $("#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' }); |
1460 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true, symbol: 'L', symbolPosition: 'right' }); |
1472 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' }); |
1461 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
1473 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
1462 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
1474 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
1463 $("#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 }); |
1475 $("#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 }); |
1464 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1476 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1465 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
1477 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |