79 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
80 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
80 $('#est_color').val(kw_to_ebc($("#color_method").val(), colorw)); |
81 $('#est_color').val(kw_to_ebc($("#color_method").val(), colorw)); |
81 }; |
82 }; |
82 |
83 |
83 function calcIBUs() { |
84 function calcIBUs() { |
84 console.log("calcIBUs()"); |
|
85 |
|
86 var total_ibus = 0; |
85 var total_ibus = 0; |
87 var rows = $('#hopGrid').jqxGrid('getboundrows'); |
86 var rows = $('#hopGrid').jqxGrid('getrows'); |
88 for (var i = 0; i < rows.length; i++) { |
87 for (var i = 0; i < rows.length; i++) { |
89 var row = rows[i]; |
88 var row = rows[i]; |
90 |
89 total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')), |
91 total_ibus += toIBU(row.h_useat, |
90 parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), $("#ibu_method").val()); |
92 row.h_form, |
|
93 preboil_sg, |
|
94 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
|
95 parseFloat(row.h_amount), |
|
96 parseFloat(row.h_time), |
|
97 parseFloat(row.h_alpha), |
|
98 $("#ibu_method").val() |
|
99 ); |
|
100 } |
91 } |
101 console.log("IBUs: " + total_ibus); |
92 console.log("calcIBUs(): " + total_ibus); |
102 $('#est_ibu').val(total_ibus); |
93 $('#est_ibu').val(total_ibus); |
103 $('#hopGrid').jqxGrid('render'); |
|
104 }; |
94 }; |
105 |
95 |
106 function calcInit () { |
96 function calcInit () { |
107 console.log("calc.init()"); |
97 console.log("calc.init()"); |
108 // $('#est_og').on('change', function (event) { calcFermentables(); }); |
98 // $('#est_og').on('change', function (event) { calcFermentables(); }); |
665 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
654 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
666 } |
655 } |
667 }); |
656 }); |
668 }, |
657 }, |
669 ready: function() { |
658 ready: function() { |
670 calcIBUs(); |
|
671 $('#jqxTabs').jqxTabs('next'); |
659 $('#jqxTabs').jqxTabs('next'); |
672 }, |
660 }, |
673 columns: [ |
661 columns: [ |
674 { text: 'Hop', editable: false, datafield: 'h_name' }, |
662 { text: 'Hop', editable: false, datafield: 'h_name' }, |
675 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
663 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
676 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
664 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
677 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
665 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
678 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
666 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
679 columntype: 'numberinput', |
667 columntype: 'numberinput', |
|
668 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
669 editor.jqxNumberInput({ decimalDigits: 3, min: 0, spinButtons: false }); |
|
670 }, |
680 validation: function (cell, value) { |
671 validation: function (cell, value) { |
681 if (value < 0 || value > 100000000000 ) { |
672 if (value < 0 || value > 100000000000 ) { |
682 return { result: false, message: "Volume moet 0-~ zijn" }; |
673 return { result: false, message: "Volume moet 0-~ zijn" }; |
683 } |
674 } |
684 return true; |
675 return true; |
685 } |
676 } |
686 }, |
677 }, |
687 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat' }, |
678 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat' }, |
688 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
679 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
689 columntype: 'numberinput', |
680 columntype: 'numberinput', |
|
681 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
682 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0 }); |
|
683 }, |
690 validation: function (cell, value) { |
684 validation: function (cell, value) { |
691 if (value < 0 || value > 100000000000 ) { |
685 var high = parseFloat($("#boil_time").jqxNumberInput('decimal')); |
692 return { result: false, message: "De tijd moet 0-~ zijn" }; |
686 if (value < 0 || value > high ) { |
|
687 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
693 } |
688 } |
694 return true; |
689 return true; |
695 } // TODO: Only enable editing if Boil, else use fixed values. |
690 } // TODO: Only enable editing if Boil, else use fixed values. |
696 }, |
691 }, |
697 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', |
692 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', |
698 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
693 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
699 var ibu = toIBU(rowdata.h_useat, |
694 var ibu = toIBU(rowdata.h_useat, |
700 rowdata.h_form, |
695 rowdata.h_form, |
701 preboil_sg, |
696 preboil_sg, |
702 /*parseFloat($("#est_og").jqxNumberInput('decimal')),*/ |
|
703 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
697 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
704 parseFloat(rowdata.h_amount), |
698 parseFloat(rowdata.h_amount), |
705 parseFloat(rowdata.h_time), |
699 parseFloat(rowdata.h_time), |
706 parseFloat(rowdata.h_alpha), |
700 parseFloat(rowdata.h_alpha), |
707 $("#ibu_method").val() |
701 $("#ibu_method").val() |
708 ); |
702 ); |
|
703 calcIBUs(); |
709 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; |
704 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; |
710 } |
705 } |
711 } |
706 } |
712 ] |
707 ] |
713 }); |
708 }); |
714 $("#hopGrid").on('cellendedit', function (event) { |
709 // $("#hopGrid").on('cellendedit', function (event) { |
715 //calcIBUs(); |
710 // //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); |
716 //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); |
711 // }); |
717 }); |
|
718 }; |
712 }; |
719 |
713 |
720 // Inline miscs editor |
714 // Inline miscs editor |
721 var editMisc = function (data) { |
715 var editMisc = function (data) { |
722 var miscSource = { |
716 var miscSource = { |