301 } |
301 } |
302 |
302 |
303 $("#yeast_cells").val(initcells); |
303 $("#yeast_cells").val(initcells); |
304 $("#need_cells").val(getNeededYeastCells()); |
304 $("#need_cells").val(getNeededYeastCells()); |
305 }; |
305 }; |
|
306 |
|
307 function calcMash() { |
|
308 |
|
309 if (!(rows = $('#mashGrid').jqxGrid('getrows'))) |
|
310 return; |
|
311 if (mashkg == 0) |
|
312 return; |
|
313 |
|
314 var infused = 0; |
|
315 for (var i = 0; i < rows.length; i++) { |
|
316 var row = $("#mashGrid").jqxGrid('getrowdata', i); |
|
317 if (row.step_type == 0) // Infusion |
|
318 infused += row.step_infuse_amount; |
|
319 $("#mashGrid").jqxGrid('setcellvalue', i, "step_thickness", infused / mashkg); |
|
320 } |
|
321 } |
306 |
322 |
307 /* |
323 /* |
308 * Change OG of recipe but keep the water volumes. |
324 * Change OG of recipe but keep the water volumes. |
309 */ |
325 */ |
310 function calcFermentablesFromOG(OG) { |
326 function calcFermentablesFromOG(OG) { |
2153 adjustMiscs(factor); |
2169 adjustMiscs(factor); |
2154 adjustYeasts(factor); |
2170 adjustYeasts(factor); |
2155 calcIBUs(); |
2171 calcIBUs(); |
2156 calcWater(); |
2172 calcWater(); |
2157 calcSparge(); |
2173 calcSparge(); |
|
2174 calcMash(); |
2158 }); |
2175 }); |
2159 $('#boil_time').on('change', function (event) { |
2176 $('#boil_time').on('change', function (event) { |
2160 console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); |
2177 console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); |
2161 var old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); |
2178 var old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); |
2162 var new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); |
2179 var new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); |
2184 console.log("est_og change:"+dataRecord.est_og); |
2201 console.log("est_og change:"+dataRecord.est_og); |
2185 $('#est_og2').val(dataRecord.est_og); |
2202 $('#est_og2').val(dataRecord.est_og); |
2186 calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts |
2203 calcFermentablesFromOG(dataRecord.est_og); // Adjust fermentables amounts |
2187 calcFermentables(); // Update the recipe details |
2204 calcFermentables(); // Update the recipe details |
2188 calcIBUs(); // and the IBU's. |
2205 calcIBUs(); // and the IBU's. |
|
2206 calcMash(); |
2189 calcYeast(); |
2207 calcYeast(); |
2190 }); |
2208 }); |
2191 $('#mash_ph').on('change', function (event) { |
2209 $('#mash_ph').on('change', function (event) { |
2192 dataRecord.mash_ph = parseFloat(event.args.value); |
2210 dataRecord.mash_ph = parseFloat(event.args.value); |
2193 calcWater(); |
2211 calcWater(); |
3888 { name: 'step_name', type: 'string' }, |
3906 { name: 'step_name', type: 'string' }, |
3889 { name: 'step_type', type: 'int' }, |
3907 { name: 'step_type', type: 'int' }, |
3890 { name: 'step_infuse_amount', type: 'float' }, |
3908 { name: 'step_infuse_amount', type: 'float' }, |
3891 { name: 'step_temp', type: 'float' }, |
3909 { name: 'step_temp', type: 'float' }, |
3892 { name: 'step_time', type: 'float' }, |
3910 { name: 'step_time', type: 'float' }, |
|
3911 { name: 'step_thickness', type: 'float' }, |
3893 { name: 'ramp_time', type: 'float' }, |
3912 { name: 'ramp_time', type: 'float' }, |
3894 { name: 'end_temp', type: 'float' } |
3913 { name: 'end_temp', type: 'float' } |
3895 ], |
3914 ], |
3896 addrow: function (rowid, rowdata, position, commit) { |
3915 addrow: function (rowid, rowdata, position, commit) { |
3897 commit(true); |
3916 commit(true); |
3906 var data = new Array(); |
3925 var data = new Array(); |
3907 for (var i = 0; i < records.length; i++) { |
3926 for (var i = 0; i < records.length; i++) { |
3908 var row = records[i]; |
3927 var row = records[i]; |
3909 if (row.step_type == 0) // Infusion |
3928 if (row.step_type == 0) // Infusion |
3910 mash_infuse += parseFloat(row.step_infuse_amount); |
3929 mash_infuse += parseFloat(row.step_infuse_amount); |
|
3930 row.step_thickness = 0; // Init this field. |
|
3931 data.push(row); |
3911 } |
3932 } |
3912 }, |
3933 }, |
3913 }); |
3934 }); |
3914 $("#mashGrid").jqxGrid({ |
3935 $("#mashGrid").jqxGrid({ |
3915 width: 1240, |
3936 width: 1240, |
3935 row["step_type"] = 0; |
3956 row["step_type"] = 0; |
3936 row["step_infuse_amount"] = 15; |
3957 row["step_infuse_amount"] = 15; |
3937 } |
3958 } |
3938 row["step_temp"] = 62.0; |
3959 row["step_temp"] = 62.0; |
3939 row['step_time'] = 20.0; |
3960 row['step_time'] = 20.0; |
|
3961 row['step_thickness'] = 0; |
3940 row['ramp_time'] = 1.0; |
3962 row['ramp_time'] = 1.0; |
3941 row['end_temp'] = 62.0; |
3963 row['end_temp'] = 62.0; |
3942 var commit = $("#mashGrid").jqxGrid('addrow', null, row); |
3964 var commit = $("#mashGrid").jqxGrid('addrow', null, row); |
3943 }); |
3965 }); |
3944 // delete selected step. |
3966 // delete selected step. |
3967 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
3990 { text: 'Start °C', datafield: 'step_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
3968 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
3991 { text: 'Eind °C', datafield: 'end_temp', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
3969 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
3992 { text: 'Rust min.', datafield: 'step_time', width: 90, align: 'right', cellsalign: 'right' }, |
3970 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
3993 { text: 'Stap min.', datafield: 'ramp_time', width: 90, align: 'right', cellsalign: 'right' }, |
3971 { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
3994 { text: 'Infuse L.', datafield: 'step_infuse_amount', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
|
3995 { text: 'L/Kg.', datafield: 'step_thickness', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'f2' }, |
3972 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
3996 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
3973 return "Wijzig"; |
3997 return "Wijzig"; |
3974 }, buttonclick: function (row) { |
3998 }, buttonclick: function (row) { |
3975 if (dataRecord.stage <= 3) { |
3999 if (dataRecord.stage <= 3) { |
3976 mashRow = row; |
4000 mashRow = row; |
4233 $("#FermentableReady").click(function () { |
4257 $("#FermentableReady").click(function () { |
4234 $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc'); |
4258 $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc'); |
4235 // Recalc percentages |
4259 // Recalc percentages |
4236 calcFermentables(); |
4260 calcFermentables(); |
4237 calcIBUs(); |
4261 calcIBUs(); |
|
4262 calcMash(); |
4238 // Waters: yes there is impact. |
4263 // Waters: yes there is impact. |
4239 }); |
4264 }); |
4240 $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
4265 $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
4241 $("#wf_instock").jqxCheckBox({ theme: theme, height: 23 }); |
4266 $("#wf_instock").jqxCheckBox({ theme: theme, height: 23 }); |
4242 $("#wf_instock").on('change', function (event) { |
4267 $("#wf_instock").on('change', function (event) { |
4308 } else { |
4333 } else { |
4309 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
4334 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
4310 } |
4335 } |
4311 calcFermentables(); |
4336 calcFermentables(); |
4312 calcIBUs(); |
4337 calcIBUs(); |
|
4338 calcMash(); |
4313 }; |
4339 }; |
4314 }); |
4340 }); |
4315 $("#wf_percentage").jqxNumberInput( Perc1dec ); |
4341 $("#wf_percentage").jqxNumberInput( Perc1dec ); |
4316 $("#wf_percentage").on('change', function (event) { |
4342 $("#wf_percentage").on('change', function (event) { |
4317 var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0; |
4343 var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0; |
4345 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); |
4371 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); |
4346 } |
4372 } |
4347 } |
4373 } |
4348 calcFermentables(); |
4374 calcFermentables(); |
4349 calcIBUs(); |
4375 calcIBUs(); |
|
4376 calcMash(); |
4350 } else { |
4377 } else { |
4351 // Adjust all the rows. |
4378 // Adjust all the rows. |
4352 var nw = tw * diff / 100; |
4379 var nw = tw * diff / 100; |
4353 for (i = 0; i < rowscount; i++) { |
4380 for (i = 0; i < rowscount; i++) { |
4354 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
4381 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
4858 mash_infuse = dataRecord.w1_amount; |
4887 mash_infuse = dataRecord.w1_amount; |
4859 if (i == 0) |
4888 if (i == 0) |
4860 row["step_infuse_amount"] = mash_infuse; |
4889 row["step_infuse_amount"] = mash_infuse; |
4861 else |
4890 else |
4862 row["step_infuse_amount"] = 0; |
4891 row["step_infuse_amount"] = 0; |
|
4892 if (mashkg > 0) |
|
4893 row['step_thickness'] = parseFloat(mash_infuse / mashkg); |
|
4894 else |
|
4895 row['step_thickness'] = 0; |
4863 row["step_temp"] = data.step_temp; |
4896 row["step_temp"] = data.step_temp; |
4864 row["end_temp"] = data.end_temp; |
4897 row["end_temp"] = data.end_temp; |
4865 row["step_time"] = data.step_time; |
4898 row["step_time"] = data.step_time; |
4866 row["ramp_time"] = data.ramp_time; |
4899 row["ramp_time"] = data.ramp_time; |
4867 var commit = $("#mashGrid").jqxGrid('addrow', null, row); |
4900 var commit = $("#mashGrid").jqxGrid('addrow', null, row); |
4880 modalOpacity: 0.40 |
4913 modalOpacity: 0.40 |
4881 }); |
4914 }); |
4882 $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
4915 $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
4883 $("#MashReady").click(function () { |
4916 $("#MashReady").click(function () { |
4884 $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc'); |
4917 $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc'); |
|
4918 calcMash(); |
4885 }); |
4919 }); |
4886 $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
4920 $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
4887 $("#wstep_name").on('change', function (event) { |
4921 $("#wstep_name").on('change', function (event) { |
4888 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
4922 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); |
4889 rowdata.step_name = event.args.value; |
4923 rowdata.step_name = event.args.value; |