82 psugar += row.f_percentage; |
102 psugar += row.f_percentage; |
83 if (row.f_graintype == "Crystal") |
103 if (row.f_graintype == "Crystal") |
84 pcara += row.f_percentage; |
104 pcara += row.f_percentage; |
85 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
105 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
86 if (row.f_added == "Mash") { |
106 if (row.f_added == "Mash") { |
87 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d; |
107 d = parseFloat(dataRecord.efficiency) / 100 * d; |
88 sugarsm += d; |
108 sugarsm += d; |
|
109 mashkg += row.f_amount; |
89 } |
110 } |
90 sugarsf += d; |
111 sugarsf += d; |
91 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat($("#batch_size").jqxNumberInput('decimal')) * 8.34436; |
112 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436; |
92 } |
113 } |
93 if (to_100 != my_100) |
|
94 console.log("change to_100 to:"+my_100); |
|
95 to_100 = my_100; |
114 to_100 = my_100; |
96 var est_og = estimate_sg(sugarsf, parseFloat($("#batch_size").jqxNumberInput('decimal'))); |
115 var est_og = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size)); |
97 $('#est_og').val(est_og); |
116 $('#est_og').val(est_og); |
98 $('#est_og2').val(est_og); |
117 $('#est_og2').val(est_og); |
99 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
118 preboil_sg = estimate_sg(sugarsm, dataRecord.boil_size); |
100 var color = kw_to_ebc($("#color_method").val(), colorw); |
119 var color = kw_to_ebc(dataRecord.color_method, colorw); |
101 $('#est_color').val(color); |
120 $('#est_color').val(color); |
102 $('#est_color2').val(color); |
121 $('#est_color2').val(color); |
103 var scolor = ebc_to_color(color); |
122 var scolor = ebc_to_color(color); |
104 document.getElementById("bcolor").style.background= scolor; |
123 document.getElementById("bcolor").style.background= scolor; |
105 document.getElementById("bcolor2").style.background= scolor; |
124 document.getElementById("bcolor2").style.background= scolor; |
|
125 // Use boil_size instead of mash_max from equipment. |
|
126 pmalts = mashkg / (dataRecord.boil_size / 3) * 100; |
|
127 $("#perc_malts").jqxProgressBar('val', pmalts); |
|
128 $("#perc_sugars").jqxProgressBar('val', psugar); |
|
129 $("#perc_cara").jqxProgressBar('val', pcara); |
106 }; |
130 }; |
107 |
131 |
108 function hopFlavourContribution(bt, vol, use, amount) { |
132 function hopFlavourContribution(bt, vol, use, amount) { |
109 var result; |
133 var result; |
110 |
134 |
172 if (row.y_use == "Primary") |
196 if (row.y_use == "Primary") |
173 svg = parseFloat(row.y_attenuation); |
197 svg = parseFloat(row.y_attenuation); |
174 } |
198 } |
175 } |
199 } |
176 |
200 |
|
201 function setWaterAgent(name, amount) { |
|
202 console.log("setWaterAgent(" + name + ", " + amount + ")"); |
|
203 var rows = $('#miscGrid').jqxGrid('getrows'); |
|
204 if (amount == 0) { |
|
205 for (var i = 0; i < rows.length; i++) { |
|
206 var row = rows[i]; |
|
207 if (row.m_name == name) { |
|
208 var id = $("#miscGrid").jqxGrid('getrowid', i); |
|
209 // console.log("name found, erase "+ id); |
|
210 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
|
211 // console.log("result: "+commit); |
|
212 } |
|
213 } |
|
214 } else { |
|
215 var found = false; |
|
216 for (var i = 0; i < rows.length; i++) { |
|
217 var row = rows[i]; |
|
218 if (row.m_name == name) { |
|
219 found = true; |
|
220 $("#miscGrid").jqxGrid('setcellvalue', i, 'm_weight', amount); |
|
221 $("#miscGrid").jqxGrid('setcellvalue', i, 'm_amount', amount / 1000); |
|
222 break; |
|
223 } |
|
224 } |
|
225 console.log("set something, found: "+found); |
|
226 if (! found) { |
|
227 // console.log("need to add this misc"); |
|
228 var miscs = new $.jqx.dataAdapter(miscInvSource, { |
|
229 loadComplete: function () { |
|
230 var records = miscs.records; |
|
231 for (var i = 0; i < records.length; i++) { |
|
232 var record = records[i]; |
|
233 if (record.name == name) { |
|
234 var row = {}; |
|
235 row["m_name"] = record.name; |
|
236 row["m_amount"] = amount / 1000; |
|
237 row["m_cost"] = record.cost; |
|
238 row["m_type"] = record.type; |
|
239 row["m_use_use"] = record.use_use; |
|
240 row["m_time"] = 0; |
|
241 row["m_weight"] = amount; |
|
242 row["m_amount_is_weight"] = record.amount_is_weight; |
|
243 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
|
244 // console.log("result: "+commit); |
|
245 } |
|
246 } |
|
247 } |
|
248 }); |
|
249 miscs.dataBind(); |
|
250 return; |
|
251 } |
|
252 } |
|
253 } |
177 |
254 |
178 function setRangeIndicator(ion, rangeCode) { |
255 function setRangeIndicator(ion, rangeCode) { |
179 $("#wr_" + ion).html("<img src='images/checkmark_range_" + rangeCode + ".gif'><span style='font-size: 10px; font-style: italic;'>" + rangeCode + "</span>"); |
256 $("#wr_" + ion).html("<img src='images/checkmark_range_" + rangeCode + ".gif'><span style='font-size: 10px; font-style: italic;'>" + rangeCode + "</span>"); |
180 } |
257 } |
181 |
258 |
182 function mix(v1, v2, c1, c2) { |
259 function mix(v1, v2, c1, c2) { |
183 if ((v1 + v2) > 0) { |
260 if ((v1 + v2) > 0) { |
184 return ((v1 * c1) + (v2 * c2)) / (v1 + v2); |
261 return ((v1 * c1) + (v2 * c2)) / (v1 + v2); |
185 } |
262 } |
186 return 0; |
263 return 0; |
|
264 } |
|
265 |
|
266 var Ka1 = 0.0000004445; |
|
267 var Ka2 = 0.0000000000468; |
|
268 |
|
269 function PartCO3(pH) { |
|
270 var H = Math.pow(10, -pH); |
|
271 return 100 * Ka1 * Ka2 / (H*H + H * Ka1 + Ka1 * Ka2); |
|
272 } |
|
273 |
|
274 function PartHCO3(pH) { |
|
275 var H = Math.pow(10, -pH); |
|
276 return 100 * Ka1 * H / (H*H + H * Ka1 + Ka1 * Ka2); |
|
277 } |
|
278 |
|
279 function Charge(pH) { |
|
280 return (-2 * PartCO3(pH) - PartHCO3(pH)); |
|
281 } |
|
282 |
|
283 //Z alkalinity is the amount of acid (in mEq/l) needed to bring water to the target pH (Z pH) |
|
284 function ZAlkalinity(pHZ) { |
|
285 var C43 = Charge(4.3); |
|
286 var Cw = Charge(parseFloat(dataRecord.mash_ph)); |
|
287 var Cz = Charge(pHZ); |
|
288 var DeltaCNaught = -C43+Cw; |
|
289 var CT = parseFloat($("#wg_total_alkalinity").jqxNumberInput('decimal')) / 50 / DeltaCNaught; |
|
290 var DeltaCZ = -Cz+Cw; |
|
291 return CT * DeltaCZ; |
|
292 } |
|
293 |
|
294 function ZRA(pHZ) { |
|
295 |
|
296 var Calc = parseFloat($("#wg_calcium").jqxNumberInput('decimal')) / (MMCa / 2); |
|
297 var Magn = parseFloat($("#wg_magnesium").jqxNumberInput('decimal')) / (MMMg / 2); |
|
298 var Z = ZAlkalinity(pHZ); |
|
299 return Z - (Calc / 3.5 + Magn / 7); |
|
300 } |
|
301 |
|
302 function ProtonDeficit(pHZ) { |
|
303 |
|
304 var Result = ZRA(pHZ) * parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
|
305 |
|
306 return Result; |
187 } |
307 } |
188 |
308 |
189 function calcWater() { |
309 function calcWater() { |
190 |
310 |
191 console.log("calcWater()"); |
311 console.log("calcWater()"); |
195 var sodium = 0; |
315 var sodium = 0; |
196 var total_alkalinity = 0; |
316 var total_alkalinity = 0; |
197 var chloride = 0; |
317 var chloride = 0; |
198 var sulfate = 0; |
318 var sulfate = 0; |
199 var ph = 0; |
319 var ph = 0; |
|
320 var RA = 0; |
|
321 var acid = 0; |
|
322 var frac = 0; |
|
323 var MolWt = 0; |
|
324 var pK1 = 0; |
|
325 var pK2 = 0; |
|
326 var pK3 = 0; |
|
327 var TpH = 0; |
|
328 var AcidSG = 0; |
|
329 var AcidPrc = 0; |
|
330 var protonDeficit = 0; |
200 |
331 |
201 // console.log((dataRecord.w1_name != "") + " " + (dataRecord.w2_name != "")); |
332 // console.log((dataRecord.w1_name != "") + " " + (dataRecord.w2_name != "")); |
202 if (dataRecord.w1_name != "") { |
333 if (dataRecord.w1_name != "") { |
203 if (dataRecord.w2_name != "") { |
334 if (dataRecord.w2_name != "") { |
204 liters = dataRecord.w1_amount + dataRecord.w2_amount; |
335 liters = dataRecord.w1_amount + dataRecord.w2_amount; |
205 calcium = Math.round(mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_calcium, dataRecord.w2_calcium) * 10) / 10; |
336 calcium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_calcium, dataRecord.w2_calcium); |
206 magnesium = Math.round(mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_magnesium, dataRecord.w2_magnesium) * 10) / 10; |
337 magnesium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_magnesium, dataRecord.w2_magnesium); |
207 sodium = Math.round(mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sodium, dataRecord.w2_sodium) * 10) / 10; |
338 sodium = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sodium, dataRecord.w2_sodium); |
208 chloride = Math.round(mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_chloride, dataRecord.w2_chloride) * 10) / 10; |
339 chloride = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_chloride, dataRecord.w2_chloride); |
209 sulfate = Math.round(mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sulfate, dataRecord.w2_sulfate) * 10) / 10; |
340 sulfate = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_sulfate, dataRecord.w2_sulfate); |
210 total_alkalinity = Math.round(mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_total_alkalinity, dataRecord.w2_total_alkalinity) * 10) / 10; |
341 total_alkalinity = mix(dataRecord.w1_amount, dataRecord.w2_amount, dataRecord.w1_total_alkalinity, dataRecord.w2_total_alkalinity); |
211 ph = Math.round(-Math.log10(((Math.pow(10, -dataRecord.w1_ph) * dataRecord.w1_amount) + (Math.pow(10, -dataRecord.w2_ph) * dataRecord.w2_amount)) / liters) * 10) / 10; |
342 ph = -Math.log10(((Math.pow(10, -dataRecord.w1_ph) * dataRecord.w1_amount) + (Math.pow(10, -dataRecord.w2_ph) * dataRecord.w2_amount)) / liters); |
212 } else { |
343 } else { |
213 liters = dataRecord.w1_amount; |
344 liters = dataRecord.w1_amount; |
214 calcium = dataRecord.w1_calcium; |
345 calcium = dataRecord.w1_calcium; |
215 magnesium = dataRecord.w1_magnesium; |
346 magnesium = dataRecord.w1_magnesium; |
216 sodium = dataRecord.w1_sodium; |
347 sodium = dataRecord.w1_sodium; |
217 chloride = dataRecord.w1_chloride; |
348 chloride = dataRecord.w1_chloride; |
218 sulfate = dataRecord.w1_sulfate; |
349 sulfate = dataRecord.w1_sulfate; |
219 total_alkalinity = dataRecord.total_alkalinity; |
350 total_alkalinity = dataRecord.w1_total_alkalinity; |
220 ph = dataRecord.w1_ph; |
351 ph = dataRecord.w1_ph; |
221 } |
352 } |
222 } |
353 } |
223 $('#wg_amount').val(liters); |
354 $('#wg_amount').val(liters); |
224 $('#wg_calcium').val(calcium); |
355 $('#wg_calcium').val(Math.round(calcium * 10) / 10); |
225 $('#wg_magnesium').val(magnesium); |
356 $('#wg_magnesium').val(Math.round(magnesium * 10) / 10); |
226 $('#wg_sodium').val(sodium); |
357 $('#wg_sodium').val(Math.round(sodium * 10) / 10); |
227 $('#wg_total_alkalinity').val(total_alkalinity); |
358 $('#wg_total_alkalinity').val(Math.round(total_alkalinity * 10) / 10); |
228 $('#wg_chloride').val(chloride); |
359 $('#wg_chloride').val(Math.round(chloride * 10) / 10); |
229 $('#wg_sulfate').val(sulfate); |
360 $('#wg_sulfate').val(Math.round(sulfate * 10) / 10); |
230 // Note: brouwhulp has the malts included here in the result. |
361 // Note: brouwhulp has the malts included here in the result. |
231 $('#wg_ph').val(ph); |
362 $('#wg_ph').val(Math.round(ph * 10) / 10); |
232 |
363 |
233 // Brouwhulp < 40 || > 200 |
364 // Noot: de volgende berekeningen geven bijna gelijke resultaten in Brun'water. |
234 if (calcium < 50) { setRangeIndicator("calcium", "low"); } |
365 // Calculate Ca |
235 if (calcium >= 50 && calcium <= 150) { setRangeIndicator("calcium", "normal"); } |
366 RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + |
236 if (calcium > 150) { setRangeIndicator("calcium", "high"); } |
367 parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4; |
237 if (calcium > 250) { setRangeIndicator("calcium", "harmful"); } |
368 calcium += 1000 * RA / parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
238 |
369 |
239 // Brouwhulp > 40 |
370 // Calculate Mg |
240 if (magnesium >= 0 && magnesium <= 30) { setRangeIndicator("magnesium", "normal"); } |
371 RA = parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMMg / MMMgSO4; |
241 if (magnesium > 30) { setRangeIndicator("magnesium", "high"); } |
372 magnesium += 1000 * RA / parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
242 if (magnesium > 50) { setRangeIndicator("magnesium", "harmful"); } |
373 |
243 |
374 // Calculate Na |
244 // Brouwhulp > 100 |
375 RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + |
245 if (sodium <= 150) { setRangeIndicator("sodium", "normal"); } |
376 parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; |
246 if (sodium > 150) { setRangeIndicator("sodium", "high"); } |
377 sodium += 1000 * RA / parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
247 if (sodium > 200) { setRangeIndicator("sodium", "harmful"); } |
378 |
248 |
379 // Calculate SO4 |
249 // Brouwhulp > 200 |
380 RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + |
250 if (chloride <= 250) { setRangeIndicator("chloride", "normal"); } |
381 parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4; |
251 if (chloride > 250) { setRangeIndicator("chloride", "high"); } |
382 sulfate += 1000 * RA / parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
252 if (chloride > 300) { setRangeIndicator("chloride", "harmful"); } |
383 |
253 |
384 // Calculate Cl |
254 // Brouwhulp > 600 |
385 RA = 2 * parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 + |
255 if (sulfate < 50) { setRangeIndicator("sulfate", "low"); } |
386 parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl; |
256 if (sulfate >= 50 && sulfate <= 350) { setRangeIndicator("sulfate", "normal"); } |
387 chloride += 1000 * RA / parseFloat($("#wg_amount").jqxNumberInput('decimal')); |
257 if (sulfate > 350) { setRangeIndicator("sulfate", "high"); } |
388 // Einde noot. |
258 if (sulfate > 750) { setRangeIndicator("sulfate", "harmful"); } |
389 |
259 |
390 TpH = parseFloat(dataRecord.mash_ph); |
|
391 if (TpH < 5.0 || TpH > 6.0) { |
|
392 TpH = 5.4; |
|
393 dataRecord.mash_ph = 5.4; |
|
394 $("#mash_ph").val(5.4); |
|
395 $("#tgt_mash_ph").val(5.4); |
|
396 } |
|
397 var acid_amount = parseFloat($("#wa_acid").jqxNumberInput('decimal')); |
|
398 var acid_perc = parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')); |
|
399 |
|
400 switch ($("#wa_acid_name").val()) { |
|
401 case 'Melkzuur': pK1 = 3.08; |
|
402 pK2 = 20; |
|
403 pK3 = 20; |
|
404 MolWt = 90.08; |
|
405 AcidSG = 1214; //@88% |
|
406 AcidPrc = 0.88; |
|
407 frac = CalcFrac(TpH, pK1, pK2, pK3); |
|
408 acid += acid_amount * acid_perc / 100 * AcidSG / MolWt * frac / liters; //mEq/l |
|
409 break; |
|
410 |
|
411 case 'Zoutzuur': pK1 = -10; |
|
412 pK2 = 20; |
|
413 pK3 = 20; |
|
414 MolWt = 36.46; |
|
415 AcidSG = 1142; //@28% |
|
416 AcidPrc = 0.28; |
|
417 frac = CalcFrac(TpH, pK1, pK2, pK3); |
|
418 Acidmg = acid_amount * acid_perc / 100 * AcidSG / liters; |
|
419 acid += Acidmg / MolWt * frac; //mEq/l |
|
420 chloride += Acidmg / 1000 * MMCl / (MMCl + 1); |
|
421 break; |
|
422 |
|
423 case 'Fosforzuur': pK1 = 2.12; |
|
424 pK2 = 7.20; |
|
425 pK3 = 12.44; |
|
426 MolWt = 98.00; |
|
427 AcidSG = 1170; //@25% |
|
428 AcidPrc = 0.25; |
|
429 frac = CalcFrac(TpH, pK1, pK2, pK3); |
|
430 Acidmg = acid_amount * acid_perc / 100 * AcidSG / liters; |
|
431 acid += Acidmg / MolWt * frac; //mEq/l |
|
432 break; |
|
433 |
|
434 case 'Zwavelzuur': pK1 = -10; |
|
435 pK2 = 1.92; |
|
436 pK3 = 20; |
|
437 MolWt = 98.07; |
|
438 AcidSG = 1700; //@93% |
|
439 AcidPrc = 0.93; |
|
440 frac = CalcFrac(TpH, pK1, pK2, pK3); |
|
441 Acidmg = acid_amount * acid_perc / 100 * AcidSG / liters; |
|
442 acid += Acidmg / MolWt * frac; //mEq/l |
|
443 sulfate += Acidmg / 1000 * MMSO4 / (MMSO4 + 2); |
|
444 break; |
|
445 } |
|
446 protonDeficit = ProtonDeficit(TpH); |
|
447 console.log("frac: "+frac+" acid: "+acid+" protonDeficit: "+protonDeficit); |
|
448 total_alkalinity -= 50 / 61 * protonDeficit * frac / liters; |
|
449 |
|
450 $('#wb_calcium').val(Math.round(calcium * 10) / 10); |
|
451 $('#wb_magnesium').val(Math.round(magnesium * 10) / 10); |
|
452 $('#wb_sodium').val(Math.round(sodium * 10) / 10); |
|
453 $('#wb_sulfate').val(Math.round(sulfate * 10) / 10); |
|
454 $('#wb_chloride').val(Math.round(chloride * 10) / 10); |
|
455 $('#wb_total_alkalinity').val(Math.round(total_alkalinity * 10) / 10); |
|
456 |
|
457 if (calcium < 40) { |
|
458 setRangeIndicator("calcium", "low"); |
|
459 } else if (calcium > 150) { |
|
460 setRangeIndicator("calcium", "high"); |
|
461 } else { |
|
462 setRangeIndicator("calcium", "normal"); |
|
463 } |
|
464 if (magnesium >= 0 && magnesium <= 30) { |
|
465 setRangeIndicator("magnesium", "normal"); |
|
466 } else { |
|
467 setRangeIndicator("magnesium", "high"); |
|
468 } |
|
469 if (sodium <= 150) { |
|
470 setRangeIndicator("sodium", "normal"); |
|
471 } else { |
|
472 setRangeIndicator("sodium", "high"); |
|
473 } |
|
474 if (chloride <= 100) { |
|
475 setRangeIndicator("chloride", "normal"); |
|
476 } else { |
|
477 setRangeIndicator("chloride", "high"); |
|
478 } |
|
479 if (sulfate <= 350) { |
|
480 setRangeIndicator("sulfate", "normal"); |
|
481 } else { |
|
482 setRangeIndicator("sulfate", "high"); |
|
483 } |
260 } |
484 } |
261 |
485 |
262 function calcFermentablesFromOG(OG) { |
486 function calcFermentablesFromOG(OG) { |
263 |
487 |
264 console.log("calcFermentablesFromOG("+OG+")"); |
488 console.log("calcFermentablesFromOG("+OG+")"); |
310 $("#w1_amount").val(dataRecord.w1_amount); |
542 $("#w1_amount").val(dataRecord.w1_amount); |
311 dataRecord.w2_amount = newval; |
543 dataRecord.w2_amount = newval; |
312 console.log("new: "+event.args.value+" w1: "+dataRecord.w1_amount+" w2: "+dataRecord.w2_amount); |
544 console.log("new: "+event.args.value+" w1: "+dataRecord.w1_amount+" w2: "+dataRecord.w2_amount); |
313 calcWater(); |
545 calcWater(); |
314 }); |
546 }); |
|
547 $('#wa_cacl2').on('change', function (event) { |
|
548 setWaterAgent('CaCl2', event.args.value); |
|
549 calcWater(); |
|
550 }); |
|
551 $('#wa_caso4').on('change', function (event) { |
|
552 setWaterAgent('CaSO4', event.args.value); |
|
553 calcWater(); |
|
554 }); |
|
555 $('#wa_mgso4').on('change', function (event) { |
|
556 setWaterAgent('MgSO4', event.args.value); |
|
557 calcWater(); |
|
558 }); |
|
559 $('#wa_nacl').on('change', function (event) { |
|
560 setWaterAgent('NaCl', event.args.value); |
|
561 calcWater(); |
|
562 }); |
|
563 $('#wa_base_name').on('change', function (event) { |
|
564 setWaterAgent(last_base, 0); |
|
565 last_base = event.args.item.value; |
|
566 setWaterAgent(last_base, parseFloat($("#wa_base").jqxNumberInput('decimal'))); |
|
567 calcWater(); |
|
568 }); |
|
569 $('#wa_base').on('change', function (event) { |
|
570 setWaterAgent($("#wa_base_name").val(), parseFloat(event.args.value)); |
|
571 calcWater(); |
|
572 }); |
|
573 $('#wa_acid_name').on('change', function (event) { |
|
574 setWaterAgent(last_acid, 0); |
|
575 last_acid = event.args.item.value; |
|
576 setWaterAgent(last_acid, parseFloat($("#wa_acid").jqxNumberInput('decimal'))); |
|
577 calcWater(); |
|
578 }); |
|
579 $('#wa_acid').on('change', function (event) { |
|
580 setWaterAgent($("#wa_acid_name").val(), parseFloat(event.args.value)); |
|
581 calcWater(); |
|
582 }); |
|
583 $('#wa_acid_perc').on('change', function (event) { calcWater(); }); |
315 |
584 |
316 $('#color_method').on('change', function (event) { calcFermentables(); }); |
585 $('#color_method').on('change', function (event) { calcFermentables(); }); |
317 $('#ibu_method').on('change', function (event) { |
586 $('#ibu_method').on('change', function (event) { |
318 calcFermentables(); |
587 calcFermentables(); |
319 calcIBUs(); |
588 calcIBUs(); |
1156 for (var i = 0; i < records.length; i++) { |
1431 for (var i = 0; i < records.length; i++) { |
1157 var row = records[i]; |
1432 var row = records[i]; |
1158 row.m_weight = row.m_amount * 1000; |
1433 row.m_weight = row.m_amount * 1000; |
1159 data.push(row); |
1434 data.push(row); |
1160 // Initial set water agent values. |
1435 // Initial set water agent values. |
1161 if (row.m_name == 'CaCl2') |
1436 switch (row.m_name) { |
1162 $("#wa_cacl2").val(row.m_weight); |
1437 case 'CaCl2': $("#wa_cacl2").val(row.m_weight); |
1163 if (row.m_name == 'CaSO4') |
1438 break; |
1164 $("#wa_caso4").val(row.m_weight); |
1439 case 'CaSO4': $("#wa_caso4").val(row.m_weight); |
1165 if (row.m_name == 'MgSO4') |
1440 break; |
1166 $("#wa_mgso4").val(row.m_weight); |
1441 case 'MgSO4': $("#wa_mgso4").val(row.m_weight); |
1167 if (row.m_name == 'NaCl') |
1442 break; |
1168 $("#wa_nacl").val(row.m_weight); |
1443 case 'NaCl': $("#wa_nacl").val(row.m_weight); |
|
1444 break; |
|
1445 case 'Melkzuur': $("#wa_acid_name").val('Melkzuur'); |
|
1446 $("#wa_acid").val(row.m_weight); |
|
1447 $("#wa_acid_perc").val(80); |
|
1448 last_acid = 'Melkzuur'; |
|
1449 break; |
|
1450 case 'Zoutzuur': $("#wa_acid_name").val('Zoutzuur'); |
|
1451 $("#wa_acid").val(row.m_weight); |
|
1452 $("#wa_acid_perc").val(80); |
|
1453 last_acid = 'Zoutzuur'; |
|
1454 break; |
|
1455 case 'Fosforzuur': $("#wa_acid_name").val('Fosforzuur'); |
|
1456 $("#wa_acid").val(row.m_weight); |
|
1457 $("#wa_acid_perc").val(80); |
|
1458 last_acid = 'Fosforzuur'; |
|
1459 break; |
|
1460 case 'Zwavelzuur': $("#wa_acid_name").val('Zwavelzuur'); |
|
1461 $("#wa_acid").val(row.m_weight); |
|
1462 $("#wa_acid_perc").val(80); |
|
1463 last_acid = 'Zwavelzuur'; |
|
1464 break; |
|
1465 case 'NaHCO3': $("#wa_base_name").val('NaHCO3'); |
|
1466 $("#wa_base").val(row.m_weight); |
|
1467 last_base = 'NaHCO3'; |
|
1468 break; |
|
1469 case 'Na2CO3': $("#wa_base_name").val('Na2CO3'); |
|
1470 $("#wa_base").val(row.m_weight); |
|
1471 last_base = 'Na2CO3'; |
|
1472 break; |
|
1473 case 'CaCO3': $("#wa_base_name").val('CaCO3'); |
|
1474 $("#wa_base").val(row.m_weight); |
|
1475 last_base = 'CaCO3'; |
|
1476 break; |
|
1477 case 'Ca(OH)2': $("#wa_base_name").val('Ca(OH)2'); |
|
1478 $("#wa_base").val(row.m_weight); |
|
1479 last_base = 'Ca(OH)2'; |
|
1480 break; |
|
1481 } |
1169 } |
1482 } |
1170 return data; |
1483 return data; |
1171 }, |
1484 }, |
1172 loadError: function(jqXHR, status, error) { |
1485 loadError: function(jqXHR, status, error) { |
1173 $('#err').text(status + ' ' + error); |
1486 $('#err').text(status + ' ' + error); |
1643 // initialize the input fields. |
1956 // initialize the input fields. |
1644 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
1957 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
1645 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
1958 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
1646 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
1959 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
1647 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. |
1960 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. |
1648 var srcDeAcid = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ]; |
1961 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ]; |
1649 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ]; |
1962 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ]; |
1650 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
1963 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
1651 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
1964 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
1652 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); |
1965 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); |
1653 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); |
1966 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); |
1691 |
2004 |
1692 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
2005 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
1693 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
2006 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
1694 $("#tgt_mash_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true }); |
2007 $("#tgt_mash_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true }); |
1695 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); |
2008 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); |
1696 // Hop flavour and aroma gauges |
2009 // Several gauges |
1697 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
2010 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
1698 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
2011 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2012 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2013 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2014 $("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
1699 |
2015 |
1700 // Water treatment |
2016 // Water treatment |
1701 $("#w1_name").jqxDropDownList({ |
2017 $("#w1_name").jqxDropDownList({ |
1702 placeHolder: "Kies hoofd water:", |
2018 placeHolder: "Kies hoofd water:", |
1703 theme: theme, |
2019 theme: theme, |
1800 $("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2116 $("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1801 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2117 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1802 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2118 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1803 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2119 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1804 |
2120 |
|
2121 $("#pr_name").jqxDropDownList({ |
|
2122 placeHolder: "Kies doel profiel:", |
|
2123 theme: theme, |
|
2124 source: waterprofiles, |
|
2125 displayMember: "name", |
|
2126 width: 250, |
|
2127 height: 27, |
|
2128 dropDownWidth: 400, |
|
2129 dropDownHeight: 300 |
|
2130 }); |
|
2131 $("#pr_name").on('select', function (event) { |
|
2132 if (event.args) { |
|
2133 var index = event.args.index; |
|
2134 var datarecord = waterprofiles.records[index]; |
|
2135 $("#pr_calcium").val(datarecord.calcium); |
|
2136 $("#pr_sulfate").val(datarecord.sulfate); |
|
2137 $("#pr_chloride").val(datarecord.chloride); |
|
2138 $("#pr_sodium").val(datarecord.sodium); |
|
2139 $("#pr_magnesium").val(datarecord.magnesium); |
|
2140 $("#pr_total_alkalinity").val(datarecord.total_alkalinity); |
|
2141 } |
|
2142 }); |
1805 $("#pr_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2143 $("#pr_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1806 $("#pr_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2144 $("#pr_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1807 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2145 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1808 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2146 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1809 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2147 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1810 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
2148 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
1811 $("#pr_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
1812 |
2149 |
1813 $("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
2150 $("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
1814 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
2151 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
1815 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
2152 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
1816 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
2153 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
1817 |
2154 |
1818 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
2155 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
1819 $("#wa_ph_up").jqxDropDownList({ theme: theme, source: srcDeAcid, width: 125, height: 23, dropDownHeight: 128 }); |
2156 $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 125, height: 23, dropDownHeight: 128 }); |
1820 $("#wa_ph_up").val('NaHCO3'); |
2157 $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' }); |
1821 $("#wa_ph_down").jqxDropDownList({ theme: theme, source: srcAcid, width: 125, height: 23, dropDownHeight: 128 }) |
2158 $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 125, height: 23, dropDownHeight: 128 }) |
1822 $("#wa_ph_down").val('Melkzuur'); |
2159 $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' }); |
|
2160 $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
1823 |
2161 |
1824 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
2162 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
1825 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
2163 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
1826 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 5, readOnly: true }); |
2164 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 5, readOnly: true }); |
1827 |
2165 |