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