www/js/rec_new.js

changeset 232
daf2d9d6fa18
parent 170
71850ebe5a1c
child 240
a85c1d4c4d12
equal deleted inserted replaced
231:9881453a49b3 232:daf2d9d6fa18
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 $(document).ready(function () { 24 $(document).ready(function () {
25 25
26 // tooltips 26 var recipe_type = 2;
27 var style_type = 0;
28
29 // Tab 1, Base
27 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); 30 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' });
31 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
28 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); 32 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' });
29 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
30
31 // editers
32 var srcType = [ "All Grain", "Partial Mash", "Extract" ];
33 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
34 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); 33 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
35 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); 34 $("#type").jqxDropDownList({
36 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); 35 theme: theme,
37 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); 36 source: RecipeTypeAdapter,
38 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.010, max: 1.2, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 37 valueMember: 'id',
39 38 displayMember: 'nl',
39 width: 180,
40 height: 23,
41 autoDropDownHeight: true
42 });
43 $("#type").jqxDropDownList('selectItem', 2);
44 $("#type").on('select', function (event) {
45 if (event.args) {
46 recipe_type = event.args.index;
47 }
48 });
49 $("#boil_time").jqxNumberInput( PosInt );
50 $("#boil_time").jqxNumberInput({ min: 4, max: 360 });
51 $("#efficiency").jqxNumberInput( Perc0 );
52 $("#est_og").jqxNumberInput( SGopts );
53 // Default values.
54 $("#boil_time").val(90);
55 $("#efficiency").val(75);
56 $("#est_og").val(1.052);
57
58 // Tab 2, Style
40 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); 59 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
41 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); 60 $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 });
42 $("#st_category_number").jqxInput({ theme: theme, width: 70, height: 23 }); 61 $("#st_category_number").jqxInput({ theme: theme, width: 70, height: 23 });
43 $("#st_style_letter").jqxInput({ theme: theme, width: 250, height: 23 }); 62 $("#st_style_letter").jqxInput({ theme: theme, width: 250, height: 23 });
44 $("#st_style_guide").jqxInput({ theme: theme, width: 250, height: 23 }); 63 $("#st_style_guide").jqxInput({ theme: theme, width: 250, height: 23 });
45 $("#st_notes").jqxInput({ theme: theme, width: 800, height: 100 }); 64 $("#st_notes").jqxInput({ theme: theme, width: 800, height: 100 });
46 $("#st_type").jqxInput({ theme: theme, width: 90, height: 23 }); 65 $("#st_type").jqxInput({ theme: theme, width: 250, height: 23 });
47 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 66 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
48 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 67 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
49 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 68 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
50 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); 69 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
51 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 70 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
58 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 77 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
59 $("#st_profile").jqxInput({ theme: theme, width: 800, height: 48 }); 78 $("#st_profile").jqxInput({ theme: theme, width: 800, height: 48 });
60 $("#st_ingredients").jqxInput({ theme: theme, width: 800, height: 23 }); 79 $("#st_ingredients").jqxInput({ theme: theme, width: 800, height: 23 });
61 $("#st_examples").jqxInput({ theme: theme, width: 800, height: 48 }); 80 $("#st_examples").jqxInput({ theme: theme, width: 800, height: 48 });
62 81
63 // Default values.
64 $("#type").val('All Grain');
65 $("#boil_time").val(90);
66 $("#efficiency").val(75);
67 $("#est_og").val(1.052);
68
69 $("#styleSelect").jqxDropDownList({ 82 $("#styleSelect").jqxDropDownList({
70 placeHolder: "Kies bierstijl:", 83 placeHolder: "Kies bierstijl:",
71 theme: theme, 84 theme: theme,
72 source: styleslist, 85 source: styleslist,
73 displayMember: "name", 86 displayMember: "name",
74 width: 150, 87 width: 250,
75 height: 27, 88 height: 27,
76 dropDownWidth: 500, 89 dropDownWidth: 500,
77 dropDownHeight: 500, 90 dropDownHeight: 500,
78 renderer: function (index, label, value) { 91 renderer: function (index, label, value) {
79 var datarecord = styleslist.records[index]; 92 var datarecord = styleslist.records[index];
87 $("#st_name").val(datarecord.name); 100 $("#st_name").val(datarecord.name);
88 $("#st_category").val(datarecord.category); 101 $("#st_category").val(datarecord.category);
89 $("#st_category_number").val(datarecord.category_number); 102 $("#st_category_number").val(datarecord.category_number);
90 $("#st_style_letter").val(datarecord.style_letter); 103 $("#st_style_letter").val(datarecord.style_letter);
91 $("#st_style_guide").val(datarecord.style_guide); 104 $("#st_style_guide").val(datarecord.style_guide);
92 $("#st_type").val(datarecord.type); 105 style_type = datarecord.type;
106 $("#st_type").val(StyleTypeData[datarecord.type].nl);
93 $("#st_og_min").val(datarecord.og_min); 107 $("#st_og_min").val(datarecord.og_min);
94 $("#st_og_max").val(datarecord.og_max); 108 $("#st_og_max").val(datarecord.og_max);
95 $("#st_fg_min").val(datarecord.fg_min); 109 $("#st_fg_min").val(datarecord.fg_min);
96 $("#st_fg_max").val(datarecord.fg_max); 110 $("#st_fg_max").val(datarecord.fg_max);
97 $("#st_ibu_min").val(datarecord.ibu_min); 111 $("#st_ibu_min").val(datarecord.ibu_min);
122 $('#styleSelect').on('change', function (event) { wizard.validate(true); }); 136 $('#styleSelect').on('change', function (event) { wizard.validate(true); });
123 $('#nextButtonCompleted').click(function () { 137 $('#nextButtonCompleted').click(function () {
124 console.log("insert start"); 138 console.log("insert start");
125 var newrow = { 139 var newrow = {
126 record: -1, 140 record: -1,
141 locked: 0,
127 name: $("#name").val(), 142 name: $("#name").val(),
128 notes: $("#notes").val(), 143 notes: $("#notes").val(),
129 st_name: $('#st_name').val(), 144 st_name: $('#st_name').val(),
130 st_letter: $('#st_style_letter').val(), 145 st_letter: $('#st_style_letter').val(),
131 st_guide: $('#st_style_guide').val(), 146 st_guide: $('#st_style_guide').val(),
132 st_category: $('#st_category').val(), 147 st_category: $('#st_category').val(),
133 st_category_number: parseFloat($('#st_category_number').jqxNumberInput('decimal')), 148 st_category_number: parseFloat($('#st_category_number').jqxNumberInput('decimal')),
134 st_type: $("#st_type").val(), 149 st_type: style_type,
135 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')), 150 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
136 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')), 151 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
137 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')), 152 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
138 st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')), 153 st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
139 st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')), 154 st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
142 st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')), 157 st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
143 st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')), 158 st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
144 st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')), 159 st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
145 st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')), 160 st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
146 st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')), 161 st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
147 type: $("#type").val(), 162 type: recipe_type,
148 batch_size: 20.0, 163 batch_size: 20.0,
149 boil_size: 22.0, 164 boil_size: 22.0,
150 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), 165 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
151 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), 166 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
152 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), 167 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
153 est_fg: 1.000, 168 est_fg: 1.000,
154 est_color: 0, 169 est_color: 0,
155 est_abv: 0.0, 170 est_abv: 0.0,
156 est_carb: 0.0, 171 est_carb: 0.0,
157 color_method: "Morey", 172 color_method: 0, // Morey
158 est_ibu: 0, 173 est_ibu: 0,
159 ibu_method: "Tinseth", 174 ibu_method: 0, // Tinseth
160 mash_name: "", 175 mash_name: "",
161 mash_ph: 5.4, 176 mash_ph: 5.4,
162 sparge_temp: 78.0, 177 sparge_temp: 85.0,
163 sparge_volume: 12.0, 178 sparge_volume: 12.0,
164 sparge_ph: 5.8, 179 sparge_ph: 5.8,
165 sparge_source: 'Bron 1', 180 sparge_source: 0, // Source 1
166 sparge_acid_type: 'Melkzuur', 181 sparge_acid_type: 0, // Lactic acid
167 sparge_acid_perc: 80, 182 sparge_acid_perc: 80,
168 sparge_acid_amount: 0, 183 sparge_acid_amount: 0,
169 calc_acid: true 184 calc_acid: true,
185 w1_name: 'Tap water',
186 w1_amount: 15,
187 w1_calcium: 0,
188 w1_sulfate: 0,
189 w1_chloride: 0,
190 w1_sodium: 0,
191 w1_magnesium: 0,
192 w1_total_alkalinity: 0,
193 w1_ph: 7.0,
194 w1_cost: 0.0,
195 wa_acid_name: 0, // Lactic acid
196 wa_acid_perc: 80,
197 wa_base_name: 0
170 }; 198 };
171 var data = "insert=true&return=" + my_return + "&" + $.param(newrow); 199 var data = "insert=true&return=" + my_return + "&" + $.param(newrow);
172 $.ajax({ 200 $.ajax({
173 dataType: 'json', 201 dataType: 'json',
174 url: "includes/db_recipes.php", 202 url: "includes/db_recipes.php",

mercurial