www/js/rec_edit.js

changeset 147
e6e5d007eb54
parent 146
2a6c00d325b2
child 148
c0f0bbfefd63
equal deleted inserted replaced
146:2a6c00d325b2 147:e6e5d007eb54
170 for (var i = 0; i < rows.length; i++) { 170 for (var i = 0; i < rows.length; i++) {
171 var row = rows[i]; 171 var row = rows[i];
172 if (row.y_use == "Primary") 172 if (row.y_use == "Primary")
173 svg = parseFloat(row.y_attenuation); 173 svg = parseFloat(row.y_attenuation);
174 } 174 }
175 }
176
177
178 function calcWater() {
179
180 console.log("calcWater()");
181 var rows = $('#waterGrid').jqxGrid('getrows');
182 var liters = 0;
183 var calcium = 0;
184 var magnesium = 0;
185 var sodium = 0;
186 var total_alkalinity = 0;
187 var chloride = 0;
188 var sulfate = 0;
189 var ph = 0;
190 for (var i = 0; i < rows.length; i++) {
191 var row = rows[i];
192 liters += row.w_amount;
193 calcium += row.w_amount * row.w_calcium;
194 magnesium += row.w_amount * row.w_magnesium;
195 sodium += row.w_amount * row.w_sodium;
196 total_alkalinity += row.w_amount * row.w_total_alkalinity;
197 chloride += row.w_amount * row.w_chloride;
198 sulfate += row.w_amount * row.w_sulfate;
199 ph += Math.pow(10, -row.w_ph) * row.w_amount;
200 }
201 $('#wg_volume').val(liters);
202 calcium = Math.round(calcium / liters * 10) / 10;
203 $('#wg_calcium').val(calcium);
204 $('#wg_magnesium').val(Math.round(magnesium / liters * 10) / 10);
205 $('#wg_sodium').val(Math.round(sodium / liters * 10) / 10);
206 $('#wg_total_alkalinity').val(Math.round(total_alkalinity / liters * 10) / 10);
207 $('#wg_chloride').val(Math.round(chloride / liters * 10) / 10);
208 sulfate = Math.round(sulfate / liters * 10) / 10;
209 $('#wg_sulfate').val(sulfate);
210 // Note: brouwhulp has the malts included here in the result.
211 ph = Math.round(-Math.log10(ph / liters) * 10) / 10;
212 $('#wg_ph').val(ph);
175 } 213 }
176 214
177 function calcFermentablesFromOG(OG) { 215 function calcFermentablesFromOG(OG) {
178 216
179 console.log("calcFermentablesFromOG("+OG+")"); 217 console.log("calcFermentablesFromOG("+OG+")");
257 calcFermentables(); // Update the recipe details 295 calcFermentables(); // Update the recipe details
258 calcSVG(); 296 calcSVG();
259 calcABV(); // and ABV 297 calcABV(); // and ABV
260 calcIBUs(); // and the IBU's. 298 calcIBUs(); // and the IBU's.
261 }); 299 });
300 $('#mash_ph').on('change', function (event) {
301 $("#tgt_mash_ph").val(parseFloat(event.args.value));
302 calcWater();
303 });
262 }; 304 };
263 305
264 $("#styleSelect").jqxDropDownList({ 306 $("#styleSelect").jqxDropDownList({
265 placeHolder: "Kies bierstijl:", 307 placeHolder: "Kies bierstijl:",
266 theme: theme, 308 theme: theme,
376 { name: 'est_color', type: 'float' }, 418 { name: 'est_color', type: 'float' },
377 { name: 'color_method', type: 'string' }, 419 { name: 'color_method', type: 'string' },
378 { name: 'est_ibu', type: 'float' }, 420 { name: 'est_ibu', type: 'float' },
379 { name: 'ibu_method', type: 'string' }, 421 { name: 'ibu_method', type: 'string' },
380 { name: 'est_carb', type: 'float' }, 422 { name: 'est_carb', type: 'float' },
381 { name: 'mash_sparge_temp', type: 'float' }, 423 { name: 'sparge_temp', type: 'float' },
424 { name: 'sparge_ph', type: 'float' },
425 { name: 'sparge_volume', type: 'float' },
426 { name: 'sparge_acid_type', type: 'string' },
427 { name: 'sparge_acid_perc', type: 'float' },
428 { name: 'sparge_acid_amount', type: 'float' },
382 { name: 'mash_ph', type: 'float' }, 429 { name: 'mash_ph', type: 'float' },
383 { name: 'mash_name', type: 'string' }, 430 { name: 'mash_name', type: 'string' },
431 { name: 'calc_acid', type: 'bool' },
384 { name: 'fermentables', type: 'array' }, 432 { name: 'fermentables', type: 'array' },
385 { name: 'hops', type: 'string' }, 433 { name: 'hops', type: 'string' },
386 { name: 'miscs', type: 'string' }, 434 { name: 'miscs', type: 'string' },
387 { name: 'yeasts', type: 'string' }, 435 { name: 'yeasts', type: 'string' },
388 { name: 'waters', type: 'array' }, 436 { name: 'waters', type: 'array' },
432 $("#est_carb").val(dataRecord.est_carb); 480 $("#est_carb").val(dataRecord.est_carb);
433 $("#st_carb_min").val(dataRecord.st_carb_min); 481 $("#st_carb_min").val(dataRecord.st_carb_min);
434 $("#st_carb_max").val(dataRecord.st_carb_max); 482 $("#st_carb_max").val(dataRecord.st_carb_max);
435 $("#mash_name").val(dataRecord.mash_name); 483 $("#mash_name").val(dataRecord.mash_name);
436 $("#mash_ph").val(dataRecord.mash_ph); 484 $("#mash_ph").val(dataRecord.mash_ph);
437 $("#mash_sparge_temp").val(dataRecord.mash_sparge_temp); 485 $("#tgt_mash_ph").val(dataRecord.mash_ph);
486 $("#sparge_temp").val(dataRecord.sparge_temp);
487 $("#sparge_ph").val(dataRecord.sparge_ph);
488 $("#sparge_volume").val(dataRecord.sparge_volume);
489 $("#sparge_acid_type").val(dataRecord.sparge_acid_type);
490 $("#sparge_acid_perc").val(dataRecord.sparge_acid_perc);
491 $("#sparge_acid_amount").val(dataRecord.sparge_acid_amount);
492 $("#calc_acid").val(dataRecord.calc_acid);
438 editFermentable(dataRecord); 493 editFermentable(dataRecord);
439 editHop(dataRecord); 494 editHop(dataRecord);
440 editMisc(dataRecord); 495 editMisc(dataRecord);
441 editYeast(dataRecord); 496 editYeast(dataRecord);
442 editWater(dataRecord); 497 editWater(dataRecord);
997 var data = new Array(); 1052 var data = new Array();
998 for (var i = 0; i < records.length; i++) { 1053 for (var i = 0; i < records.length; i++) {
999 var row = records[i]; 1054 var row = records[i];
1000 row.m_weight = row.m_amount * 1000; 1055 row.m_weight = row.m_amount * 1000;
1001 data.push(row); 1056 data.push(row);
1057 // Initial set water agent values.
1058 if (row.m_name == 'CaCl2')
1059 $("#wa_cacl2").val(row.m_weight);
1060 if (row.m_name == 'CaSO4')
1061 $("#wa_caso4").val(row.m_weight);
1062 if (row.m_name == 'MgSO4')
1063 $("#wa_mgso4").val(row.m_weight);
1064 if (row.m_name == 'NaCl')
1065 $("#wa_nacl").val(row.m_weight);
1002 } 1066 }
1003 return data; 1067 return data;
1004 }, 1068 },
1005 loadError: function(jqXHR, status, error) { 1069 loadError: function(jqXHR, status, error) {
1006 $('#err').text(status + ' ' + error); 1070 $('#err').text(status + ' ' + error);
1419 var rowscount = $("#waterGrid").jqxGrid('getdatainformation').rowscount; 1483 var rowscount = $("#waterGrid").jqxGrid('getdatainformation').rowscount;
1420 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 1484 if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
1421 var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex); 1485 var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex);
1422 var commit = $("#waterGrid").jqxGrid('deleterow', id); 1486 var commit = $("#waterGrid").jqxGrid('deleterow', id);
1423 } 1487 }
1488 calcWater();
1424 }); 1489 });
1425 }, 1490 },
1426 ready: function() { 1491 ready: function() {
1492 calcWater();
1427 $('#jqxTabs').jqxTabs('next'); 1493 $('#jqxTabs').jqxTabs('next');
1428 }, 1494 },
1429 columns: [ 1495 columns: [
1430 { text: 'Water bron', editable: false, datafield: 'w_name' }, 1496 { text: 'Water bron', editable: false, datafield: 'w_name' },
1431 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', 1497 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
1445 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 1511 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
1446 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 1512 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
1447 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } 1513 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }
1448 ] 1514 ]
1449 }); 1515 });
1450 }; // editWater = function (data) { 1516 $("#waterGrid").on('cellendedit', function (event) {
1517 var args = event.args;
1518 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
1519 $("#waterGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
1520 calcWater();
1521 });
1522 };
1451 1523
1452 // inline mash editor 1524 // inline mash editor
1453 var editMash = function (data) { 1525 var editMash = function (data) {
1454 var generaterow = function () { 1526 var generaterow = function () {
1455 var row = {}; 1527 var row = {};
1581 // initialize the input fields. 1653 // initialize the input fields.
1582 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; 1654 var srcType = [ "All Grain", "Partial Mash", "Extract" ];
1583 var srcColor = [ "Morey", "Mosher", "Daniels" ]; 1655 var srcColor = [ "Morey", "Mosher", "Daniels" ];
1584 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; 1656 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ];
1585 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. 1657 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time.
1658 var srcDeAcid = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ];
1659 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ];
1586 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 1660 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
1587 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); 1661 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
1588 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); 1662 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
1589 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); 1663 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
1590 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); 1664 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
1625 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 1699 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1626 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 1700 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1627 1701
1628 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); 1702 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
1629 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 1703 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
1704 $("#tgt_mash_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true });
1630 $("#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 }); 1705 $("#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 });
1631 // Hop flavour and aroma gauges 1706 // Hop flavour and aroma gauges
1632 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 1707 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
1633 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); 1708 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
1709
1710 // Water treatment
1711 $("#wg_volume").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1712 $("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1713 $("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1714 $("#wg_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1715 $("#wg_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1716 $("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1717 $("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1718 $("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1719
1720 $("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1721 $("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1722 $("#wb_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1723 $("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1724 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1725 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1726 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1727
1728 $("#pr_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1729 $("#pr_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1730 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1731 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1732 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1733 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1734 $("#pr_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
1735
1736 $("#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' });
1737 $("#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' });
1738 $("#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' });
1739 $("#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' });
1740
1741 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 });
1742 $("#wa_ph_up").jqxDropDownList({ theme: theme, source: srcDeAcid, width: 125, height: 23, dropDownHeight: 128 });
1743 $("#wa_ph_up").val('NaHCO3');
1744 $("#wa_ph_down").jqxDropDownList({ theme: theme, source: srcAcid, width: 125, height: 23, dropDownHeight: 128 })
1745 $("#wa_ph_down").val('Melkzuur');
1746
1747 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
1748 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
1749 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 5, readOnly: true });
1634 1750
1635 // Tabs inside the popup window. 1751 // Tabs inside the popup window.
1636 $('#jqxTabs').jqxTabs({ 1752 $('#jqxTabs').jqxTabs({
1637 theme: theme, 1753 theme: theme,
1638 width: 1280, 1754 width: 1280,
1718 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), 1834 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
1719 ibu_method: $("#ibu_method").val(), 1835 ibu_method: $("#ibu_method").val(),
1720 est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')), 1836 est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
1721 mash_name: $("#mash_name").val(), 1837 mash_name: $("#mash_name").val(),
1722 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')), 1838 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
1723 mash_sparge_temp: parseFloat($("#mash_sparge_temp").jqxNumberInput('decimal')), 1839 sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
1840 sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
1841 sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
1842 sparge_acid_type: $("#sparge_acid_type").val(),
1843 sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
1844 sparge_acid_amount: parseFloat($("#sparge_acid_amount").jqxNumberInput('decimal')),
1845 calc_acid: $("#calc_acid").val(),
1724 fermentables: fermentablerow, 1846 fermentables: fermentablerow,
1725 hops: hoprow, 1847 hops: hoprow,
1726 miscs: miscrow, 1848 miscs: miscrow,
1727 yeasts: yeastrow, 1849 yeasts: yeastrow,
1728 waters: waterrow, 1850 waters: waterrow,

mercurial