www/js/prod_edit.js

changeset 164
0a5abea575a9
parent 163
4a4cc3497a57
child 167
dabcd35f8f92
equal deleted inserted replaced
163:4a4cc3497a57 164:0a5abea575a9
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2018 2 * Copyright (C) 2018-2019
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of BMS 6 * This file is part of BMS
7 * 7 *
983 Acid = Math.round(Acid * 100) / 100; 983 Acid = Math.round(Acid * 100) / 100;
984 dataRecord.sparge_acid_amount = Acid / 1000; 984 dataRecord.sparge_acid_amount = Acid / 1000;
985 $("#sparge_acid_amount").val(Acid); 985 $("#sparge_acid_amount").val(Acid);
986 } 986 }
987 987
988 function calcFermentation() {
989 if (dataRecord.brew_fermenter_sg < 1.020)
990 return;
991 if ((dataRecord.primary_end_sg > 0.990) && (dataRecord.primary_end_sg < dataRecord.brew_fermenter_sg)) {
992 var primary_svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.primary_end_sg) / (dataRecord.brew_fermenter_sg - 1);
993 console.log("primary svg: "+primary_svg);
994 $("#primary_svg").val(primary_svg);
995 if ((dataRecord.fg > 0.990) && (dataRecord.fg < dataRecord.brew_fermenter_sg)) {
996 var final_svg = 100 * (dataRecord.brew_fermenter_sg - dataRecord.fg) / (dataRecord.brew_fermenter_sg - 1);
997 $("#final_svg").val(final_svg);
998 var ABV = abvol(dataRecord.brew_fermenter_sg, dataRecord.fg);
999 $("#final_abv").val(ABV);
1000 }
1001 }
1002 }
1003
988 function CarbCO2toS(CO2, T, SFactor) { 1004 function CarbCO2toS(CO2, T, SFactor) {
989 // Calcuation of disolved CO2 in the beer. 1005 // Calcuation of disolved CO2 in the beer.
990 // Brewersfriend uses: 3.0378 - (0.050062 * temp) + (0.00026555 * temp^2) 1006 // Brewersfriend uses: 3.0378 - (0.050062 * temp) + (0.00026555 * temp^2)
991 // Brouwhulp uses: 0.000849151 * T * T - 0.0587512 * T + 1.71137) 1007 // Brouwhulp uses: 0.000849151 * T * T - 0.0587512 * T + 1.71137)
992 var sugar = SFactor * (CO2 - (0.000849151 * T * T - 0.0587512 * T + 1.71137)) / 0.286; 1008 var sugar = SFactor * (CO2 - (0.000849151 * T * T - 0.0587512 * T + 1.71137)) / 0.286;
1208 $('#sparge_acid_perc').on('change', function (event) { 1224 $('#sparge_acid_perc').on('change', function (event) {
1209 dataRecord.sparge_acid_perc = parseFloat(event.args.value); 1225 dataRecord.sparge_acid_perc = parseFloat(event.args.value);
1210 calcSparge(); 1226 calcSparge();
1211 }); 1227 });
1212 1228
1229 calcFermentation();
1213 calcCarbonation(); 1230 calcCarbonation();
1214 $('#bottle_amount').on('change', function (event) { 1231 $('#bottle_amount').on('change', function (event) {
1215 dataRecord.bottle_amount = parseFloat(event.args.value); 1232 dataRecord.bottle_amount = parseFloat(event.args.value);
1216 calcCarbonation(); 1233 calcCarbonation();
1217 }); 1234 });
1615 $("#brew_whirlpool6").val(dataRecord.brew_whirlpool6); 1632 $("#brew_whirlpool6").val(dataRecord.brew_whirlpool6);
1616 $("#brew_whirlpool2").val(dataRecord.brew_whirlpool2); 1633 $("#brew_whirlpool2").val(dataRecord.brew_whirlpool2);
1617 // Header Naar gistvat 1634 // Header Naar gistvat
1618 $("#brew_fermenter_volume").val(dataRecord.brew_fermenter_volume); 1635 $("#brew_fermenter_volume").val(dataRecord.brew_fermenter_volume);
1619 $("#brew_fermenter_sg").val(dataRecord.brew_fermenter_sg); 1636 $("#brew_fermenter_sg").val(dataRecord.brew_fermenter_sg);
1637 $("#brew_fermenter_sg2").val(dataRecord.brew_fermenter_sg);
1620 $("#brew_fermenter_ibu").val(dataRecord.brew_fermenter_ibu); 1638 $("#brew_fermenter_ibu").val(dataRecord.brew_fermenter_ibu);
1621 1639
1622 $("#brew_aboil_ph").val(dataRecord.brew_aboil_ph); 1640 $("#brew_aboil_ph").val(dataRecord.brew_aboil_ph);
1623 $("#brew_aboil_sg").val(dataRecord.brew_aboil_sg); 1641 $("#brew_aboil_sg").val(dataRecord.brew_aboil_sg);
1624 $("#brew_aboil_volume").val(dataRecord.brew_aboil_volume); 1642 $("#brew_aboil_volume").val(dataRecord.brew_aboil_volume);
1633 $("#brew_fermenter_extrasugar").val(dataRecord.brew_fermenter_extrasugar); 1651 $("#brew_fermenter_extrasugar").val(dataRecord.brew_fermenter_extrasugar);
1634 $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color); 1652 $("#brew_fermenter_color").val(dataRecord.brew_fermenter_color);
1635 $("#brew_date_end").val(dataRecord.brew_date_end); 1653 $("#brew_date_end").val(dataRecord.brew_date_end);
1636 $("#og").val(dataRecord.og); 1654 $("#og").val(dataRecord.og);
1637 $("#fg").val(dataRecord.fg); 1655 $("#fg").val(dataRecord.fg);
1656 $("#primary_start_temp").val(dataRecord.primary_start_temp);
1657 $("#primary_max_temp").val(dataRecord.primary_max_temp);
1658 $("#primary_end_temp").val(dataRecord.primary_end_temp);
1659 $("#primary_end_sg").val(dataRecord.primary_end_sg);
1660 $("#primary_end_date").val(dataRecord.primary_end_date);
1661 $("#secondary_temp").val(dataRecord.secondary_temp);
1662 $("#secondary_end_date").val(dataRecord.secondary_end_date);
1663 $("#tertiary_temp").val(dataRecord.tertiary_temp);
1638 $("#package_date").val(dataRecord.package_date); 1664 $("#package_date").val(dataRecord.package_date);
1639 $("#bottle_amount").val(dataRecord.bottle_amount); 1665 $("#bottle_amount").val(dataRecord.bottle_amount);
1640 $("#bottle_carbonation").val(dataRecord.bottle_carbonation); 1666 $("#bottle_carbonation").val(dataRecord.bottle_carbonation);
1641 $("#bottle_priming_sugar").val(dataRecord.bottle_priming_sugar); 1667 $("#bottle_priming_sugar").val(dataRecord.bottle_priming_sugar);
1642 $("#bottle_priming_amount").val(dataRecord.bottle_priming_amount); 1668 $("#bottle_priming_amount").val(dataRecord.bottle_priming_amount);
1687 $("#efficiency").val(dataRecord.efficiency); 1713 $("#efficiency").val(dataRecord.efficiency);
1688 $("#est_og").val(dataRecord.est_og); 1714 $("#est_og").val(dataRecord.est_og);
1689 $("#est_og2").val(dataRecord.est_og); 1715 $("#est_og2").val(dataRecord.est_og);
1690 $("#est_og3").val(dataRecord.est_og); 1716 $("#est_og3").val(dataRecord.est_og);
1691 $("#est_fg").val(dataRecord.est_fg); 1717 $("#est_fg").val(dataRecord.est_fg);
1718 $("#est_fg2").val(dataRecord.est_fg);
1692 $("#est_color").val(dataRecord.est_color); 1719 $("#est_color").val(dataRecord.est_color);
1693 $("#est_color2").val(dataRecord.est_color); 1720 $("#est_color2").val(dataRecord.est_color);
1694 $("#est_abv").val(dataRecord.est_abv); 1721 $("#est_abv").val(dataRecord.est_abv);
1695 $("#color_method").val(dataRecord.color_method); 1722 $("#color_method").val(dataRecord.color_method);
1696 $("#est_ibu").val(dataRecord.est_ibu); 1723 $("#est_ibu").val(dataRecord.est_ibu);
2805 }, 2832 },
2806 ready: function() { 2833 ready: function() {
2807 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal')))); 2834 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal'))));
2808 dataRecord.est_fg = fg; 2835 dataRecord.est_fg = fg;
2809 $('#est_fg').val(fg); 2836 $('#est_fg').val(fg);
2837 $('#est_fg2').val(fg);
2810 calcInit(); 2838 calcInit();
2811 $('#jqxLoader').jqxLoader('close'); 2839 $('#jqxLoader').jqxLoader('close');
2812 $('#jqxTabs').jqxTabs('first'); 2840 $('#jqxTabs').jqxTabs('first');
2813 }, 2841 },
2814 columns: [ 2842 columns: [
2941 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2969 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2942 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); 2970 $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
2943 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2971 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2944 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); 2972 $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
2945 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); 2973 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
2974 $("#est_fg2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 3, readOnly: true });
2946 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); 2975 $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
2947 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2976 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2948 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); 2977 $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
2949 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 2978 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
2950 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); 2979 $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
3241 $("#brew_fermenter_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); 3270 $("#brew_fermenter_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 });
3242 $("#brew_fermenter_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); 3271 $("#brew_fermenter_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 });
3243 3272
3244 // Tab 10, Fermentation 3273 // Tab 10, Fermentation
3245 // Note, fermentation temps changes must do calcCarbonation() 3274 // Note, fermentation temps changes must do calcCarbonation()
3275 $("#brew_fermenter_sg2").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 });
3276 $("#primary_start_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3277 $("#primary_max_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3278 $("#primary_end_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3279 $("#primary_end_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.990, max: 1.2, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 });
3280 $("#primary_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3281 $("#primary_end_date").jqxTooltip({ content: 'De eind datum van de hoofdvergisting en eventueel overhevelen.' });
3282 $("#primary_end_date").jqxDateTimeInput({
3283 theme: theme,
3284 width: 150,
3285 height: 23,
3286 allowNullDate: true,
3287 todayString: 'Vandaag',
3288 clearString: 'Wissen',
3289 showFooter: true,
3290 formatString: 'yyyy-MM-dd'
3291 });
3292 $("#secondary_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3293 $("#secondary_end_date").jqxTooltip({ content: 'De eind datum van de navergisting en het begin van het lageren.' });
3294 $("#secondary_end_date").jqxDateTimeInput({
3295 theme: theme,
3296 width: 150,
3297 height: 23,
3298 allowNullDate: true,
3299 todayString: 'Vandaag',
3300 clearString: 'Wissen',
3301 showFooter: true,
3302 formatString: 'yyyy-MM-dd'
3303 });
3304 $("#tertiary_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3246 $("#fg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 3305 $("#fg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 });
3306 $("#final_abv").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3307 $("#final_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3247 3308
3248 // Tab 11, Packaging 3309 // Tab 11, Packaging
3249 $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' }); 3310 $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' });
3250 $("#package_date").jqxDateTimeInput({ 3311 $("#package_date").jqxDateTimeInput({
3251 theme: theme, 3312 theme: theme,
3398 eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')), 3459 eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')),
3399 eq_kettle_height: dataRecord.eq_kettle_height, 3460 eq_kettle_height: dataRecord.eq_kettle_height,
3400 eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')), 3461 eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')),
3401 eq_mash_max: parseFloat($("#eq_mash_max").jqxNumberInput('decimal')), 3462 eq_mash_max: parseFloat($("#eq_mash_max").jqxNumberInput('decimal')),
3402 eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')), 3463 eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')),
3403 3464 brew_date_start: $("#brew_date_start").val(),
3465 brew_mash_ph: parseFloat($("#brew_mash_ph").jqxNumberInput('decimal')),
3466 brew_mash_sg: parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')),
3467 brew_sparge_temperature: parseFloat($("#brew_sparge_temperature").jqxNumberInput('decimal')),
3468 brew_sparge_volume: parseFloat($("#brew_sparge_volume").jqxNumberInput('decimal')),
3469 brew_sparge_ph: parseFloat($("#brew_sparge_ph").jqxNumberInput('decimal')),
3470 brew_preboil_volume: parseFloat($("#brew_preboil_volume").jqxNumberInput('decimal')),
3471 brew_preboil_sg: parseFloat($("#brew_preboil_sg").jqxNumberInput('decimal')),
3472 brew_preboil_ph: parseFloat($("#brew_preboil_ph").jqxNumberInput('decimal')),
3473 brew_aboil_volume: parseFloat($("#brew_aboil_volume").jqxNumberInput('decimal')),
3474 brew_aboil_sg: parseFloat($("#brew_aboil_sg").jqxNumberInput('decimal')),
3475 brew_aboil_ph: parseFloat($("#brew_aboil_ph").jqxNumberInput('decimal')),
3476 brew_aboil_efficiency: parseFloat($("#brew_aboil_efficiency").jqxNumberInput('decimal')),
3477 brew_cooling_method: $("#brew_cooling_method").val(),
3478 brew_cooling_time: parseFloat($("#brew_cooling_time").jqxNumberInput('decimal')),
3479 brew_cooling_to: parseFloat($("#brew_cooling_to").jqxNumberInput('decimal')),
3480 brew_whirlpool9: parseFloat($("#brew_whirlpool9").jqxNumberInput('decimal')),
3481 brew_whirlpool7: parseFloat($("#brew_whirlpool7").jqxNumberInput('decimal')),
3482 brew_whirlpool6: parseFloat($("#brew_whirlpool6").jqxNumberInput('decimal')),
3483 brew_whirlpool2: parseFloat($("#brew_whirlpool2").jqxNumberInput('decimal')),
3484 brew_fermenter_volume: parseFloat($("#brew_fermenter_volume").jqxNumberInput('decimal')),
3485 brew_fermenter_extrawater: parseFloat($("#brew_fermenter_extrawater").jqxNumberInput('decimal')),
3486 brew_aeration_time: parseFloat($("#brew_aeration_time").jqxNumberInput('decimal')),
3487 brew_aeration_speed: parseFloat($("#brew_aeration_speed").jqxNumberInput('decimal')),
3488 brew_aeration_type: $("#brew_aeration_type").val(),
3489 brew_fermenter_sg: parseFloat($("#brew_fermenter_sg").jqxNumberInput('decimal')),
3490 brew_fermenter_ibu: parseFloat($("#brew_fermenter_ibu").jqxNumberInput('decimal')),
3491 brew_date_end: $("#brew_date_end").val(),
3492 brew_log_available: $("#brew_log_available").val(),
3404 og: dataRecord.og, 3493 og: dataRecord.og,
3405 fg: parseFloat($("#fg").jqxNumberInput('decimal')), 3494 fg: parseFloat($("#fg").jqxNumberInput('decimal')),
3495 primary_start_temp: parseFloat($("#primary_start_temp").jqxNumberInput('decimal')),
3496 primary_max_temp: parseFloat($("#primary_max_temp").jqxNumberInput('decimal')),
3497 primary_end_temp: parseFloat($("#primary_end_temp").jqxNumberInput('decimal')),
3498 primary_end_sg: parseFloat($("#primary_end_sg").jqxNumberInput('decimal')),
3499 primary_end_date: $("#primary_end_date").val(),
3500 secondary_temp: parseFloat($("#secondary_temp").jqxNumberInput('decimal')),
3501 secondary_end_date: $("#secondary_end_date").val(),
3502 tertiary_temp: parseFloat($("#tertiary_temp").jqxNumberInput('decimal')),
3406 package_date: $("#package_date").val(), 3503 package_date: $("#package_date").val(),
3407 bottle_amount: parseFloat($("#bottle_amount").jqxNumberInput('decimal')), 3504 bottle_amount: parseFloat($("#bottle_amount").jqxNumberInput('decimal')),
3408 bottle_carbonation: parseFloat($("#bottle_carbonation").jqxNumberInput('decimal')), 3505 bottle_carbonation: parseFloat($("#bottle_carbonation").jqxNumberInput('decimal')),
3409 bottle_priming_sugar: $("#bottle_priming_sugar").val(), 3506 bottle_priming_sugar: $("#bottle_priming_sugar").val(),
3410 bottle_priming_amount: parseFloat($("#bottle_priming_amount").jqxNumberInput('decimal')), 3507 bottle_priming_amount: parseFloat($("#bottle_priming_amount").jqxNumberInput('decimal')),

mercurial