www/js/prod_edit.js

changeset 831
21fae4d2203e
parent 830
8f3936eef739
equal deleted inserted replaced
830:8f3936eef739 831:21fae4d2203e
19 * along with ThermFerm; see the file COPYING. If not, write to the Free 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. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 function createPopupElements() {
25
26 $('#volumeWindow').jqxWindow({
27 theme: theme,
28 position: { x: 380, y: 210 },
29 width: 500,
30 height: 200,
31 resizable: false,
32 isModal: true,
33 modalOpacity: 0.4,
34 autoOpen: false,
35 cancelButton: $('#volumeReady')
36 });
37
38 }
39
40
41
42 function drop_endis(flag, item, index) {
43 (flag) ? $(item).jqxDropDownList('disableAt', index) : $(item).jqxDropDownList('enableAt', index);
44 }
45
46
47
48 function block_fermentable(stage, added) { 24 function block_fermentable(stage, added) {
49 if (stage > 5 && added < 4) // After fermentation and added before packaging 25 if (stage > 5 && added < 4) // After fermentation and added before packaging
50 return true; 26 return true;
51 if (stage > 3 && added < 3) // After primary and added before sec/tert 27 if (stage > 3 && added < 3) // After primary and added before sec/tert
52 return true; 28 return true;
53 if (stage > 2 && added < 2) // After boil and added during mash or boil 29 if (stage > 2 && added < 2) // After boil and added during mash or boil
54 return true; 30 return true;
55 return false; 31 return false;
56 } 32 }
57 33
58
59
60 function minimum_fermentable(stage, added) {
61 if (stage > 5 && added < 4)
62 return 4;
63 if (stage > 3 && added < 3)
64 return 3;
65 if (stage > 2 && added < 2)
66 return 2;
67 return added;
68 }
69
70
71
72 function minimum_hop(stage, useat)
73 {
74 if (stage > 2 && useat < 5)
75 return 5;
76 return useat;
77 }
78
79
80
81 function block_hop(stage, useat) 34 function block_hop(stage, useat)
82 { 35 {
83 if (stage > 2 && useat < 5) 36 if (stage > 2 && useat < 5)
84 return true; 37 return true;
85 return false; 38 return false;
86 } 39 }
87
88
89 40
90 function block_misc(stage, use_use) { 41 function block_misc(stage, use_use) {
91 if (stage > 5 && use_use < 5) 42 if (stage > 5 && use_use < 5)
92 return true; 43 return true;
93 if (stage > 3 && use_use < 4) 44 if (stage > 3 && use_use < 4)
97 if (stage > 1 && use_use < 1) 48 if (stage > 1 && use_use < 1)
98 return true; 49 return true;
99 return false; 50 return false;
100 } 51 }
101 52
102
103
104 function minimum_misc(stage, use_use) {
105 if (stage > 5 && use_use < 5)
106 return 5;
107 if (stage > 3 && use_use < 4)
108 return 4;
109 if (stage > 2 && use_use < 3)
110 return 3;
111 if (stage > 1 && use_use < 1)
112 return 1;
113 return use_use;
114 }
115
116
117
118 function block_yeast(stage, use) { 53 function block_yeast(stage, use) {
119 if (stage > 3 && use < 1) 54 if (stage > 3 && use < 1)
120 return true; 55 return true;
121 if (stage > 4 && use < 2) 56 if (stage > 4 && use < 2)
122 return true; 57 return true;
124 return true; 59 return true;
125 if (stage > 6 && use < 4) 60 if (stage > 6 && use < 4)
126 return true; 61 return true;
127 return false; 62 return false;
128 } 63 }
129
130
131
132 function minimum_yeast(stage, use) {
133 if (stage > 3 && use < 1)
134 return 1;
135 if (stage > 4 && use < 2)
136 return 2;
137 if (stage > 5 && use < 3)
138 return 3;
139 if (stage > 6 && use < 4)
140 return 4;
141 return use;
142 }
143
144 64
145 65
146 $(document).ready(function() { 66 $(document).ready(function() {
147 67
148 var i, 68 var i,
1224 1144
1225 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) { 1145 function infusionVol(step_infused, step_mashkg, infuse_temp, step_temp, last_temp) {
1226 var a = last_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); 1146 var a = last_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
1227 var b = step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt); 1147 var b = step_temp * (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_infused * SpecificHeatWater + step_mashkg * SpecificHeatMalt);
1228 var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2); 1148 var vol = Round(((b - a) / ((infuse_temp - step_temp) * SpecificHeatWater)), 2);
1229 //console.log('infusionVol(' + step_infused + ', ' + step_mashkg + ', ' + infuse_temp + ', ' + step_temp + ', ' + last_temp + '): ' + vol);
1230 return vol; 1149 return vol;
1231 } 1150 }
1232 1151
1233 function decoctionVol(step_volume, step_temp, prev_temp) { 1152 function decoctionVol(step_volume, step_temp, prev_temp) {
1234 var a = (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp); 1153 var a = (dataRecord.eq_tun_weight * dataRecord.eq_tun_specific_heat + step_volume * SpecificHeatWater) * (step_temp - prev_temp);
1235 var b = SpecificHeatWater * (99 - step_temp); 1154 var b = SpecificHeatWater * (99 - step_temp);
1236 var vol = 0; 1155 var vol = 0;
1237 if (b > 0) 1156 if (b > 0)
1238 vol = Round(a / b, 6); 1157 vol = Round(a / b, 6);
1239 console.log('decoctionVol(' + step_volume + ', ' + step_temp + ', ' + prev_temp + '): ' + vol);
1240 return vol; 1158 return vol;
1241 } 1159 }
1242 1160
1243 function calcViability() { 1161 function calcViability() {
1244 var vpm = 1.00; 1162 var vpm = 1.00;
1306 } 1224 }
1307 if (ok_fermentables && ok_hops && ok_miscs && ok_yeasts && ok_waters) 1225 if (ok_fermentables && ok_hops && ok_miscs && ok_yeasts && ok_waters)
1308 $('#ok_supplies').html("<img src='images/dialog-ok-apply.png'>"); 1226 $('#ok_supplies').html("<img src='images/dialog-ok-apply.png'>");
1309 else 1227 else
1310 $('#ok_supplies').html("<img src='images/dialog-error.png'>"); 1228 $('#ok_supplies').html("<img src='images/dialog-error.png'>");
1311 }
1312
1313 function calcPercentages() {
1314
1315 console.log('calcPercentages()');
1316 var tw = 0, rowdata, percentage, rowscount = dataRecord.fermentables.length;
1317 if (rowscount > 1) {
1318 for (i = 0; i < rowscount; i++) {
1319 rowdata = dataRecord.fermentables[i];
1320 if (rowdata.f_added < 4)
1321 tw += Round(rowdata.f_amount, 3);
1322 }
1323 tw = Round(tw, 3);
1324
1325 for (i = 0; i < rowscount; i++) {
1326 rowdata = $('#fermentableGrid').jqxGrid('getrowdata', i);
1327 if (rowdata.f_added < 4) {
1328 percentage = Round(rowdata.f_amount / tw * 100, 1);
1329 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', percentage);
1330 } else {
1331 $('#fermentableGrid').jqxGrid('setcellvalue', i, 'f_percentage', 0);
1332 }
1333 }
1334 } else {
1335 $('#fermentableGrid').jqxGrid('setcellvalue', 0, 'f_percentage', 100);
1336 }
1337 } 1229 }
1338 1230
1339 /* 1231 /*
1340 * All calculations that depend on changes in the fermentables, 1232 * All calculations that depend on changes in the fermentables,
1341 * volumes and equipments. 1233 * volumes and equipments.
3410 // Buttons below 3302 // Buttons below
3411 $('#Terug').jqxButton({ template: 'primary', width: '80px', theme: theme }); 3303 $('#Terug').jqxButton({ template: 'primary', width: '80px', theme: theme });
3412 $('#Terug').bind('click', function() { 3304 $('#Terug').bind('click', function() {
3413 window.location.href = my_return; 3305 window.location.href = my_return;
3414 }); 3306 });
3415
3416 createPopupElements();
3417 }); 3307 });
3418 3308

mercurial