Mon, 10 Dec 2018 22:20:19 +0100
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
68 | 1 | /***************************************************************************** |
2 | * Copyright (C) 2018 | |
3 | * | |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of BMS | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * BrewCloud is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
23 | ||
24 | function createDelElements() { | |
25 | $('#eventWindow').jqxWindow({ | |
26 | theme: theme, | |
27 | position: { x: 490, y: 210 }, | |
28 | width: 300, | |
29 | height: 175, | |
30 | resizable: false, | |
31 | isModal: true, | |
32 | modalOpacity: 0.4, | |
33 | okButton: $('#delOk'), | |
34 | cancelButton: $('#delCancel'), | |
35 | initContent: function () { | |
36 | $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); | |
37 | $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); | |
38 | $('#delCancel').focus(); | |
39 | } | |
40 | }); | |
41 | $('#eventWindow').jqxWindow('hide'); | |
42 | } | |
43 | ||
44 | ||
45 | $(document).ready(function () { | |
46 | ||
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
47 | var dataRecord = {}; |
127
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
48 | var to_100 = false; // Fermentables adjust to 100% |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
49 | var preboil_sg = 0; |
97
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
50 | var sugarsm = 0; // Sugars after mash |
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
51 | var sugarsf = 0; // Sugars after boil |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
52 | var psugar = 0; // Percentage real sugars |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
53 | var pcara = 0; // Percentage cara/crystal malts |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
54 | var svg = 77; // Default attenuation |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
55 | |
68 | 56 | console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
57 | $("#jqxLoader").jqxLoader({ |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
58 | width: 250, |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
59 | height: 150, |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
60 | isModal: true, |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
61 | text: "Laden recept ...", |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
62 | theme: theme |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
63 | }); |
68 | 64 | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
65 | function calcFermentables() { |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
66 | console.log("calcFermentables()"); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
67 | sugarsf = 0; |
97
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
68 | sugarsm = 0; |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
69 | psugar = 0; |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
70 | pcara = 0; |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
71 | var colorw = 0; // Colors working |
127
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
72 | var my_100 = false; |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
73 | |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
74 | var rows = $('#fermentableGrid').jqxGrid('getrows'); |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
75 | for (var i = 0; i < rows.length; i++) { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
76 | var row = rows[i]; |
127
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
77 | if (row.f_adjust_to_total_100) |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
78 | my_100 = true; |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
79 | if (row.f_type == "Sugar") |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
80 | psugar += row.f_percentage; |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
81 | if (row.f_graintype == "Crystal") |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
82 | pcara += row.f_percentage; |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
83 | var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
97
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
84 | if (row.f_added == "Mash") { |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
85 | d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d; |
97
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
86 | sugarsm += d; |
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
87 | } |
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
88 | sugarsf += d; |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
89 | colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat($("#batch_size").jqxNumberInput('decimal')) * 8.34436; |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
90 | } |
127
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
91 | if (to_100 != my_100) |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
92 | console.log("change to_100 to:"+my_100); |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
93 | to_100 = my_100; |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
94 | $('#est_og').val(estimate_sg(sugarsf, parseFloat($("#batch_size").jqxNumberInput('decimal')))); |
97
22c277be7e7e
Don't count sugar for preboil gravity.
Michiel Broek <mbroek@mbse.eu>
parents:
96
diff
changeset
|
95 | preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
96 | $('#est_color').val(kw_to_ebc($("#color_method").val(), colorw)); |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
97 | }; |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
98 | |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
99 | function hopFlavourContribution(bt, vol, use, amount) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
100 | var result; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
101 | |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
102 | if ((use == "First Wort") || (use == "First wort")) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
103 | result = 0.15 * amount * 1000; // assume 15% flavourcontribution for fwh |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
104 | } else if (bt > 50) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
105 | result = 0.10 * amount * 1000; // assume 10% flavourcontribution as a minimum |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
106 | } else { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
107 | result = 15.25 / (6 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 21) /6, 2)) * amount * 1000; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
108 | if (result < (0.10 * amount * 1000)) |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
109 | result = 0.10 * amount * 1000; // assume 10% flavourcontribution as a minimum |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
110 | } |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
111 | console.log("hopFlavourContribution("+bt+","+vol+","+use+","+amount+"): "+(result / vol)); |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
112 | return result / vol; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
113 | } |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
114 | |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
115 | function hopAromaContribution(bt, vol, use, amount) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
116 | var result = 0; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
117 | |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
118 | if (bt > 20) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
119 | result = 0; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
120 | } else if (bt > 7.5) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
121 | result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2)) * amount * 1000; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
122 | } else if (use == "Boil") { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
123 | result = amount * 1000; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
124 | } else if (use == "Aroma") { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
125 | result = 1.2 * amount * 1000; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
126 | } else if (use == "Whirlpool") { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
127 | result = 1.2 * amount * 1000; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
128 | } else if ((use == "Dry Hop") || (use == "Dry hop")) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
129 | result = 1.33 * amount * 1000; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
130 | } |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
131 | console.log("hopAromaContribution("+bt+","+vol+","+use+","+amount+"): "+(result / vol)); |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
132 | return result / vol; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
133 | } |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
134 | |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
135 | function calcIBUs() { |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
136 | var total_ibus = 0; |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
137 | var rows = $('#hopGrid').jqxGrid('getrows'); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
138 | for (var i = 0; i < rows.length; i++) { |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
139 | var row = rows[i]; |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
140 | total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')), |
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
141 | parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), $("#ibu_method").val()); |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
142 | hopFlavourContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')), |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
143 | row.h_useat, parseFloat(row.h_amount)); |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
144 | hopAromaContribution(parseFloat(row.h_time), parseFloat($("#batch_size").jqxNumberInput('decimal')), |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
145 | row.h_useat, parseFloat(row.h_amount)); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
146 | } |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
147 | console.log("calcIBUs(): " + total_ibus); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
148 | $('#est_ibu').val(total_ibus); |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
149 | }; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
150 | |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
151 | function calcSVG() { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
152 | var rows = $('#yeastGrid').jqxGrid('getrows'); |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
153 | for (var i = 0; i < rows.length; i++) { |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
154 | var row = rows[i]; |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
155 | if (row.y_use == "Primary") |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
156 | svg = parseFloat(row.y_attenuation); |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
157 | } |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
158 | } |
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
159 | |
133
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
160 | function calcFermentablesFromOG(OG) { |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
161 | |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
162 | console.log("calcFermentablesFromOG("+OG+")"); |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
163 | var i; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
164 | var efficiency = parseFloat($("#efficiency").jqxNumberInput('decimal')); |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
165 | var rows = $('#fermentableGrid').jqxGrid('getrows'); |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
166 | var sug = sg_to_plato(OG) * parseFloat($("#batch_size").jqxNumberInput('decimal')) * OG / 100; //total amount of sugars in kg |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
167 | var tot = 0; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
168 | var d; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
169 | for (i = 0; i < rows.length; i++) { |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
170 | row = rows[i]; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
171 | d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
172 | if (row.f_added == "Mash") |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
173 | d = efficiency / 100 * d; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
174 | tot += d; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
175 | } |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
176 | |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
177 | var totmass = 0; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
178 | if (tot) |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
179 | totmass = sug / tot; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
180 | |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
181 | if (totmass) { |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
182 | for (i = 0; i < rows.length; i++) { |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
183 | row = rows[i]; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
184 | $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_amount", row.f_percentage / 100 * totmass); |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
185 | } |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
186 | } |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
187 | //CalcWaterBalance; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
188 | }; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
189 | |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
190 | function calcABV() { |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
191 | $("#est_abv").val(abvol(parseFloat($("#est_og").jqxNumberInput('decimal')), parseFloat($("#est_fg").jqxNumberInput('decimal')))); |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
192 | }; |
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
193 | |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
194 | function calcInit () { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
195 | console.log("calc.init()"); |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
196 | |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
197 | $('#color_method').on('change', function (event) { calcFermentables(); }); |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
198 | $('#ibu_method').on('change', function (event) { |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
199 | calcFermentables(); |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
200 | calcIBUs(); |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
201 | }); |
134
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
202 | $('#batch_size').on('change', function (event) { |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
203 | console.log("batch_size change:"+event.args.value+" old:"+dataRecord.batch_size); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
204 | var new_boil = parseFloat(event.args.value) + dataRecord.boil_size - dataRecord.batch_size; |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
205 | dataRecord.boil_size = new_boil; |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
206 | $("#boil_size").val(Math.round(new_boil * 100) / 100); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
207 | dataRecord.batch_size = parseFloat(event.args.value); |
134
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
208 | calcFermentablesFromOG(parseFloat($("#est_og").jqxNumberInput('decimal'))); // Keep the OG |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
209 | calcFermentables(); |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
210 | calcSVG(); |
134
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
211 | calcABV(); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
212 | // TODO: adjust the hops, miscs, yeast, water. |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
213 | calcIBUs(); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
214 | }); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
215 | $('#boil_time').on('change', function (event) { |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
216 | console.log("boil_time change:"+parseFloat(event.args.value)+" old:"+dataRecord.boil_time); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
217 | var old_evap = parseFloat(dataRecord.boil_size) - parseFloat(dataRecord.batch_size); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
218 | var new_evap = old_evap * (parseFloat(event.args.value) / dataRecord.boil_time); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
219 | var new_boil = parseFloat(dataRecord.batch_size) + new_evap; |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
220 | // console.log("old_evap:"+old_evap+" new_evap:"+new_evap+" new_boil:"+new_boil); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
221 | dataRecord.boil_time = parseFloat(event.args.value); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
222 | dataRecord.boil_size = new_boil; |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
223 | $("#boil_size").val(Math.round(new_boil * 100) / 100); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
224 | calcFermentables(); |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
225 | calcSVG(); |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
226 | calcABV(); |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
227 | // TODO: adjust the hops, miscs, yeast, water. |
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
228 | calcIBUs(); |
134
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
229 | }); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
230 | $('#efficiency').on('change', function (event) { |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
231 | console.log("efficiency change:"+event.args.value); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
232 | calcFermentables(); |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
233 | calcSVG(); |
134
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
234 | calcABV(); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
235 | calcIBUs(); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
236 | }); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
237 | $('#est_og').on('change', function (event) { |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
238 | console.log("est_og change:"+event.args.value); |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
239 | calcFermentablesFromOG(event.args.value); // Adjust fermentables amounts |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
240 | calcFermentables(); // Update the recipe details |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
241 | calcSVG(); |
134
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
242 | calcABV(); // and ABV |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
243 | calcIBUs(); // and the IBU's. |
be59b9127978
Added change batch size and efficiency.
Michiel Broek <mbroek@mbse.eu>
parents:
133
diff
changeset
|
244 | }); |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
245 | }; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
246 | |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
247 | // Styles dropdown list |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
248 | var stylesUrl = "includes/db_profile_styles.php"; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
249 | var stylesSource = { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
250 | datatype: "json", |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
251 | datafields: [ |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
252 | { name: 'record', type: 'number' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
253 | { name: 'name', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
254 | { name: 'category', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
255 | { name: 'category_number', type: 'number' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
256 | { name: 'style_letter', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
257 | { name: 'style_guide', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
258 | { name: 'type', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
259 | { name: 'og_min', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
260 | { name: 'og_max', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
261 | { name: 'fg_min', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
262 | { name: 'fg_max', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
263 | { name: 'ibu_min', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
264 | { name: 'ibu_max', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
265 | { name: 'color_min', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
266 | { name: 'color_max', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
267 | { name: 'carb_min', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
268 | { name: 'carb_max', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
269 | { name: 'abv_min', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
270 | { name: 'abv_max', type: 'float' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
271 | { name: 'notes', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
272 | { name: 'profile', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
273 | { name: 'ingredients', type: 'string' }, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
274 | { name: 'examples', type: 'string' } |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
275 | ], |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
276 | url: stylesUrl, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
277 | async: true |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
278 | }; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
279 | var styleslist = new $.jqx.dataAdapter(stylesSource); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
280 | $("#styleSelect").jqxDropDownList({ |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
281 | placeHolder: "Kies bierstijl:", |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
282 | theme: theme, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
283 | source: styleslist, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
284 | displayMember: "name", |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
285 | width: 150, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
286 | height: 27, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
287 | dropDownVerticalAlignment: 'top', |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
288 | dropDownWidth: 500, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
289 | dropDownHeight: 380, |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
290 | renderer: function (index, label, value) { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
291 | var datarecord = styleslist.records[index]; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
292 | return datarecord.style_guide + " " + datarecord.style_letter+ " " + datarecord.name; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
293 | } |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
294 | }); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
295 | $("#styleSelect").on('select', function (event) { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
296 | if (event.args) { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
297 | var index = event.args.index; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
298 | var datarecord = styleslist.records[index]; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
299 | $("#st_name").val(datarecord.name); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
300 | $("#st_category").val(datarecord.category); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
301 | $("#st_category_number").val(datarecord.category_number); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
302 | $("#st_letter").val(datarecord.style_letter); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
303 | $("#st_guide").val(datarecord.style_guide); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
304 | $("#st_type").val(datarecord.type); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
305 | $("#st_og_min").val(datarecord.og_min); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
306 | $("#st_og_max").val(datarecord.og_max); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
307 | $("#st_fg_min").val(datarecord.fg_min); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
308 | $("#st_fg_max").val(datarecord.fg_max); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
309 | $("#st_ibu_min").val(datarecord.ibu_min); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
310 | $("#st_ibu_max").val(datarecord.ibu_max); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
311 | $("#st_color_min").val(datarecord.color_min); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
312 | $("#st_color_max").val(datarecord.color_max); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
313 | $("#st_carb_min").val(datarecord.carb_min); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
314 | $("#st_carb_max").val(datarecord.carb_max); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
315 | $("#st_abv_min").val(datarecord.abv_min); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
316 | $("#st_abv_max").val(datarecord.abv_max); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
317 | } |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
318 | }); |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
319 | |
68 | 320 | var url = "includes/db_recipes.php"; |
321 | // tooltips | |
322 | $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); | |
323 | $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
324 | $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); |
95 | 325 | $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); |
326 | $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' }); | |
327 | $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); | |
328 | $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' }); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
329 | $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
330 | $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
331 | $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
332 | $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
333 | $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
334 | $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
335 | |
68 | 336 | $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
337 | $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
338 | $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
339 | $("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
340 | $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
341 | $("#st_type").jqxTooltip({ content: 'Het bierstijl type.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
342 | $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
343 | $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
344 | $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
345 | $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
346 | $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
347 | $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
348 | $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
349 | $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
350 | $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
351 | $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
352 | $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
353 | $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
354 | |
68 | 355 | // prepare the data |
356 | var source = { | |
357 | datatype: "json", | |
358 | cache: false, | |
359 | datafields: [ | |
360 | { name: 'record', type: 'number' }, | |
361 | { name: 'st_name', type: 'string' }, | |
362 | { name: 'st_letter', type: 'string' }, | |
363 | { name: 'st_guide', type: 'string' }, | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
364 | { name: 'st_type', type: 'string' }, |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
365 | { name: 'st_category', type: 'string' }, |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
366 | { name: 'st_category_number', type: 'float' }, |
68 | 367 | { name: 'st_og_min', type: 'float' }, |
368 | { name: 'st_og_max', type: 'float' }, | |
369 | { name: 'st_fg_min', type: 'float' }, | |
370 | { name: 'st_fg_max', type: 'float' }, | |
371 | { name: 'st_ibu_min', type: 'float' }, | |
372 | { name: 'st_ibu_max', type: 'float' }, | |
373 | { name: 'st_color_min', type: 'float' }, | |
374 | { name: 'st_color_max', type: 'float' }, | |
375 | { name: 'st_carb_min', type: 'float' }, | |
376 | { name: 'st_carb_max', type: 'float' }, | |
377 | { name: 'st_abv_min', type: 'float' }, | |
378 | { name: 'st_abv_max', type: 'float' }, | |
379 | { name: 'name', type: 'string' }, | |
380 | { name: 'notes', type: 'string' }, | |
71
e1c50b21b7e3
Added new recipe screens and wizzard.
Michiel Broek <mbroek@mbse.eu>
parents:
69
diff
changeset
|
381 | { name: 'type', type: 'string' }, |
68 | 382 | { name: 'batch_size', type: 'float' }, |
95 | 383 | { name: 'boil_size', type: 'float' }, |
68 | 384 | { name: 'boil_time', type: 'float' }, |
385 | { name: 'efficiency', type: 'float' }, | |
386 | { name: 'est_og', type: 'float' }, | |
387 | { name: 'est_fg', type: 'float' }, | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
388 | { name: 'est_abv', type: 'float' }, |
68 | 389 | { name: 'est_color', type: 'float' }, |
390 | { name: 'color_method', type: 'string' }, | |
391 | { name: 'est_ibu', type: 'float' }, | |
392 | { name: 'ibu_method', type: 'string' }, | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
393 | { name: 'est_carb', type: 'float' }, |
68 | 394 | { name: 'mash_sparge_temp', type: 'float' }, |
395 | { name: 'mash_ph', type: 'float' }, | |
396 | { name: 'mash_name', type: 'string' }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
397 | { name: 'fermentables', type: 'array' }, |
68 | 398 | { name: 'hops', type: 'string' }, |
399 | { name: 'miscs', type: 'string' }, | |
400 | { name: 'yeasts', type: 'string' }, | |
401 | { name: 'waters', type: 'array' }, | |
402 | { name: 'mashs', type: 'string' } | |
403 | ], | |
404 | id: 'record', | |
130
601920b902e5
Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
405 | url: url + '?record=' + my_record |
68 | 406 | }; |
407 | // Load data and select one record. | |
408 | var dataAdapter = new $.jqx.dataAdapter(source, { | |
409 | loadComplete: function () { | |
410 | var records = dataAdapter.records; | |
411 | dataRecord = records[0]; | |
412 | $("#name").val(dataRecord.name); | |
413 | $("#notes").val(dataRecord.notes); | |
414 | $("#st_name").val(dataRecord.st_name); | |
415 | $("#st_letter").val(dataRecord.st_letter); | |
416 | $("#st_guide").val(dataRecord.st_guide); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
417 | $("#st_category").val(dataRecord.st_category); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
418 | $("#st_category_number").val(dataRecord.st_category_number); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
419 | $("#st_type").val(dataRecord.st_type); |
68 | 420 | $("#type").val(dataRecord.type); |
421 | $("#batch_size").val(dataRecord.batch_size); | |
95 | 422 | $("#boil_size").val(dataRecord.boil_size); |
68 | 423 | $("#boil_time").val(dataRecord.boil_time); |
424 | $("#efficiency").val(dataRecord.efficiency); | |
425 | $("#est_og").val(dataRecord.est_og); | |
426 | $("#st_og_min").val(dataRecord.st_og_min); | |
427 | $("#st_og_max").val(dataRecord.st_og_max); | |
428 | $("#est_fg").val(dataRecord.est_fg); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
429 | $("#st_fg_min").val(dataRecord.st_fg_min); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
430 | $("#st_fg_max").val(dataRecord.st_fg_max); |
68 | 431 | $("#est_color").val(dataRecord.est_color); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
432 | $("#est_abv").val(dataRecord.est_abv); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
433 | $("#st_abv_min").val(dataRecord.st_abv_min); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
434 | $("#st_abv_max").val(dataRecord.st_abv_max); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
435 | $("#st_color_min").val(dataRecord.st_color_min); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
436 | $("#st_color_max").val(dataRecord.st_color_max); |
68 | 437 | $("#color_method").val(dataRecord.color_method); |
438 | $("#est_ibu").val(dataRecord.est_ibu); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
439 | $("#st_ibu_min").val(dataRecord.st_ibu_min); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
440 | $("#st_ibu_max").val(dataRecord.st_ibu_max); |
68 | 441 | $("#ibu_method").val(dataRecord.ibu_method); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
442 | $("#est_carb").val(dataRecord.est_carb); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
443 | $("#st_carb_min").val(dataRecord.st_carb_min); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
444 | $("#st_carb_max").val(dataRecord.st_carb_max); |
68 | 445 | $("#mash_name").val(dataRecord.mash_name); |
446 | $("#mash_ph").val(dataRecord.mash_ph); | |
447 | $("#mash_sparge_temp").val(dataRecord.mash_sparge_temp); | |
448 | editFermentable(dataRecord); | |
449 | editHop(dataRecord); | |
450 | editMisc(dataRecord); | |
451 | editYeast(dataRecord); | |
452 | editWater(dataRecord); | |
453 | editMash(dataRecord); | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
454 | $('#jqxTabs').jqxTabs('next'); |
68 | 455 | }, |
456 | loadError: function (jqXHR, status, error) { | |
457 | }, | |
458 | beforeLoadComplete: function (records) { | |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
459 | $('#jqxLoader').jqxLoader('open'); |
68 | 460 | } |
461 | }); | |
462 | dataAdapter.dataBind(); | |
463 | ||
464 | // Inline fermentables editor | |
465 | var editFermentable = function (data) { | |
466 | var fermentableSource = { | |
467 | localdata: data.fermentables, | |
468 | datatype: "local", | |
469 | datafields: [ | |
470 | { name: 'f_name', type: 'string' }, | |
471 | { name: 'f_origin', type: 'string' }, | |
472 | { name: 'f_supplier', type: 'string' }, | |
473 | { name: 'f_amount', type: 'float' }, | |
474 | { name: 'f_cost', type: 'float' }, | |
475 | { name: 'f_type', type: 'string' }, | |
476 | { name: 'f_yield', type: 'float' }, | |
477 | { name: 'f_color', type: 'float' }, | |
478 | { name: 'f_coarse_fine_diff', type: 'float' }, | |
479 | { name: 'f_moisture', type: 'float' }, | |
480 | { name: 'f_diastatic_power', type: 'float' }, | |
481 | { name: 'f_protein', type: 'float' }, | |
482 | { name: 'f_max_in_batch', type: 'float' }, | |
483 | { name: 'f_graintype', type: 'string' }, | |
484 | { name: 'f_added', type: 'string' }, | |
485 | { name: 'f_dissolved_protein', type: 'float' }, | |
486 | { name: 'f_recommend_mash', type: 'bool' }, | |
487 | { name: 'f_add_after_boil', type: 'bool' }, | |
488 | { name: 'f_adjust_to_total_100', type: 'bool' }, | |
489 | { name: 'f_percentage', type: 'float' }, | |
490 | { name: 'f_di_ph', type: 'float' } | |
491 | ], | |
492 | addrow: function (rowid, rowdata, position, commit) { | |
493 | commit(true); | |
494 | }, | |
495 | deleterow: function (rowid, commit) { | |
496 | commit(true); | |
497 | } | |
498 | }; | |
499 | var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); | |
500 | // dropdownlist datasource from inventory_fermentables | |
501 | var fermentableUrl = "getfermentablesources.php"; | |
502 | var fermentableInvSource = { | |
503 | datatype: "json", | |
504 | datafields: [ | |
505 | { name: 'record', type: 'number' }, | |
506 | { name: 'name', type: 'string' }, | |
507 | { name: 'type', type: 'string' }, | |
508 | { name: 'yield', type: 'float' }, | |
509 | { name: 'color', type: 'float' }, | |
510 | { name: 'add_after_boil', type: 'bool' }, | |
511 | { name: 'origin', type: 'string' }, | |
512 | { name: 'supplier', type: 'string' }, | |
513 | { name: 'coarse_fine_diff', type: 'float' }, | |
514 | { name: 'moisture', type: 'float' }, | |
515 | { name: 'diastatic_power', type: 'float' }, | |
516 | { name: 'protein', type: 'float' }, | |
517 | { name: 'max_in_batch', type: 'float' }, | |
518 | { name: 'recommend_mash', type: 'bool' }, | |
519 | { name: 'graintype', type: 'string' }, | |
520 | { name: 'di_ph', type: 'float' }, | |
521 | { name: 'inventory', type: 'float' }, | |
522 | { name: 'cost', type: 'float' } | |
523 | ], | |
524 | url: fermentableUrl, | |
525 | async: true | |
526 | }; | |
527 | var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); | |
528 | ||
529 | $("#fermentableGrid").jqxGrid({ | |
128
4d188d216c88
Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
530 | width: 1150, |
68 | 531 | height: 400, |
532 | source: fermentableAdapter, | |
533 | theme: theme, | |
534 | selectionmode: 'singlerow', | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
535 | editmode: 'selectedcell', |
68 | 536 | editable: true, |
537 | localization: getLocalization(), | |
538 | showtoolbar: true, | |
539 | rendertoolbar: function (toolbar) { | |
540 | var me = this; | |
541 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
542 | toolbar.append(container); | |
543 | container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); | |
128
4d188d216c88
Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
544 | container.append('<input style="float: left; margin-left: 505px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); |
68 | 545 | // add fermentable from dropdownlist. |
546 | $("#faddrowbutton").jqxDropDownList({ | |
547 | placeHolder: "Kies mout:", | |
548 | theme: theme, | |
549 | source: fermentablelist, | |
550 | displayMember: "name", | |
551 | width: 150, | |
552 | height: 27, | |
553 | dropDownWidth: 500, | |
554 | dropDownHeight: 500, | |
555 | renderer: function (index, label, value) { | |
556 | var datarecord = fermentablelist.records[index]; | |
557 | return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; | |
558 | } | |
559 | }); | |
560 | $("#faddrowbutton").on('select', function (event) { | |
561 | if (event.args) { | |
562 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; | |
563 | var index = event.args.index; | |
564 | var datarecord = fermentablelist.records[index]; | |
565 | var row = {}; | |
566 | row["f_name"] = datarecord.name; | |
567 | row["f_origin"] = datarecord.origin; | |
568 | row["f_supplier"] = datarecord.supplier; | |
569 | row["f_amount"] = 0; | |
570 | row["f_cost"] = datarecord.cost; | |
571 | row["f_type"] = datarecord.type; | |
572 | row["f_yield"] = datarecord.yield; | |
573 | row["f_color"] = datarecord.color; | |
574 | row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff; | |
575 | row["f_moisture"] = datarecord.moisture; | |
576 | row["f_diastatic_power"] = datarecord.diastatic_power; | |
577 | row["f_protein"] = datarecord.protein; | |
578 | row["f_max_in_batch"] = datarecord.max_in_batch; | |
579 | row["f_graintype"] = datarecord.graintype; | |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
580 | if (datarecord.add_after_boil) { |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
581 | row["f_added"] = "Primary"; |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
582 | } else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) { |
68 | 583 | row["f_added"] = "Boil"; |
584 | } else { | |
585 | row["f_added"] = "Mash"; | |
586 | } | |
587 | row["f_dissolved_protein"] = 0; | |
588 | row["f_recommend_mash"] = datarecord.recommend_mash; | |
589 | row["f_add_after_boil"] = datarecord.add_after_boil; | |
590 | if (rowscount == 0) { | |
591 | // The first fermentable | |
592 | row["f_adjust_to_total_100"] = 1; | |
593 | row["f_percentage"] = 100; | |
594 | } else { | |
595 | row["f_adjust_to_total_100"] = 0; | |
596 | row["f_percentage"] = 0; | |
597 | } | |
598 | row["f_di_ph"] = datarecord.di_ph; | |
599 | var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); | |
600 | } | |
601 | }); | |
602 | ||
603 | // delete selected fermentable. | |
604 | $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
605 | $("#fdeleterowbutton").on('click', function () { | |
606 | var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); | |
607 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; | |
608 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
609 | var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); | |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
610 | var percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_percentage"); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
611 | var amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_amount"); |
68 | 612 | var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
613 | } | |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
614 | rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
615 | if (rowscount > 1) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
616 | if (to_100) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
617 | for (var i = 0; i < rowscount; i++) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
618 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
619 | if (rowdata.f_adjust_to_total_100) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
620 | rowdata.f_percentage += percent; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
621 | rowdata.f_amount += amount; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
622 | } |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
623 | } |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
624 | } else { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
625 | var tw = 0; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
626 | for (i = 0; i < rowscount; i++) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
627 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
628 | tw += rowdata.f_amount; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
629 | }; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
630 | for (i = 0; i < rowscount; i++) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
631 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
632 | var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
633 | $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
634 | }; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
635 | } |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
636 | } else { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
637 | $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
638 | } |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
639 | calcFermentables(); |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
640 | calcSVG(); |
133
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
641 | calcABV(); |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
642 | calcIBUs(); |
68 | 643 | }); |
644 | }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
645 | ready: function() { |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
646 | calcFermentables(); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
647 | $('#jqxTabs').jqxTabs('next'); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
648 | }, |
68 | 649 | columns: [ |
128
4d188d216c88
Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
650 | { text: 'Vergistbaar ingrediënt', editable: false, datafield: 'f_name', |
68 | 651 | cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
652 | var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); | |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
653 | return "<span style='margin: 3px; margin-top: 6px; float: "+columnproperties.cellsalign+"'>" +rowData.f_name + " (" + rowData.f_color + " EBC)</span>"; |
68 | 654 | } |
655 | }, | |
128
4d188d216c88
Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
656 | { text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' }, |
127
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
657 | { text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist', |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
658 | createeditor: function (row, column, editor) { |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
659 | var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ]; |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
660 | editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded }); |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
661 | } |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
662 | }, |
128
4d188d216c88
Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
663 | { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
664 | { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
68 | 665 | columntype: 'numberinput', |
666 | validation: function (cell, value) { | |
667 | // Maximum weight is the batch_size, just a simple check. | |
668 | var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal')); | |
669 | if (value < 0 || value > maxmout) { | |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
670 | return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" }; |
68 | 671 | } |
672 | return true; | |
673 | }, | |
674 | initeditor: function (row, cellvalue, editor) { | |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
675 | editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false }); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
676 | }, |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
677 | cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
678 | if (to_100) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
679 | return oldvalue; // When using percentages, don't allow edited results. |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
680 | } |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
681 | // console.log("row:"+row+" col:"+column+" type:"+columntype+" old:"+oldvalue+" new:"+newvalue); |
68 | 682 | } |
683 | }, | |
128
4d188d216c88
Layout changes in fermentables editor.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
684 | { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1', |
68 | 685 | columntype: 'numberinput', |
686 | validation: function (cell, value) { | |
687 | if (value < 0 || value > 100) { | |
688 | return { result: false, message: "Percentage moet 0-100 zijn" }; | |
689 | } | |
690 | return true; | |
691 | }, | |
692 | initeditor: function (row, cellvalue, editor) { | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
693 | editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false }); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
694 | }, |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
695 | cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
696 | oldvalue = Math.round(oldvalue * 10) / 10.0; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
697 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
698 | if ((oldvalue != newvalue) && (rowscount > 1)) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
699 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
700 | if (rowdata.f_adjust_to_total_100) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
701 | return oldvalue; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
702 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
703 | var diff = newvalue - oldvalue; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
704 | var tw = 0; // total weight |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
705 | for (i = 0; i < rowscount; i++) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
706 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
707 | tw += rowdata.f_amount; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
708 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
709 | if (to_100) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
710 | // Adjust this row and the 100% row. |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
711 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
712 | rowdata.f_amount += tw * diff / 100; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
713 | for (i = 0; i < rowscount; i++) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
714 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
715 | if (rowdata.f_adjust_to_total_100) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
716 | rowdata.f_percentage -= diff; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
717 | rowdata.f_amount -= tw * diff / 100; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
718 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
719 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
720 | } else { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
721 | // Adjust all the rows. |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
722 | var nw = tw * diff / 100; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
723 | for (i = 0; i < rowscount; i++) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
724 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
725 | if (i == row) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
726 | rowdata.f_amount += nw; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
727 | } else { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
728 | rowdata.f_amount -= nw / (rowscount - 1); |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
729 | rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
730 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
731 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
732 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
733 | } |
68 | 734 | } |
735 | }, | |
127
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
736 | { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80, |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
737 | cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
738 | if (to_100) { |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
739 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
740 | for (i = 0; i < rowscount; i++) { |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
741 | if (i != row) { |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
742 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
743 | rowdata.f_adjust_to_total_100 = false; |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
744 | } |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
745 | } |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
746 | } |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
747 | } |
6d5e215d77d2
Added fermentables Moment dropdown list. Added fermentables adjust to 100% logic.
Michiel Broek <mbroek@mbse.eu>
parents:
126
diff
changeset
|
748 | } |
68 | 749 | ] |
750 | }); | |
751 | $("#fermentableGrid").on('cellendedit', function (event) { | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
752 | var args = event.args; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
753 | console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
754 | // Make sure the grid itself is updated. |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
755 | $("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
756 | if ((args.datafield == 'f_amount') && (! to_100)) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
757 | // If one of the amounts is changed, recalculate the percentages. |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
758 | console.log("adjust percentages"); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
759 | var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
760 | if (rowscount > 1) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
761 | var tw = 0; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
762 | for (i = 0; i < rowscount; i++) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
763 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
764 | tw += rowdata.f_amount; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
765 | }; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
766 | for (i = 0; i < rowscount; i++) { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
767 | var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
768 | var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
769 | $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
770 | }; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
771 | } else { |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
772 | $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
773 | } |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
774 | }; |
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
775 | $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); // TODO: not reliable |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
776 | calcFermentables(); |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
777 | calcSVG(); |
133
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
778 | calcABV(); |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
779 | calcIBUs(); // Depends on gravity, so recalculate. |
68 | 780 | }); |
781 | }; | |
782 | ||
783 | // Inline hops editor | |
784 | var editHop = function (data) { | |
785 | var hopSource = { | |
786 | localdata: data.hops, | |
787 | datatype: "local", | |
788 | cache: false, | |
789 | datafields: [ | |
790 | { name: 'h_name', type: 'string' }, | |
791 | { name: 'h_origin', type: 'string' }, | |
792 | { name: 'h_amount', type: 'float' }, | |
793 | { name: 'h_cost', type: 'float' }, | |
794 | { name: 'h_type', type: 'string' }, | |
795 | { name: 'h_form', type: 'string' }, | |
796 | { name: 'h_useat', type: 'string' }, | |
797 | { name: 'h_time', type: 'float' }, | |
798 | { name: 'h_alpha', type: 'float' }, | |
799 | { name: 'h_beta', type: 'float' }, | |
800 | { name: 'h_hsi', type: 'float' }, | |
801 | { name: 'h_humulene', type: 'float' }, | |
802 | { name: 'h_carophyllene', type: 'float' }, | |
803 | { name: 'h_cohumulone', type: 'float' }, | |
804 | { name: 'h_myrcene', type: 'float' }, | |
805 | { name: 'h_total_oil', type: 'float' } | |
806 | ], | |
807 | addrow: function (rowid, rowdata, position, commit) { | |
808 | commit(true); | |
809 | }, | |
810 | deleterow: function (rowid, commit) { | |
811 | commit(true); | |
812 | } | |
813 | }; | |
814 | var hopAdapter = new $.jqx.dataAdapter(hopSource); | |
815 | // dropdownlist datasource from inventory_hops | |
816 | var hopUrl = "gethopsources.php"; | |
817 | var hopInvSource = { | |
818 | datatype: "json", | |
819 | datafields: [ | |
820 | { name: 'record', type: 'number' }, | |
821 | { name: 'name', type: 'string' }, | |
822 | { name: 'origin', type: 'string' }, | |
823 | { name: 'type', type: 'string' }, | |
824 | { name: 'alpha', type: 'float' }, | |
825 | { name: 'beta', type: 'float' }, | |
826 | { name: 'humulene', type: 'float' }, | |
827 | { name: 'caryophyllene', type: 'float' }, | |
828 | { name: 'cohumulone', type: 'float' }, | |
829 | { name: 'myrcene', type: 'float' }, | |
830 | { name: 'hsi', type: 'float' }, | |
831 | { name: 'useat', type: 'string' }, | |
832 | { name: 'form', type: 'string' }, | |
833 | { name: 'total_oil', type: 'float' }, | |
834 | { name: 'cost', type: 'float' } | |
835 | ], | |
836 | url: hopUrl, | |
837 | async: true | |
838 | }; | |
839 | var hoplist = new $.jqx.dataAdapter(hopInvSource); | |
840 | ||
841 | $("#hopGrid").jqxGrid({ | |
842 | width: 960, | |
843 | height: 400, | |
844 | source: hopAdapter, | |
845 | theme: theme, | |
846 | selectionmode: 'singlerow', | |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
847 | editmode: 'selectedcell', |
68 | 848 | editable: true, |
849 | localization: getLocalization(), | |
850 | showtoolbar: true, | |
851 | rendertoolbar: function (toolbar) { | |
852 | var me = this; | |
853 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
854 | toolbar.append(container); | |
855 | container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); | |
856 | container.append('<input style="float: left; margin-left: 230px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); | |
857 | // add hop from dropdownlist. | |
858 | $("#haddrowbutton").jqxDropDownList({ | |
859 | placeHolder: "Kies hop:", | |
860 | theme: theme, | |
861 | source: hoplist, | |
862 | displayMember: "name", | |
863 | width: 150, | |
864 | height: 27, | |
69
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
68
diff
changeset
|
865 | dropDownWidth: 500, |
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
68
diff
changeset
|
866 | dropDownHeight: 500, |
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
68
diff
changeset
|
867 | renderer: function (index, label, value) { |
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
68
diff
changeset
|
868 | var datarecord = hoplist.records[index]; |
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
68
diff
changeset
|
869 | return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + "% α)"; |
ca25fdce3b85
Improved hop selection dropdown
Michiel Broek <mbroek@mbse.eu>
parents:
68
diff
changeset
|
870 | } |
68 | 871 | }); |
872 | $("#haddrowbutton").on('select', function (event) { | |
873 | if (event.args) { | |
874 | var index = event.args.index; | |
875 | var datarecord = hoplist.records[index]; | |
876 | var row = {}; | |
877 | row["h_name"] = datarecord.name; | |
878 | row["h_origin"] = datarecord.origin; | |
879 | row["h_amount"] = 0; | |
880 | row["h_cost"] = datarecord.cost; | |
881 | row["h_type"] = datarecord.type; | |
882 | row["h_form"] = datarecord.form; | |
883 | row["h_useat"] = datarecord.useat; | |
884 | row["h_time"] = 0; | |
885 | row["h_alpha"] = datarecord.alpha; | |
886 | row["h_beta"] = datarecord.beta; | |
887 | row["h_hsi"] = datarecord.hsi; | |
888 | row["h_humulene"] = datarecord.humulene; | |
889 | row["h_carophyllene"] = datarecord.carophyllene; | |
890 | row["h_cohumulone"] = datarecord.cohumulone; | |
891 | row["h_myrcene"] = datarecord.myrcene; | |
892 | row["h_total_oil"] = datarecord.total_oil; | |
893 | var commit = $("#hopGrid").jqxGrid('addrow', null, row); | |
894 | } | |
895 | }); | |
896 | ||
897 | // delete selected hop. | |
898 | $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
899 | $("#hdeleterowbutton").on('click', function () { | |
900 | var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); | |
901 | var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; | |
902 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
903 | var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); | |
904 | var commit = $("#hopGrid").jqxGrid('deleterow', id); | |
905 | } | |
906 | }); | |
907 | }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
908 | ready: function() { |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
909 | $('#jqxTabs').jqxTabs('next'); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
910 | }, |
68 | 911 | columns: [ |
912 | { text: 'Hop', editable: false, datafield: 'h_name' }, | |
913 | { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, | |
914 | { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, | |
131
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
915 | { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
916 | { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4', |
68 | 917 | columntype: 'numberinput', |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
918 | initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
131
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
919 | editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false }); |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
920 | }, |
68 | 921 | validation: function (cell, value) { |
922 | if (value < 0 || value > 100000000000 ) { | |
923 | return { result: false, message: "Volume moet 0-~ zijn" }; | |
924 | } | |
925 | return true; | |
926 | } | |
927 | }, | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
928 | { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist', |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
929 | createeditor: function (row, column, editor) { |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
930 | var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
931 | editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); |
131
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
932 | }, |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
933 | cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
934 | if ((newvalue == "Mash") || (newvalue == "First Wort")) { |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
935 | $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat($("#boil_time").jqxNumberInput('decimal'))); |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
936 | } else if (newvalue == "Aroma") { |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
937 | $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0); |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
938 | } |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
939 | } |
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
940 | }, |
68 | 941 | { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
942 | columntype: 'numberinput', | |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
943 | initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
944 | editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0 }); |
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
945 | }, |
131
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
946 | cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
947 | var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat"); |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
948 | if (use != "Boil") |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
949 | return oldvalue; |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
950 | }, |
68 | 951 | validation: function (cell, value) { |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
952 | var high = parseFloat($("#boil_time").jqxNumberInput('decimal')); |
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
953 | if (value < 0 || value > high ) { |
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
954 | return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
68 | 955 | } |
956 | return true; | |
132 | 957 | } |
68 | 958 | }, |
959 | { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', | |
960 | cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { | |
961 | var ibu = toIBU(rowdata.h_useat, | |
962 | rowdata.h_form, | |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
963 | preboil_sg, |
68 | 964 | parseFloat($("#batch_size").jqxNumberInput('decimal')), |
965 | parseFloat(rowdata.h_amount), | |
966 | parseFloat(rowdata.h_time), | |
967 | parseFloat(rowdata.h_alpha), | |
968 | $("#ibu_method").val() | |
969 | ); | |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
970 | calcIBUs(); |
68 | 971 | return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; |
972 | } | |
973 | } | |
974 | ] | |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
975 | }); |
131
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
976 | $("#hopGrid").on('cellendedit', function (event) { |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
977 | var args = event.args; |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
978 | console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
979 | $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
125
f2c79ed6423a
Fixes and improvements for hops editing and calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
99
diff
changeset
|
980 | // //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); |
131
71f1ca48c551
When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents:
130
diff
changeset
|
981 | }); |
68 | 982 | }; |
983 | ||
984 | // Inline miscs editor | |
985 | var editMisc = function (data) { | |
986 | var miscSource = { | |
987 | localdata: data.miscs, | |
988 | datatype: "local", | |
989 | cache: false, | |
990 | datafields: [ | |
991 | { name: 'm_name', type: 'string' }, | |
992 | { name: 'm_amount', type: 'float' }, | |
993 | { name: 'm_cost', type: 'float' }, | |
994 | { name: 'm_type', type: 'string' }, | |
995 | { name: 'm_use_use', type: 'string' }, | |
996 | { name: 'm_time', type: 'float' }, | |
997 | { name: 'm_amount_is_weight', type: 'bool' } | |
998 | ], | |
999 | addrow: function (rowid, rowdata, position, commit) { | |
1000 | commit(true); | |
1001 | }, | |
1002 | deleterow: function (rowid, commit) { | |
1003 | commit(true); | |
1004 | } | |
1005 | }; | |
1006 | var miscAdapter = new $.jqx.dataAdapter(miscSource); | |
1007 | // dropdownlist datasource from inventory_miscs | |
1008 | var miscUrl = "getmiscsources.php"; | |
1009 | var miscInvSource = { | |
1010 | datatype: "json", | |
1011 | datafields: [ | |
1012 | { name: 'record', type: 'number' }, | |
1013 | { name: 'name', type: 'string' }, | |
1014 | { name: 'type', type: 'string' }, | |
1015 | { name: 'use_use', type: 'string' }, | |
1016 | { name: 'amount_is_weight', type: 'bool' }, | |
1017 | { name: 'time', type: 'float' }, | |
1018 | { name: 'cost', type: 'float' } | |
1019 | ], | |
1020 | url: miscUrl, | |
1021 | async: true | |
1022 | }; | |
1023 | var misclist = new $.jqx.dataAdapter(miscInvSource); | |
1024 | ||
1025 | $("#miscGrid").jqxGrid({ | |
1026 | width: 960, | |
1027 | height: 400, | |
1028 | source: miscAdapter, | |
1029 | theme: theme, | |
1030 | selectionmode: 'singlerow', | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
1031 | editmode: 'selectedcell', |
68 | 1032 | editable: true, |
1033 | localization: getLocalization(), | |
1034 | showtoolbar: true, | |
1035 | rendertoolbar: function (toolbar) { | |
1036 | var me = this; | |
1037 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
1038 | toolbar.append(container); | |
1039 | container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); | |
1040 | container.append('<input style="float: left; margin-left: 230px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); | |
1041 | // add misc from dropdownlist. | |
1042 | $("#maddrowbutton").jqxDropDownList({ | |
1043 | placeHolder: "Kies ingredient:", | |
1044 | theme: theme, | |
1045 | source: misclist, | |
1046 | displayMember: "name", | |
1047 | width: 150, | |
1048 | height: 27, | |
1049 | dropDownWidth: 300 | |
1050 | }); | |
1051 | $("#maddrowbutton").on('select', function (event) { | |
1052 | if (event.args) { | |
1053 | var index = event.args.index; | |
1054 | var datarecord = misclist.records[index]; | |
1055 | var row = {}; | |
1056 | row["m_name"] = datarecord.name; | |
1057 | row["m_amount"] = 0; | |
1058 | row["m_cost"] = datarecord.cost; | |
1059 | row["m_type"] = datarecord.type; | |
1060 | row["m_use_use"] = datarecord.use_use; | |
1061 | row["m_time"] = 0; | |
1062 | row["m_amount_is_weight"] = datarecord.amount_is_weight; | |
1063 | var commit = $("#miscGrid").jqxGrid('addrow', null, row); | |
1064 | } | |
1065 | }); | |
1066 | // delete selected misc. | |
1067 | $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
1068 | $("#mdeleterowbutton").on('click', function () { | |
1069 | var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); | |
1070 | var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; | |
1071 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
1072 | var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); | |
1073 | var commit = $("#miscGrid").jqxGrid('deleterow', id); | |
1074 | } | |
1075 | }); | |
1076 | }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1077 | ready: function() { |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1078 | $('#jqxTabs').jqxTabs('next'); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1079 | }, |
68 | 1080 | columns: [ |
1081 | { text: 'Ingredient', editable: false, datafield: 'm_name' }, | |
1082 | { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, | |
1083 | { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' }, | |
1084 | { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', | |
1085 | columntype: 'numberinput', | |
1086 | validation: function (cell, value) { | |
1087 | if (value < 0 || value > 100000000000 ) { | |
1088 | return { result: false, message: "Volume moet 0-~ zijn" }; | |
1089 | } | |
1090 | return true; | |
1091 | } | |
1092 | }, | |
1093 | { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', | |
1094 | columntype: 'numberinput', | |
1095 | validation: function (cell, value) { | |
1096 | if (value < 0 || value > 100000000000 ) { | |
1097 | return { result: false, message: "De tijd moet 0-~ zijn" }; | |
1098 | } | |
1099 | return true; | |
1100 | } | |
1101 | } | |
1102 | ] | |
1103 | }) | |
1104 | }; | |
1105 | ||
1106 | // Inline yeasts editor | |
1107 | var editYeast = function (data) { | |
1108 | var yeastSource = { | |
1109 | localdata: data.yeasts, | |
1110 | datatype: "local", | |
1111 | cache: false, | |
1112 | datafields: [ | |
1113 | { name: 'y_name', type: 'string' }, | |
1114 | { name: 'y_laboratory', type: 'string' }, | |
1115 | { name: 'y_product_id', type: 'string' }, | |
1116 | { name: 'y_amount', type: 'float' }, | |
1117 | { name: 'y_cost', type: 'float' }, | |
1118 | { name: 'y_type', type: 'string' }, | |
1119 | { name: 'y_form', type: 'string' }, | |
1120 | { name: 'y_time', type: 'float' }, | |
1121 | { name: 'y_min_temperature', type: 'float' }, | |
1122 | { name: 'y_max_temperature', type: 'float' }, | |
1123 | { name: 'y_attenuation', type: 'float' }, | |
1124 | { name: 'y_amount_is_weight', type: 'bool' }, | |
1125 | { name: 'y_use', type: 'string' } | |
1126 | ], | |
1127 | addrow: function (rowid, rowdata, position, commit) { | |
1128 | commit(true); | |
1129 | }, | |
1130 | deleterow: function (rowid, commit) { | |
1131 | commit(true); | |
1132 | } | |
1133 | }; | |
1134 | var yeastAdapter = new $.jqx.dataAdapter(yeastSource); | |
1135 | // dropdownlist datasource from inventory_yeasts | |
1136 | var yeastUrl = "getyeastsources.php"; | |
1137 | var yeastInvSource = { | |
1138 | datatype: "json", | |
1139 | datafields: [ | |
1140 | { name: 'record', type: 'number' }, | |
1141 | { name: 'name', type: 'string' }, | |
1142 | { name: 'type', type: 'string' }, | |
1143 | { name: 'form', type: 'string' }, | |
1144 | { name: 'laboratory', type: 'string' }, | |
1145 | { name: 'product_id', type: 'string' }, | |
1146 | { name: 'min_temperature', type: 'float' }, | |
1147 | { name: 'max_temperature', type: 'float' }, | |
1148 | { name: 'attenuation', type: 'float' }, | |
1149 | { name: 'cost', type: 'float' } | |
1150 | ], | |
1151 | url: yeastUrl, | |
1152 | async: true | |
1153 | }; | |
1154 | var yeastlist = new $.jqx.dataAdapter(yeastInvSource); | |
1155 | ||
1156 | $("#yeastGrid").jqxGrid({ | |
1157 | width: 1050, | |
1158 | height: 300, | |
1159 | source: yeastAdapter, | |
1160 | theme: theme, | |
1161 | selectionmode: 'singlerow', | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
1162 | editmode: 'selectedcell', |
68 | 1163 | editable: true, |
1164 | localization: getLocalization(), | |
1165 | showtoolbar: true, | |
1166 | rendertoolbar: function (toolbar) { | |
1167 | var me = this; | |
1168 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
1169 | toolbar.append(container); | |
1170 | container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); | |
1171 | container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); | |
1172 | // add yeast from dropdownlist. | |
1173 | $("#yaddrowbutton").jqxDropDownList({ | |
1174 | placeHolder: "Kies gist:", | |
1175 | theme: theme, | |
1176 | source: yeastlist, | |
1177 | displayMember: "name", | |
1178 | width: 150, | |
1179 | height: 27, | |
1180 | dropDownWidth: 300 | |
1181 | }); | |
1182 | $("#yaddrowbutton").on('select', function (event) { | |
1183 | if (event.args) { | |
1184 | var index = event.args.index; | |
1185 | var datarecord = yeastlist.records[index]; | |
1186 | var row = {}; | |
1187 | row["y_name"] = datarecord.name; | |
1188 | row["y_laboratory"] = datarecord.laboratory; | |
1189 | row["y_product_id"] = datarecord.product_id; | |
1190 | row["y_type"] = datarecord.type; | |
1191 | row["y_form"] = datarecord.form; | |
1192 | row["y_amount"] = 0; | |
1193 | row["y_cost"] = datarecord.cost; | |
1194 | row["y_use"] = "Primary"; | |
1195 | row["y_time"] = 0; | |
1196 | if (datarecord.form == "Dry") { | |
1197 | row["y_amount_is_weight"] = 1; | |
1198 | } else { | |
1199 | row["y_amount_is_weight"] = 0; | |
1200 | } | |
1201 | row["y_min_temperature"] = datarecord.min_temperature; | |
1202 | row["y_max_temperature"] = datarecord.max_temperature; | |
1203 | row["y_attenuation"] = datarecord.attenuation; | |
1204 | var commit = $("#yeastGrid").jqxGrid('addrow', null, row); | |
1205 | } | |
1206 | }); | |
1207 | // delete selected yeast. | |
1208 | $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
1209 | $("#ydeleterowbutton").on('click', function () { | |
1210 | var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); | |
1211 | var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; | |
1212 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
1213 | var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); | |
1214 | var commit = $("#yeastGrid").jqxGrid('deleterow', id); | |
1215 | } | |
1216 | }); | |
1217 | }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1218 | ready: function() { |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
1219 | calcSVG(); |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1220 | $('#jqxTabs').jqxTabs('next'); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1221 | }, |
68 | 1222 | columns: [ |
1223 | { text: 'Gist', editable: false, datafield: 'y_name' }, | |
1224 | { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, | |
1225 | { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, | |
1226 | { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, | |
1227 | { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, | |
1228 | { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, | |
1229 | { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, | |
1230 | { text: 'Voor', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_use' }, | |
1231 | { text: 'Hoeveel', datafield: 'y_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', | |
1232 | columntype: 'numberinput', | |
1233 | validation: function (cell, value) { | |
1234 | if (value < 0 || value > 100000000000 ) { | |
1235 | return { result: false, message: "Volume moet 0-~ zijn" }; | |
1236 | } | |
1237 | return true; | |
1238 | } | |
1239 | } | |
1240 | ] | |
1241 | }) | |
1242 | }; | |
1243 | ||
1244 | // Inline waters editor | |
1245 | var editWater = function (data) { | |
1246 | var waterSource = { | |
1247 | localdata: data.waters, | |
1248 | datatype: "local", | |
1249 | datafields: [ | |
1250 | { name: 'w_name', type: 'string' }, | |
1251 | { name: 'w_amount', type: 'float' }, | |
1252 | { name: 'w_calcium', type: 'float' }, | |
1253 | { name: 'w_sulfate', type: 'float' }, | |
1254 | { name: 'w_chloride', type: 'float' }, | |
1255 | { name: 'w_sodium', type: 'float' }, | |
1256 | { name: 'w_magnesium', type: 'float' }, | |
1257 | { name: 'w_ph', type: 'float' }, | |
1258 | { name: 'w_total_alkalinity', type: 'float' }, | |
1259 | { name: 'w_cost', type: 'float' }, | |
1260 | ], | |
1261 | addrow: function (rowid, rowdata, position, commit) { | |
1262 | commit(true); | |
1263 | }, | |
1264 | deleterow: function (rowid, commit) { | |
1265 | commit(true); | |
1266 | } | |
1267 | }; | |
1268 | var waterAdapter = new $.jqx.dataAdapter(waterSource); | |
1269 | // dropdownlist datasource from inventory_waters | |
1270 | var waterUrl = "getwatersources.php"; | |
1271 | var waterInvSource = { | |
1272 | datatype: "json", | |
1273 | datafields: [ | |
1274 | { name: 'record', type: 'number' }, | |
1275 | { name: 'name', type: 'string' }, | |
1276 | { name: 'unlimited_stock', type: 'bool' }, | |
1277 | { name: 'calcium', type: 'float' }, | |
1278 | { name: 'sulfate', type: 'float' }, | |
1279 | { name: 'chloride', type: 'float' }, | |
1280 | { name: 'sodium', type: 'float' }, | |
1281 | { name: 'magnesium', type: 'float' }, | |
1282 | { name: 'ph', type: 'float' }, | |
1283 | { name: 'total_alkalinity', type: 'float' }, | |
1284 | { name: 'cost', type: 'float' }, | |
1285 | ], | |
1286 | url: waterUrl, | |
1287 | async: true | |
1288 | }; | |
1289 | var waterlist = new $.jqx.dataAdapter(waterInvSource); | |
1290 | ||
1291 | $("#waterGrid").jqxGrid({ | |
1292 | width: 960, | |
1293 | height: 200, | |
1294 | source: waterAdapter, | |
1295 | theme: theme, | |
1296 | selectionmode: 'singlerow', | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
1297 | editmode: 'selectedcell', |
68 | 1298 | editable: true, |
1299 | localization: getLocalization(), | |
1300 | showtoolbar: true, | |
1301 | rendertoolbar: function (toolbar) { | |
1302 | var me = this; | |
1303 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
1304 | toolbar.append(container); | |
1305 | container.append('<div style="float: left; margin-left: 165px;" id="waddrowbutton"></div>'); | |
1306 | container.append('<input style="float: left; margin-left: 230px;" id="wdeleterowbutton" type="button" value="Verwijder water" />'); | |
1307 | // add water from dropdownlist. | |
1308 | $("#waddrowbutton").jqxDropDownList({ | |
1309 | placeHolder: "Kies water:", | |
1310 | theme: theme, | |
1311 | source: waterlist, | |
1312 | displayMember: "name", | |
1313 | width: 150, | |
1314 | height: 27, | |
1315 | dropDownWidth: 300 | |
1316 | }); | |
1317 | $("#waddrowbutton").on('select', function (event) { | |
1318 | if (event.args) { | |
1319 | var index = event.args.index; | |
1320 | var datarecord = waterlist.records[index]; | |
1321 | var row = {}; | |
1322 | row["w_name"] = datarecord.name; | |
1323 | row["w_amount"] = 0; | |
1324 | row["w_calcium"] = datarecord.calcium; | |
1325 | row["w_sulfate"] = datarecord.sulfate; | |
1326 | row["w_chloride"] = datarecord.chloride; | |
1327 | row["w_sodium"] = datarecord.sodium; | |
1328 | row["w_magnesium"] = datarecord.magnesium; | |
1329 | row["w_ph"] = datarecord.ph; | |
1330 | row["w_total_alkalinity"] = datarecord.total_alkalinity; | |
1331 | row["w_cost"] = datarecord.cost; | |
1332 | var commit = $("#waterGrid").jqxGrid('addrow', null, row); | |
1333 | } | |
1334 | }); | |
1335 | ||
1336 | // delete selected water. | |
1337 | // Overgebleven waters in volume verhogen met het verwijderde water. | |
1338 | $("#wdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
1339 | $("#wdeleterowbutton").on('click', function () { | |
1340 | var selectedrowindex = $("#waterGrid").jqxGrid('getselectedrowindex'); | |
1341 | var rowscount = $("#waterGrid").jqxGrid('getdatainformation').rowscount; | |
1342 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
1343 | var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex); | |
1344 | var commit = $("#waterGrid").jqxGrid('deleterow', id); | |
1345 | } | |
1346 | }); | |
1347 | }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1348 | ready: function() { |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1349 | $('#jqxTabs').jqxTabs('next'); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1350 | }, |
68 | 1351 | columns: [ |
1352 | { text: 'Water bron', editable: false, datafield: 'w_name' }, | |
1353 | { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', | |
1354 | columntype: 'numberinput', | |
1355 | validation: function (cell, value) { | |
1356 | if (value < 0 || value > 100000000000 ) { | |
1357 | return { result: false, message: "Volume moet 0-~ zijn" }; | |
1358 | } | |
1359 | return true; | |
1360 | } | |
1361 | }, | |
1362 | // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal. | |
1363 | { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1364 | { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1365 | { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1366 | { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1367 | { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1368 | { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, | |
1369 | { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } | |
1370 | ] | |
1371 | }); | |
1372 | }; // editWater = function (data) { | |
1373 | ||
1374 | // inline mash editor | |
1375 | var editMash = function (data) { | |
1376 | var generaterow = function () { | |
1377 | var row = {}; | |
1378 | row["step_name"] = "Stap 1"; | |
1379 | row["step_type"] = "Infusion"; | |
1380 | row["step_infuse_amount"] = 15; | |
1381 | row["step_temp"] = 62.0; | |
1382 | row['step_time'] = 20.0; | |
1383 | row['ramp_time'] = 1.0; | |
1384 | row['end_temp'] = 62.0; | |
1385 | return row; | |
1386 | } | |
1387 | var mashSource = { | |
1388 | localdata: data.mashs, | |
1389 | datatype: "local", | |
1390 | cache: false, | |
1391 | datafields: [ | |
1392 | { name: 'step_name', type: 'string' }, | |
1393 | { name: 'step_type', type: 'string' }, | |
1394 | { name: 'step_infuse_amount', type: 'float' }, | |
1395 | { name: 'step_temp', type: 'float' }, | |
1396 | { name: 'step_time', type: 'float' }, | |
1397 | { name: 'ramp_time', type: 'float' }, | |
1398 | { name: 'end_temp', type: 'float' } | |
1399 | ], | |
1400 | addrow: function (rowid, rowdata, position, commit) { | |
1401 | commit(true); | |
1402 | }, | |
1403 | deleterow: function (rowid, commit) { | |
1404 | commit(true); | |
1405 | } | |
1406 | }; | |
1407 | var mashAdapter = new $.jqx.dataAdapter(mashSource); | |
1408 | // dropdownlist datasource from profile_mash | |
1409 | var mashUrl = "include/db_profile_mash.php"; | |
1410 | var mashInvSource = { | |
1411 | datatype: "json", | |
1412 | datafields: [ | |
1413 | { name: 'record', type: 'number' }, | |
1414 | { name: 'name', type: 'string' }, | |
1415 | { name: 'steps', type: 'array' } | |
1416 | ], | |
1417 | url: mashUrl, | |
1418 | async: true | |
1419 | }; | |
1420 | var mashlist = new $.jqx.dataAdapter(mashInvSource); | |
1421 | ||
1422 | $("#mashGrid").jqxGrid({ | |
1423 | width: 960, | |
1424 | height: 400, | |
1425 | source: mashAdapter, | |
1426 | theme: theme, | |
1427 | selectionmode: 'singlerow', | |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
125
diff
changeset
|
1428 | editmode: 'selectedcell', |
68 | 1429 | editable: true, |
1430 | localization: getLocalization(), | |
1431 | showtoolbar: true, | |
1432 | rendertoolbar: function (toolbar) { | |
1433 | var me = this; | |
1434 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
1435 | toolbar.append(container); | |
1436 | container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); | |
1437 | container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); | |
1438 | $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
1439 | $("#saddrowbutton").on('click', function () { | |
1440 | var datarow = generaterow(); | |
1441 | var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); | |
1442 | }); | |
1443 | // delete selected yeast. | |
1444 | $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); | |
1445 | $("#sdeleterowbutton").on('click', function () { | |
1446 | var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); | |
1447 | var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; | |
1448 | if (selectedrowindex >= 0 && selectedrowindex < rowscount) { | |
1449 | var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); | |
1450 | var commit = $("#mashGrid").jqxGrid('deleterow', id); | |
1451 | } | |
1452 | }); | |
1453 | }, | |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1454 | ready: function() { |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
135
diff
changeset
|
1455 | var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal')))); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
1456 | calcInit(); |
129
7f41b61c3faf
Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
128
diff
changeset
|
1457 | $('#jqxLoader').jqxLoader('close'); |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1458 | $('#jqxTabs').jqxTabs('first'); |
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
95
diff
changeset
|
1459 | }, |
68 | 1460 | columns: [ |
1461 | { text: 'Stap naam', datafield: 'step_name' }, | |
1462 | { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', | |
1463 | createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { | |
1464 | var dataSource = [ "Infusion", "Temperature", "Decoction" ]; | |
1465 | editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 }); | |
1466 | } | |
1467 | }, | |
1468 | { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', | |
1469 | validation: function (cell, value) { | |
1470 | if (value < 35 || value > 80) { | |
1471 | return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; | |
1472 | } | |
1473 | return true; | |
1474 | } | |
1475 | }, | |
1476 | { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', | |
1477 | validation: function (cell, value) { | |
1478 | if (value < 35 || value > 80) { | |
1479 | return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; | |
1480 | } | |
1481 | return true; | |
1482 | } | |
1483 | }, | |
1484 | { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', | |
1485 | validation: function (cell, value) { | |
1486 | if (value < 1 || value > 360) { | |
1487 | return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; | |
1488 | } | |
1489 | return true; | |
1490 | } | |
1491 | }, | |
1492 | { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', | |
1493 | validation: function (cell, value) { | |
1494 | if (value < 1 || value > 60) { | |
1495 | return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; | |
1496 | } | |
1497 | return true; | |
1498 | } | |
1499 | }, | |
1500 | { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right', | |
1501 | validation: function (cell, value) { | |
1502 | if (value < 0 || value > 60) { | |
1503 | return { result: false, message: "De waarde moet tussen 0 en 60 zijn." }; | |
1504 | } | |
1505 | return true; | |
1506 | } | |
1507 | } | |
1508 | ] | |
1509 | }); | |
1510 | $("#mashGrid").on('cellendedit', function (event) { | |
1511 | $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc'); | |
1512 | }); | |
1513 | }; | |
1514 | ||
1515 | // initialize the input fields. | |
1516 | var srcType = [ "All Grain", "Partial Mash", "Extract" ]; | |
1517 | var srcColor = [ "Morey", "Mosher", "Daniels" ]; | |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
1518 | //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
1519 | var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. |
68 | 1520 | $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
1521 | $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); | |
1522 | $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); | |
1523 | $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); | |
1524 | $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1525 | $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1526 | $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1527 | $("#st_type").jqxInput({ theme: theme, width: 90, height: 23 }); |
68 | 1528 | $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); |
1529 | $("#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' }); | |
135
cd1403633e96
Added boil time change logic. Better precision.
Michiel Broek <mbroek@mbse.eu>
parents:
134
diff
changeset
|
1530 | $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' }); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1531 | $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
68 | 1532 | $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
133
22d28dd9c041
Added ABV calculation. Added calculate fermentables from OG calculation. Scale fermentables when the OG changes.
Michiel Broek <mbroek@mbse.eu>
parents:
132
diff
changeset
|
1533 | $("#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 }); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1534 | $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
68 | 1535 | $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1536 | |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1537 | $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1538 | $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1539 | $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1540 | |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1541 | $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1542 | $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1543 | $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1544 | |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1545 | $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1546 | $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1547 | $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
68 | 1548 | $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1549 | |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1550 | $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1551 | $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1552 | $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
98
92d6bc8a4cdd
Added javascript formulas for color calculations. Added IBU total calculation. Better IBI calculation for the hop entries. Blocked selection of IBU calculation for Garetz, Mosher and Noonan. Better sg calculation in the recipe print.
Michiel Broek <mbroek@mbse.eu>
parents:
97
diff
changeset
|
1553 | $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' }); |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1554 | |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1555 | $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1556 | $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1557 | $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1558 | |
68 | 1559 | $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
1560 | $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); | |
1561 | $("#mash_sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); | |
1562 | ||
1563 | // Tabs inside the popup window. | |
1564 | $('#jqxTabs').jqxTabs({ | |
1565 | theme: theme, | |
1566 | width: 1280, | |
1567 | height: 630, | |
1568 | autoHeight: false, | |
1569 | position: 'top' | |
1570 | }); | |
1571 | ||
79 | 1572 | $("#Print").jqxButton({ template: "info", width: '80px', theme: theme }); |
1573 | $("#Print").click(function () { | |
1574 | // Open print in a new tab. | |
1575 | var url="rec_print.php?record=" + my_record; | |
1576 | window.open(url); | |
1577 | }); | |
1578 | ||
68 | 1579 | $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); |
1580 | $("#Delete").click(function () { | |
1581 | // Open a popup to confirm this action. | |
1582 | $('#eventWindow').jqxWindow('open'); | |
1583 | $("#delOk").click(function () { | |
1584 | var data = "delete=true&" + $.param({ record: my_record }); | |
1585 | $.ajax({ | |
1586 | dataType: 'json', | |
1587 | url: url, | |
1588 | cache: false, | |
1589 | data: data, | |
1590 | type: "POST", | |
1591 | success: function (data, status, xhr) { | |
1592 | // delete command is executed. | |
1593 | window.location.href = my_return; | |
1594 | }, | |
1595 | error: function (jqXHR, textStatus, errorThrown) { | |
1596 | } | |
1597 | }); | |
1598 | }); | |
1599 | }); | |
1600 | ||
1601 | $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme }); | |
1602 | $("#Cancel").click(function () { | |
1603 | window.location.href = my_return; | |
1604 | }); | |
1605 | ||
1606 | $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); | |
1607 | $("#Save").click(function () { | |
1608 | var fermentablerow = $('#fermentableGrid').jqxGrid('getrows'); | |
1609 | var hoprow = $('#hopGrid').jqxGrid('getrows'); | |
1610 | var miscrow = $('#miscGrid').jqxGrid('getrows'); | |
1611 | var yeastrow = $('#yeastGrid').jqxGrid('getrows'); | |
1612 | var waterrow = $('#waterGrid').jqxGrid('getrows'); | |
1613 | var mashrow = $('#mashGrid').jqxGrid('getrows'); | |
1614 | var row = { | |
1615 | record: my_record, | |
1616 | name: $("#name").val(), | |
1617 | notes: $("#notes").val(), | |
1618 | st_name: $('#st_name').val(), | |
1619 | st_letter: $('#st_letter').val(), | |
1620 | st_guide: $('#st_guide').val(), | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1621 | st_type: $('#st_type').val(), |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1622 | st_category: $('#st_category').val(), |
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1623 | st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')), |
73
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1624 | st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1625 | st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1626 | st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1627 | st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1628 | st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1629 | st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1630 | st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1631 | st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1632 | st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1633 | st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1634 | st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')), |
454fc4558609
Added style selector in recipe editer. Better formatting of cellsrenderer fields. Added When field to the fermentables list. Attempts to calculate the fermentables.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
1635 | st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')), |
68 | 1636 | type: $("#type").val(), |
1637 | batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), | |
95 | 1638 | boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), |
68 | 1639 | boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
1640 | efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), | |
1641 | est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), | |
1642 | est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1643 | est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')), |
68 | 1644 | est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), |
1645 | color_method: $("#color_method").val(), | |
1646 | est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), | |
1647 | ibu_method: $("#ibu_method").val(), | |
72
93a0be4f5be3
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents:
71
diff
changeset
|
1648 | est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')), |
68 | 1649 | mash_name: $("#mash_name").val(), |
1650 | mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), | |
1651 | mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), | |
1652 | fermentables: fermentablerow, | |
1653 | hops: hoprow, | |
1654 | miscs: miscrow, | |
1655 | yeasts: yeastrow, | |
1656 | waters: waterrow, | |
1657 | mashs: mashrow | |
1658 | }; | |
1659 | var data = "update=true&" + $.param(row); | |
1660 | $.ajax({ | |
1661 | dataType: 'json', | |
1662 | url: url, | |
1663 | cache: false, | |
1664 | data: data, | |
1665 | type: "POST", | |
1666 | success: function (data, status, xhr) { | |
1667 | // update command is executed. | |
1668 | window.location.href = my_return; | |
1669 | }, | |
1670 | error: function(jqXHR, textStatus, errorThrown) { | |
1671 | } | |
1672 | }); | |
1673 | }); | |
1674 | createDelElements(); | |
1675 | }); | |
1676 |