www/js/rec_edit.js

changeset 156
35860890224c
parent 155
041af8a82d77
child 158
3b9e4dfb0476
equal deleted inserted replaced
155:041af8a82d77 156:35860890224c
304 return ((v1 * c1) + (v2 * c2)) / (v1 + v2); 304 return ((v1 * c1) + (v2 * c2)) / (v1 + v2);
305 } 305 }
306 return 0; 306 return 0;
307 } 307 }
308 308
309 // mg/l as CaCO3
310 function ResidualAlkalinity(total_alkalinity, calcium, magnesium) {
311 return total_alkalinity - (calcium / 1.4 + magnesium / 1.7);
312 }
313
309 var Ka1 = 0.0000004445; 314 var Ka1 = 0.0000004445;
310 var Ka2 = 0.0000000000468; 315 var Ka2 = 0.0000000000468;
311 316
312 function PartCO3(pH) { 317 function PartCO3(pH) {
313 var H = Math.pow(10, -pH); 318 var H = Math.pow(10, -pH);
322 function Charge(pH) { 327 function Charge(pH) {
323 return (-2 * PartCO3(pH) - PartHCO3(pH)); 328 return (-2 * PartCO3(pH) - PartHCO3(pH));
324 } 329 }
325 330
326 //Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH) 331 //Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH)
327 function ZAlkalinity(pHZ, WpH) { 332 function ZAlkalinity(pHZ) {
328 var C43 = Charge(4.3); 333 var C43 = Charge(4.3);
329 var Cw = Charge(WpH); 334 //var Cw = Charge(parseFloat($("#wg_ph").jqxNumberInput('decimal')));
335 var Cw = Charge(7.0);
330 var Cz = Charge(pHZ); 336 var Cz = Charge(pHZ);
331 var DeltaCNaught = -C43+Cw; 337 var DeltaCNaught = -C43+Cw;
332 var CT = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')) / 50 / DeltaCNaught; 338 var CT = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')) / 50 / DeltaCNaught;
333 var DeltaCZ = -Cz+Cw; 339 var DeltaCZ = -Cz+Cw;
334 return CT * DeltaCZ; 340 return CT * DeltaCZ;
335 } 341 }
336 342
337 //Z Residual alkalinity is the amount of acid (in mEq/l) needed to bring the water in the mash to the target pH (Z pH) 343 //Z Residual alkalinity is the amount of acid (in mEq/l) needed to bring the water in the mash to the target pH (Z pH)
338 function ZRA(pHZ, WpH) { 344 function ZRA(pHZ) {
339 345
340 var Calc = parseFloat($("#wg_calcium").jqxNumberInput('decimal')) / (MMCa / 2); 346 var Calc = parseFloat($("#wg_calcium").jqxNumberInput('decimal')) / (MMCa / 2);
341 var Magn = parseFloat($("#wg_magnesium").jqxNumberInput('decimal')) / (MMMg / 2); 347 var Magn = parseFloat($("#wg_magnesium").jqxNumberInput('decimal')) / (MMMg / 2);
342 var Z = ZAlkalinity(pHZ, WpH); 348 var Z = ZAlkalinity(pHZ);
343 return Z - (Calc / 3.5 + Magn / 7); 349 return Z - (Calc / 3.5 + Magn / 7);
344 } 350 }
345 351
346 function ProtonDeficit(pHZ) { 352 function ProtonDeficit(pHZ) {
347 353
348 var Result = ZRA(pHZ, parseFloat($("#wg_ph").jqxNumberInput('decimal'))) * parseFloat($("#wg_amount").jqxNumberInput('decimal')); 354 var Result = ZRA(pHZ) * parseFloat($("#wg_amount").jqxNumberInput('decimal'));
355 // proton deficit for the grist
349 var rows = $('#fermentableGrid').jqxGrid('getrows'); 356 var rows = $('#fermentableGrid').jqxGrid('getrows');
350 for (var i = 0; i < rows.length; i++) { 357 for (var i = 0; i < rows.length; i++) {
351 var row = rows[i]; 358 var row = rows[i];
352 if (row.f_added == 'Mash' && row.f_graintype != 'No malt') { 359 if (row.f_added == 'Mash' && row.f_graintype != 'No malt') {
353 // Check if acid is required 360 // Check if acid is required
354 var C1 = 0; 361 var C1 = 0;
355 if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) { 362 if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) {
356 C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7); 363 C1 = row.f_acid_to_ph_57 / (row.f_di_ph - 5.7);
357 // console.log("formula C1: "+C1);
358 } else { 364 } else {
359 // If the acid_to_ph_5.7 is unknown from the malter, guess the required acid. 365 // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid.
360 var ebc = row.f_color; 366 var ebc = row.f_color;
361 switch (row.f_graintype) { 367 switch (row.f_graintype) {
362 case 'Base': 368 case 'Base':
363 case 'Special': 369 case 'Special':
364 case 'Kilned': C1 = 0.014 * ebc - 34.192; 370 case 'Kilned': C1 = 0.014 * ebc - 34.192;
368 case 'Roast': C1 = 0.0107 * ebc - 54.768; 374 case 'Roast': C1 = 0.0107 * ebc - 54.768;
369 break; 375 break;
370 case 'Sour': C1 = -149; 376 case 'Sour': C1 = -149;
371 break; 377 break;
372 } 378 }
373 // console.log("Logic C1: "+C1);
374 } 379 }
375 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) 380 x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH)
376 // console.log(row.f_name+" C1: "+C1+" ZpH: "+pHZ+" di_ph: "+row.f_di_ph+" acid rquired: "+x); 381 // console.log(row.f_name+" C1: "+C1+" ZpH: "+pHZ+" di_ph: "+row.f_di_ph+" acid rquired: "+x);
377 Result += x * row.f_amount; 382 Result += x * row.f_amount;
378 } 383 }
500 var wg_sulfate = sulfate; 505 var wg_sulfate = sulfate;
501 $('#wg_sulfate').val(Math.round(sulfate * 10) / 10); 506 $('#wg_sulfate').val(Math.round(sulfate * 10) / 10);
502 // Note: brouwhulp has the malts included here in the result. 507 // Note: brouwhulp has the malts included here in the result.
503 var wg_ph = ph; 508 var wg_ph = ph;
504 $('#wg_ph').val(Math.round(ph * 10) / 10); 509 $('#wg_ph').val(Math.round(ph * 10) / 10);
505 // $('#wb_ph').val(Math.round(ph * 10) / 10);
506 $('#wb_ph').val(Math.round(MashpH() * 10) / 10); 510 $('#wb_ph').val(Math.round(MashpH() * 10) / 10);
507 bicarbonate = total_alkalinity * 1.22; 511 bicarbonate = total_alkalinity * 1.22;
508 var wg_bicarbonate = bicarbonate; 512 var wg_bicarbonate = bicarbonate;
509 513
510 // Noot: de volgende berekeningen geven bijna gelijke resultaten in Brun'water. 514 // Noot: de volgende berekeningen geven bijna gelijke resultaten in Brun'water.
560 if (protonDeficit > 0) { // Add acid 564 if (protonDeficit > 0) { // Add acid
561 $("#wa_base").val(0); 565 $("#wa_base").val(0);
562 setWaterAgent(last_base, 0); 566 setWaterAgent(last_base, 0);
563 frac = CalcFrac(TpH, pK1, pK2, pK3); 567 frac = CalcFrac(TpH, pK1, pK2, pK3);
564 Acid = protonDeficit / frac; 568 Acid = protonDeficit / frac;
565 // console.log("Required moles: "+Acid);
566 Acid *= MolWt; // mg 569 Acid *= MolWt; // mg
567 Acidmg = Acid; 570 Acidmg = Acid;
568 // console.log("Required mg: "+Acidmg);
569 Acid = Acid / AcidSG; // ml 571 Acid = Acid / AcidSG; // ml
570 572
571 if (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) == 0) 573 if (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) == 0)
572 $("#wa_acid_perc").val(AcidPrc); 574 $("#wa_acid_perc").val(AcidPrc);
573 Acid = Acid * AcidPrc / (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) / 100); // ml 575 Acid = Acid * AcidPrc / (parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')) / 100); // ml
599 // HCO3 601 // HCO3
600 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; 602 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
601 RA = 1000 * RA / liters; 603 RA = 1000 * RA / liters;
602 bicarbonate = wg_bicarbonate + RA; 604 bicarbonate = wg_bicarbonate + RA;
603 total_alkalinity = bicarbonate * 50 / 61; 605 total_alkalinity = bicarbonate * 50 / 61;
606 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
604 } 607 }
605 break; 608 break;
606 case 'Na2CO3': base = -protonDeficit / (2 * f1d + f2d); //mmol totaal 609 case 'Na2CO3': base = -protonDeficit / (2 * f1d + f2d); //mmol totaal
607 base = base * MMNa2CO3/1000; //gram 610 base = base * MMNa2CO3/1000; //gram
608 $("#wa_base").val(Math.round(base * 100) / 100); 611 $("#wa_base").val(Math.round(base * 100) / 100);
615 // HCO3 618 // HCO3
616 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; 619 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
617 RA = 1000 * RA / liters; 620 RA = 1000 * RA / liters;
618 bicarbonate = wg_bicarbonate + RA; 621 bicarbonate = wg_bicarbonate + RA;
619 total_alkalinity = bicarbonate * 50 / 61; 622 total_alkalinity = bicarbonate * 50 / 61;
623 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
620 } 624 }
621 break; 625 break;
622 case 'CaCO3': base = -protonDeficit * (f1d - f3d); //mmol totaal 626 case 'CaCO3': base = -protonDeficit * (f1d - f3d); //mmol totaal
623 base = base * MMCaCO3/1000; //gram 627 base = base * MMCaCO3/1000; //gram
624 //but only 1/3 is effective, so add 3 times as much 628 //but only 1/3 is effective, so add 3 times as much
635 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + 639 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
636 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + 640 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
637 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; 641 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
638 RA = 1000 * RA / liters; 642 RA = 1000 * RA / liters;
639 calcium = wg_calcium + RA; 643 calcium = wg_calcium + RA;
644 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
640 } 645 }
641 break; 646 break;
642 case 'Ca(OH)2': base = -protonDeficit / 19.3; // g 647 case 'Ca(OH)2': base = -protonDeficit / 19.3; // g
643 $("#wa_base").val(Math.round(base * 100) / 100); 648 $("#wa_base").val(Math.round(base * 100) / 100);
644 setWaterAgent(BT, Math.round(base * 100) / 100); 649 setWaterAgent(BT, Math.round(base * 100) / 100);
651 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + 656 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
652 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + 657 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
653 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2; 658 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2;
654 RA = 1000 * RA / liters; 659 RA = 1000 * RA / liters;
655 calcium = wg_calcium + RA; 660 calcium = wg_calcium + RA;
661 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
656 } 662 }
657 break; 663 break;
658 } 664 }
659 } 665 }
660 ph = TpH; 666 ph = TpH;
661 $('#wb_ph').val(Math.round(ph * 10) / 10); 667 $('#wb_ph').val(Math.round(ph * 10) / 10);
662 } else { // Manual 668 } else { // Manual
663 console.log("calc_acid no"); 669 console.log("calc_acid no");
664 // First add base salts 670 // First add base salts
665 if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) { 671 if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) {
666 672 if (liters > 0) {
673 switch (BT) {
674 case 'NaHCO3': // Na
675 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
676 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
677 RA = 1000 * RA / liters;
678 sodium = wg_sodium + RA;
679 // HCO3
680 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
681 RA = 1000 * RA / liters;
682 bicarbonate = wg_bicarbonate + RA;
683 total_alkalinity = bicarbonate * 50 / 61;
684 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
685 break;
686 case 'Na2CO3': RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
687 parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
688 RA = 1000 * RA / liters;
689 sodium = wg_sodium + RA;
690 // HCO3
691 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
692 RA = 1000 * RA / liters;
693 bicarbonate = wg_bicarbonate + RA;
694 total_alkalinity = bicarbonate * 50 / 61;
695 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
696 break;
697 case 'CaCO3': // Bicarbonate
698 RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
699 RA = 1000 * RA / liters;
700 bicarbonate = wg_bicarbonate + RA;
701 total_alkalinity = bicarbonate * 50 / 61;
702 RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
703 // Ca
704 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
705 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
706 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
707 RA = 1000 * RA / liters;
708 calcium = wg_calcium + RA;
709 break;
710 }
711 }
667 } 712 }
668 713
669 TpH = parseFloat(dataRecord.mash_ph); 714 TpH = parseFloat(dataRecord.mash_ph);
670 // pHa = MashpH(); 715 // pHa = MashpH();
671 pHa = parseFloat($("#wb_ph").jqxNumberInput('decimal')); 716 pHa = parseFloat($("#wb_ph").jqxNumberInput('decimal'));
722 Acidmg / 1000 * MMCl / (MMCL + 1); 767 Acidmg / 1000 * MMCl / (MMCL + 1);
723 RA = 1000 * RA / liters; 768 RA = 1000 * RA / liters;
724 chloride = wg_chloride + RA; 769 chloride = wg_chloride + RA;
725 } 770 }
726 771
772 // 2:1 Sulfate to Chroride IPA's, Pale Ales.
773 // 1:1 Sulfate to Chloride Balanced
774 // 1:2 Sulfate to Chloride Malty
727 $('#tgt_bu').val(Math.round(GetBUGU() * 100) / 100); 775 $('#tgt_bu').val(Math.round(GetBUGU() * 100) / 100);
728 $('#tgt_cl_so4').val(Math.round(GetOptClSO4ratio() * 10) / 10); // Show real value too 776 $('#tgt_cl_so4').val(Math.round(GetOptClSO4ratio() * 10) / 10); // Show real value too
777 if (sulfate > 0)
778 RA = chloride / sulfate;
779 else
780 RA = 10;
781 var piCLSO4_low = 0.8 * GetOptClSO4ratio();
782 var piCLSO4_high = 1.2 * GetOptClSO4ratio();
783 console.log("low: "+piCLSO4_low+" val: "+RA+" high: "+piCLSO4_high);
729 784
730 $('#wb_calcium').val(Math.round(calcium * 10) / 10); 785 $('#wb_calcium').val(Math.round(calcium * 10) / 10);
731 $('#wb_magnesium').val(Math.round(magnesium * 10) / 10); 786 $('#wb_magnesium').val(Math.round(magnesium * 10) / 10);
732 $('#wb_sodium').val(Math.round(sodium * 10) / 10); 787 $('#wb_sodium').val(Math.round(sodium * 10) / 10);
733 $('#wb_sulfate').val(Math.round(sulfate * 10) / 10); 788 $('#wb_sulfate').val(Math.round(sulfate * 10) / 10);
766 } else if (ph > 5.6) { 821 } else if (ph > 5.6) {
767 setRangeIndicator("ph", "high"); 822 setRangeIndicator("ph", "high");
768 } else { 823 } else {
769 setRangeIndicator("ph", "normal"); 824 setRangeIndicator("ph", "normal");
770 } 825 }
826 calcSparge();
827 }
828
829 function calcSparge() {
830
831 // Code from BrewBuddy/Brouwhulp, who got it from http://www.brewery.org/brewery/library/Acidi0,00fWaterAJD0497.html
832 var TargetpH = dataRecord.sparge_ph;
833 var Source_pH = dataRecord.w1_ph;
834 var Source_alkalinity = dataRecord.w1_total_alkalinity;
835 if (dataRecord.sparge_source == 'Bron 2') {
836 if (dataRecord.w2_ph > 0.0) {
837 Source_pH = dataRecord.w2_ph;
838 Source_alkalinity = dataRecord.w2_total_alkalinity;
839 } else {
840 dataRecord.sparge_source = 'Bron 1';
841 $("#sparge_source").val('Bron 1');
842 }
843 } else if (dataRecord.sparge_source == 'Gemengd') {
844 if (dataRecord.w2_ph > 0.0) {
845 Source_pH = parseFloat($("#wg_ph").jqxNumberInput('decimal'));
846 Source_alkalinity = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal'));
847 } else {
848 dataRecord.sparge_source = 'Bron 1';
849 $("#sparge_source").val('Bron 1');
850 }
851 }
852
853 console.log("calcSparge() target pH: "+TargetpH+" Source: "+Source_pH+" alkalinity: "+Source_alkalinity);
854
855 // Step 1: Compute the mole fractions of carbonic (f1o), bicarbonate (f2o) and carbonate(f3o) at the water pH
856 r1 = Math.pow(10, Source_pH - 6.38);
857 r2 = Math.pow(10, Source_pH - 10.33);
858 d = 1 + r1 + r1*r2;
859 f1 = 1/d;
860 f2 = r1/d;
861 f3 = r1 * r2 / d;
862
863 //Step 2. Compute the mole fractions at pH = 4.3 (the pH which defines alkalinity)
864 r143 = Math.pow(10, 4.3 - 6.38);
865 r243 = Math.pow(10, 4.3 - 10.33);
866 d43 = 1 + r143 + r143*r243;
867 f143 = 1/d43;
868 f243 = r143 / d43;
869 f343 = r143 * r243 / d43;
870
871 //Step 3. Convert the sample alkalinity to milliequivalents/L
872 alkalinity = Source_alkalinity / 50;
873 //Step 4. Solve
874 alkalinity = alkalinity / ((f143-f1)+(f3-f343));
875
876 //Step 5. Compute mole fractions at desired pH
877 r1g = Math.pow(10, TargetpH - 6.38);
878 r2g = Math.pow(10, TargetpH - 10.33);
879 dg = 1 + r1g + r1g*r2g;
880 f1g = 1/dg;
881 f2g = r1g / dg;
882 f3g = r1g * r2g / dg;
883
884 //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L)
885 Acid = alkalinity * ((f1g-f1)+(f3-f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l
886
887 if ($("#sparge_acid_type").val() == "") {
888 $("#sparge_acid_type").val('Melkzuur');
889 dataRecord.sparge_acid_type = 'Melkzuur';
890 }
891 AT = dataRecord.sparge_acid_type;
892 var result = GetAcidSpecs(AT);
893 pK1 = result.pK1;
894 pK2 = result.pK2;
895 pK3 = result.pK3;
896 MolWt = result.MolWt;
897 AcidSG = result.AcidSG;
898 AcidPrc = result.AcidPrc;
899 fract = CalcFrac(TargetpH, pK1, pK2, pK3);
900
901 //Step 9. Now divide the mEq required by the "fraction". This is the required number of moles of acid.
902 Acid /= fract;
903
904 //Step 10. Multiply by molecular weight of the acid
905 Acid *= MolWt; //mg
906
907 Acid = Acid / AcidSG; //ml ; 88% lactic solution
908 f1 = dataRecord.sparge_acid_perc;
909 if (f1 <= 0.1)
910 f1 = AcidPrc;
911 Acid = Acid * AcidPrc / (f1 / 100);
912
913 Acid *= dataRecord.sparge_volume; //ml lactic acid total
914 Acid = Math.round(Acid * 100) / 100;
915 dataRecord.sparge_acid_amount = Acid / 1000;
916 $("#sparge_acid_amount").val(Acid);
917 console.log("acid needed: "+Acid);
771 } 918 }
772 919
773 function calcFermentablesFromOG(OG) { 920 function calcFermentablesFromOG(OG) {
774 921
775 console.log("calcFermentablesFromOG("+OG+")"); 922 console.log("calcFermentablesFromOG("+OG+")");
926 calcIBUs(); // and the IBU's. 1073 calcIBUs(); // and the IBU's.
927 }); 1074 });
928 $('#mash_ph').on('change', function (event) { 1075 $('#mash_ph').on('change', function (event) {
929 dataRecord.mash_ph = parseFloat(event.args.value); 1076 dataRecord.mash_ph = parseFloat(event.args.value);
930 calcWater(); 1077 calcWater();
1078 });
1079
1080 $('#sparge_ph').on('change', function (event) {
1081 dataRecord.sparge_ph = parseFloat(event.args.value);
1082 calcSparge();
1083 });
1084 $('#sparge_volume').on('change', function (event) {
1085 dataRecord.sparge_volume = parseFloat(event.args.value);
1086 calcSparge();
1087 });
1088 $('#sparge_source').on('change', function (event) {
1089 dataRecord.sparge_source= event.args.item.value;
1090 calcSparge();
1091 });
1092 $('#sparge_acid_type').on('change', function (event) {
1093 dataRecord.sparge_acid_type = event.args.item.value;
1094 console.log("new sparge_acid_type: "+dataRecord.sparge_acid_type);
1095 calcSparge();
1096 });
1097 $('#sparge_acid_perc').on('change', function (event) {
1098 dataRecord.sparge_acid_perc = parseFloat(event.args.value);
1099 calcSparge();
931 }); 1100 });
932 }; 1101 };
933 1102
934 $("#styleSelect").jqxDropDownList({ 1103 $("#styleSelect").jqxDropDownList({
935 placeHolder: "Kies bierstijl:", 1104 placeHolder: "Kies bierstijl:",
1062 { name: 'ibu_method', type: 'string' }, 1231 { name: 'ibu_method', type: 'string' },
1063 { name: 'est_carb', type: 'float' }, 1232 { name: 'est_carb', type: 'float' },
1064 { name: 'sparge_temp', type: 'float' }, 1233 { name: 'sparge_temp', type: 'float' },
1065 { name: 'sparge_ph', type: 'float' }, 1234 { name: 'sparge_ph', type: 'float' },
1066 { name: 'sparge_volume', type: 'float' }, 1235 { name: 'sparge_volume', type: 'float' },
1236 { name: 'sparge_source', type: 'string' },
1067 { name: 'sparge_acid_type', type: 'string' }, 1237 { name: 'sparge_acid_type', type: 'string' },
1068 { name: 'sparge_acid_perc', type: 'float' }, 1238 { name: 'sparge_acid_perc', type: 'float' },
1069 { name: 'sparge_acid_amount', type: 'float' }, 1239 { name: 'sparge_acid_amount', type: 'float' },
1070 { name: 'mash_ph', type: 'float' }, 1240 { name: 'mash_ph', type: 'float' },
1071 { name: 'mash_name', type: 'string' }, 1241 { name: 'mash_name', type: 'string' },
1143 $("#mash_name").val(dataRecord.mash_name); 1313 $("#mash_name").val(dataRecord.mash_name);
1144 $("#mash_ph").val(dataRecord.mash_ph); 1314 $("#mash_ph").val(dataRecord.mash_ph);
1145 $("#sparge_temp").val(dataRecord.sparge_temp); 1315 $("#sparge_temp").val(dataRecord.sparge_temp);
1146 $("#sparge_ph").val(dataRecord.sparge_ph); 1316 $("#sparge_ph").val(dataRecord.sparge_ph);
1147 $("#sparge_volume").val(dataRecord.sparge_volume); 1317 $("#sparge_volume").val(dataRecord.sparge_volume);
1318 $("#sparge_source").val(dataRecord.sparge_source);
1148 $("#sparge_acid_type").val(dataRecord.sparge_acid_type); 1319 $("#sparge_acid_type").val(dataRecord.sparge_acid_type);
1149 $("#sparge_acid_perc").val(dataRecord.sparge_acid_perc); 1320 $("#sparge_acid_perc").val(dataRecord.sparge_acid_perc);
1150 $("#sparge_acid_amount").val(dataRecord.sparge_acid_amount); 1321 $("#sparge_acid_amount").val(dataRecord.sparge_acid_amount * 1000);
1151 $("#calc_acid").val(dataRecord.calc_acid); 1322 $("#calc_acid").val(dataRecord.calc_acid);
1152 $("#w1_name").val(dataRecord.w1_name); 1323 $("#w1_name").val(dataRecord.w1_name);
1153 $("#w1_amount").val(dataRecord.w1_amount); 1324 $("#w1_amount").val(dataRecord.w1_amount);
1154 $("#w1_calcium").val(dataRecord.w1_calcium); 1325 $("#w1_calcium").val(dataRecord.w1_calcium);
1155 $("#w1_sulfate").val(dataRecord.w1_sulfate); 1326 $("#w1_sulfate").val(dataRecord.w1_sulfate);
2260 var srcColor = [ "Morey", "Mosher", "Daniels" ]; 2431 var srcColor = [ "Morey", "Mosher", "Daniels" ];
2261 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; 2432 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ];
2262 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. 2433 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time.
2263 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ]; 2434 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ];
2264 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ]; 2435 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ];
2436 var srcSource = [ "Bron 1", "Bron 2", "Gemengd" ];
2265 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 2437 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
2266 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); 2438 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
2267 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); 2439 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
2268 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); 2440 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
2269 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); 2441 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
2304 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2476 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2305 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 2477 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
2306 2478
2307 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); 2479 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
2308 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 2480 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2309 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
2310 // Several gauges 2481 // Several gauges
2311 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2482 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2312 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2483 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2313 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2484 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2314 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 2485 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
2455 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); 2626 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2456 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); 2627 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2457 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); 2628 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
2458 2629
2459 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 2630 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 });
2460 $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 125, height: 23, dropDownHeight: 128 }); 2631 $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 100, height: 23, dropDownHeight: 128 });
2461 $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' }); 2632 $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' });
2462 $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 125, height: 23, dropDownHeight: 128 }) 2633 $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 100, height: 23, dropDownHeight: 128 });
2463 $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' }); 2634 $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' });
2464 $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); 2635 $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' });
2465 2636
2637 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
2466 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 2638 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2467 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 2639 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
2468 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 5, readOnly: true }); 2640 $("#sparge_source").jqxDropDownList({ theme: theme, source: srcSource, width: 100, height: 23, dropDownHeight: 95 });
2641 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: ' ml', symbolPosition: 'right' });
2642 $("#sparge_acid_type").jqxDropDownList({ theme: theme, source: srcAcid, width: 100, height: 23, dropDownHeight: 128 });
2643 $("#sparge_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, spinButtons: true, decimalDigits: 0, symbol: '%', symbolPosition: 'right' });
2469 2644
2470 // Tabs inside the popup window. 2645 // Tabs inside the popup window.
2471 $('#jqxTabs').jqxTabs({ 2646 $('#jqxTabs').jqxTabs({
2472 theme: theme, 2647 theme: theme,
2473 width: 1280, 2648 width: 1280,
2555 mash_name: $("#mash_name").val(), 2730 mash_name: $("#mash_name").val(),
2556 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), 2731 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
2557 sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')), 2732 sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
2558 sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')), 2733 sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
2559 sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')), 2734 sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
2560 // sparge_acid_type: $("#sparge_acid_type").val(), 2735 sparge_source: $("#sparge_source").val(),
2561 // sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')), 2736 sparge_acid_type: $("#sparge_acid_type").val(),
2562 // sparge_acid_amount: parseFloat($("#sparge_acid_amount").jqxNumberInput('decimal')), 2737 sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
2738 sparge_acid_amount: dataRecord.sparge_acid_amount,
2563 calc_acid: $("#calc_acid").val(), 2739 calc_acid: $("#calc_acid").val(),
2564 w1_name: $("#w1_name").val(), 2740 w1_name: $("#w1_name").val(),
2565 w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')), 2741 w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')),
2566 w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')), 2742 w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')),
2567 w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')), 2743 w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')),

mercurial