1 | var xmlhttp;
|
---|
2 | if (window.XMLHttpRequest)
|
---|
3 | {// code for IE7+, Firefox, Chrome, Opera, Safari
|
---|
4 | xmlhttp=new XMLHttpRequest();
|
---|
5 | }
|
---|
6 | else
|
---|
7 | {// code for IE6, IE5
|
---|
8 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
9 | }
|
---|
10 |
|
---|
11 | //function to get programs from the db
|
---|
12 | function get_progs(prog, selectsize, mode)
|
---|
13 | {
|
---|
14 | xmlhttp.open("GET","get_progs.php?fProgram="+prog+"&fSelectSize="+selectsize+"&fMode="+mode,false);
|
---|
15 | xmlhttp.send();
|
---|
16 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
17 | {
|
---|
18 | document.getElementById('progfield').innerHTML = xmlhttp.responseText;
|
---|
19 | document.getElementById('keyfield').innerHTML = "";
|
---|
20 | if (document.getElementById('valuefield1'))
|
---|
21 | document.getElementById('valuefield1').innerHTML = "";
|
---|
22 | }
|
---|
23 | else
|
---|
24 | document.getElementById('progfield').innerHTML = "argh";
|
---|
25 | }
|
---|
26 |
|
---|
27 | //function to get keys from the db
|
---|
28 | function get_keys(prog, key, selectsize, mode)
|
---|
29 | {
|
---|
30 | xmlhttp.open("GET","get_keys.php?fProgram="+prog+"&fKey="+key+"&fSelectSize="+selectsize+"&fMode="+mode,false);
|
---|
31 | xmlhttp.send();
|
---|
32 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
33 | {
|
---|
34 | document.getElementById('keyfield').innerHTML = xmlhttp.responseText;
|
---|
35 | if (document.getElementById('valuefield1'))
|
---|
36 | document.getElementById('valuefield1').innerHTML = "";
|
---|
37 | }
|
---|
38 | else
|
---|
39 | document.getElementById('keyfield').innerHTML = "argh";
|
---|
40 |
|
---|
41 | if(document.getElementById('addrowprog'))
|
---|
42 | document.getElementById('addrowprog').style.display = "";
|
---|
43 | }
|
---|
44 |
|
---|
45 | function get_statusdate(getvalcase, val)
|
---|
46 | {
|
---|
47 | if (!val)
|
---|
48 | {
|
---|
49 | radio=document.getElementsByName('dateformat'+getvalcase);
|
---|
50 | for (i=0; i< radio.length; i++)
|
---|
51 | if (radio[i].checked)
|
---|
52 | val=radio[i].value;
|
---|
53 | }
|
---|
54 | if (val=="pulldown")
|
---|
55 | {
|
---|
56 | year=document.getElementById('year'+getvalcase).value;
|
---|
57 | month=document.getElementById('month'+getvalcase).value;
|
---|
58 | day=document.getElementById('day'+getvalcase).value;
|
---|
59 | hour=document.getElementById('hour'+getvalcase).value;
|
---|
60 | min=document.getElementById('min'+getvalcase).value;
|
---|
61 | sec=document.getElementById('sec'+getvalcase).value;
|
---|
62 | if (year=="empty")
|
---|
63 | statusdate="";
|
---|
64 | else
|
---|
65 | {
|
---|
66 | statusdate=year;
|
---|
67 | if (month!="empty")
|
---|
68 | {
|
---|
69 | statusdate=statusdate+"-"+month;
|
---|
70 | if (day!="empty")
|
---|
71 | {
|
---|
72 | statusdate=statusdate+"-"+day;
|
---|
73 | if (hour!="empty")
|
---|
74 | {
|
---|
75 | statusdate=statusdate+" "+hour;
|
---|
76 | if (min!="empty")
|
---|
77 | {
|
---|
78 | statusdate=statusdate+":"+min;
|
---|
79 | if (sec!="empty")
|
---|
80 | statusdate=statusdate+":"+sec;
|
---|
81 | }
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|
86 | }
|
---|
87 | if (val=="textinput")
|
---|
88 | statusdate=document.getElementById('statusdate'+getvalcase).value;
|
---|
89 | return statusdate;
|
---|
90 | }
|
---|
91 |
|
---|
92 | //function to get values from the db
|
---|
93 | function get_values(getvalcase, prog, key, mode)
|
---|
94 | {
|
---|
95 | if (parseInt(getvalcase)>1)
|
---|
96 | {
|
---|
97 | //get prog and key
|
---|
98 | progselect=document.getElementById("prog");
|
---|
99 | if (!progselect)
|
---|
100 | prog="all";
|
---|
101 | else
|
---|
102 | if (progselect.options[progselect.selectedIndex])
|
---|
103 | prog=progselect.options[progselect.selectedIndex].value;
|
---|
104 | else
|
---|
105 | prog="all";
|
---|
106 | keyselect=document.getElementById("key");
|
---|
107 | if (!keyselect)
|
---|
108 | key="all";
|
---|
109 | else
|
---|
110 | if (keyselect.options[keyselect.selectedIndex])
|
---|
111 | key=keyselect.options[keyselect.selectedIndex].value;
|
---|
112 | else
|
---|
113 | key="all";
|
---|
114 | }
|
---|
115 | if (mode=="view" && getvalcase==1)
|
---|
116 | return;
|
---|
117 | //if (getvalcase==3)
|
---|
118 | // document.getElementById('comparevals').style.display = "";
|
---|
119 | if ((getvalcase==2 || getvalcase==3) && document.getElementById('statusdate'+getvalcase))
|
---|
120 | {
|
---|
121 | statusdate=get_statusdate(getvalcase);
|
---|
122 | //alert(statusdate);
|
---|
123 | phpcall="get_values.php?fStatusDate="+statusdate+"&fGetValCase="+getvalcase+"&fKey="+key+"&fProgram="+prog;
|
---|
124 | }
|
---|
125 | else
|
---|
126 | phpcall="get_values.php?fGetValCase="+getvalcase+"&fKey="+key+"&fProgram="+prog;
|
---|
127 |
|
---|
128 | xmlhttp.open("GET",phpcall,false);
|
---|
129 | xmlhttp.send();
|
---|
130 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
131 | document.getElementById('valuefield'+getvalcase).innerHTML = xmlhttp.responseText;
|
---|
132 | else
|
---|
133 | document.getElementById('valuefield'+getvalcase).innerHTML = "argh";
|
---|
134 |
|
---|
135 | if(document.getElementById('addrowkey'))
|
---|
136 | document.getElementById('addrowkey').style.display = "";
|
---|
137 | }
|
---|
138 |
|
---|
139 | function addRow(addcase, prog, key, key1, key2, type)
|
---|
140 | {
|
---|
141 | if (!prog)
|
---|
142 | {
|
---|
143 | progselect=document.getElementById("prog");
|
---|
144 | if (progselect.options[progselect.selectedIndex])
|
---|
145 | prog=progselect.options[progselect.selectedIndex].value;
|
---|
146 | else
|
---|
147 | prog='all';
|
---|
148 | }
|
---|
149 | if (!key)
|
---|
150 | {
|
---|
151 | keyselect=document.getElementById("key");
|
---|
152 | if (!keyselect)
|
---|
153 | key='all';
|
---|
154 | else
|
---|
155 | if (keyselect.options[keyselect.selectedIndex])
|
---|
156 | key=keyselect.options[keyselect.selectedIndex].value;
|
---|
157 | else
|
---|
158 | key='all';
|
---|
159 | }
|
---|
160 | switch(addcase)
|
---|
161 | {
|
---|
162 | case 1:
|
---|
163 | get_keys(prog,key,"10", "edit");
|
---|
164 | case 2:
|
---|
165 | get_values(1, prog, key);
|
---|
166 | }
|
---|
167 |
|
---|
168 | if (prog=='all' && (addcase==3 || addcase==2))
|
---|
169 | addcase=1;
|
---|
170 | if (key=='all' && addcase==3)
|
---|
171 | addcase=2;
|
---|
172 |
|
---|
173 |
|
---|
174 | for (var i = 1 ; i <= document.getElementById('maxindex').innerHTML ; i++)
|
---|
175 | if(document.getElementById('action'+i))
|
---|
176 | //document.getElementById('action'+i).innerHTML = "";
|
---|
177 | document.getElementById('action'+i).style.display = "none";
|
---|
178 |
|
---|
179 | tabBody=document.getElementById("valtable1");
|
---|
180 | row=document.createElement("TR");
|
---|
181 | row.id='val0';
|
---|
182 | cell0 = document.createElement("TD");
|
---|
183 | cell1 = document.createElement("TD");
|
---|
184 | cell2 = document.createElement("TD");
|
---|
185 | cell3 = document.createElement("TD");
|
---|
186 | cell4 = document.createElement("TD");
|
---|
187 | cell5 = document.createElement("TD");
|
---|
188 | cell6 = document.createElement("TD");
|
---|
189 | cell7 = document.createElement("TD");
|
---|
190 | cell8 = document.createElement("TD");
|
---|
191 | cell9 = document.createElement("TD");
|
---|
192 | cell10 = document.createElement("TD");
|
---|
193 | var updcase;
|
---|
194 |
|
---|
195 | // addcase: three cases
|
---|
196 | // 1: add new prog+key, val=NULL
|
---|
197 | // 2: add new key, val=NULL, prog=selected
|
---|
198 | // 3: add new val, prog=selected, key=selected, type fixed
|
---|
199 | switch(addcase)
|
---|
200 | {
|
---|
201 | case 1:
|
---|
202 | //field for prog
|
---|
203 | input1 = document.createElement("INPUT");
|
---|
204 | input1.id = 'prog0';
|
---|
205 | cell1.appendChild(input1);
|
---|
206 | //fields for keys
|
---|
207 | input2 = document.createElement("INPUT");
|
---|
208 | input2.id = '1key0';
|
---|
209 | cell2.appendChild(input2);
|
---|
210 | input10 = document.createElement("INPUT");
|
---|
211 | input10.id = '2key0';
|
---|
212 | cell10.appendChild(input10);
|
---|
213 | //field for val
|
---|
214 | cell3.id = 'newval0';
|
---|
215 | textnode3=document.createTextNode("NULL");
|
---|
216 | cell3.appendChild(textnode3);
|
---|
217 | updcase=5;
|
---|
218 | //field type
|
---|
219 | select7 = document.createElement("select");
|
---|
220 | select7.id = 'newtype0';
|
---|
221 | select7.option = 'string';
|
---|
222 | option7a = document.createElement("option");
|
---|
223 | option7a.text = '-';
|
---|
224 | option7a.value = '';
|
---|
225 | select7.appendChild(option7a);
|
---|
226 | option7b = document.createElement("option");
|
---|
227 | option7b.id = 'int';
|
---|
228 | option7b.text = 'int';
|
---|
229 | option7b.value = 'int';
|
---|
230 | select7.appendChild(option7b);
|
---|
231 | option7c = document.createElement("option");
|
---|
232 | option7c.id = 'float';
|
---|
233 | option7c.text = 'float';
|
---|
234 | option7c.value = 'float';
|
---|
235 | select7.appendChild(option7c);
|
---|
236 | option7d = document.createElement("option");
|
---|
237 | option7d.id = 'string';
|
---|
238 | option7d.text = 'string';
|
---|
239 | option7d.value = 'string';
|
---|
240 | select7.appendChild(option7d);
|
---|
241 | option7e = document.createElement("option");
|
---|
242 | option7e.id = 'bool';
|
---|
243 | option7e.text = 'bool';
|
---|
244 | option7e.value = 'bool';
|
---|
245 | select7.appendChild(option7e);
|
---|
246 | cell7.appendChild(select7);
|
---|
247 | break;
|
---|
248 | case 2:
|
---|
249 | //field for prog
|
---|
250 | cell1.id = 'prog0';
|
---|
251 | textnode1=document.createTextNode(prog);
|
---|
252 | cell1.appendChild(textnode1);
|
---|
253 | //field for key
|
---|
254 | input2 = document.createElement("INPUT");
|
---|
255 | input2.id = '1key0';
|
---|
256 | cell2.appendChild(input2);
|
---|
257 | input10 = document.createElement("INPUT");
|
---|
258 | input10.id = '2key0';
|
---|
259 | cell10.appendChild(input10);
|
---|
260 | //field for val
|
---|
261 | cell3.id = 'newval0';
|
---|
262 | textnode3=document.createTextNode("NULL");
|
---|
263 | cell3.appendChild(textnode3);
|
---|
264 | updcase=1;
|
---|
265 | //field type
|
---|
266 | select7 = document.createElement("select");
|
---|
267 | select7.id = 'newtype0';
|
---|
268 | select7.option = 'string';
|
---|
269 | option7a = document.createElement("option");
|
---|
270 | option7a.text = '-';
|
---|
271 | option7a.value = '';
|
---|
272 | select7.appendChild(option7a);
|
---|
273 | option7b = document.createElement("option");
|
---|
274 | option7b.id = 'int';
|
---|
275 | option7b.text = 'int';
|
---|
276 | option7b.value = 'int';
|
---|
277 | select7.appendChild(option7b);
|
---|
278 | option7c = document.createElement("option");
|
---|
279 | option7c.id = 'float';
|
---|
280 | option7c.text = 'float';
|
---|
281 | option7c.value = 'float';
|
---|
282 | select7.appendChild(option7c);
|
---|
283 | option7d = document.createElement("option");
|
---|
284 | option7d.id = 'string';
|
---|
285 | option7d.text = 'string';
|
---|
286 | option7d.value = 'string';
|
---|
287 | select7.appendChild(option7d);
|
---|
288 | option7e = document.createElement("option");
|
---|
289 | option7e.id = 'bool';
|
---|
290 | option7e.text = 'bool';
|
---|
291 | option7e.value = 'bool';
|
---|
292 | select7.appendChild(option7e);
|
---|
293 | cell7.appendChild(select7);
|
---|
294 | break;
|
---|
295 | case 3:
|
---|
296 | //field for prog
|
---|
297 | cell1.id = 'prog0';
|
---|
298 | textnode1=document.createTextNode(prog);
|
---|
299 | cell1.appendChild(textnode1);
|
---|
300 | //field for key
|
---|
301 | cell2.id = '1key0';
|
---|
302 | textnode2=document.createTextNode(key1);
|
---|
303 | cell2.appendChild(textnode2);
|
---|
304 | cell10.id = '2key0';
|
---|
305 | textnode10=document.createTextNode(key2);
|
---|
306 | cell10.appendChild(textnode10);
|
---|
307 | //field for val
|
---|
308 | input3 = document.createElement("INPUT");
|
---|
309 | input3.id = 'newval0';
|
---|
310 | cell3.appendChild(input3);
|
---|
311 | updcase=2;
|
---|
312 | //field type
|
---|
313 | cell7.id = 'type0';
|
---|
314 | textnode7 = document.createTextNode(type);
|
---|
315 | cell7.appendChild(textnode7);
|
---|
316 | break;
|
---|
317 | default:
|
---|
318 | break;
|
---|
319 | }
|
---|
320 |
|
---|
321 | //field descr
|
---|
322 | input4 = document.createElement("INPUT");
|
---|
323 | input4.id = 'newdescr0';
|
---|
324 | cell4.appendChild(input4);
|
---|
325 | //field action
|
---|
326 | input5a = document.createElement("input");
|
---|
327 | input5a.value = 'Add';
|
---|
328 | input5a.type = "button";
|
---|
329 | input5a.onclick = function () { UpdateRow(updcase, 0); onclick() }
|
---|
330 | cell5.appendChild(input5a);
|
---|
331 | input5b = document.createElement("input");
|
---|
332 | input5b.value = 'Cancel';
|
---|
333 | input5b.type = "button";
|
---|
334 | input5b.onclick = function () { CancelAddRow(prog, key); onclick() }
|
---|
335 | cell5.appendChild(input5b);
|
---|
336 |
|
---|
337 | row.appendChild(cell0);//index, counter
|
---|
338 | row.appendChild(cell6);//valid from
|
---|
339 | row.appendChild(cell1);//prog
|
---|
340 | row.appendChild(cell2);//key1
|
---|
341 | row.appendChild(cell10);//key2
|
---|
342 | row.appendChild(cell3);//value
|
---|
343 | row.appendChild(cell7);//type
|
---|
344 | row.appendChild(cell4);//descr
|
---|
345 | row.appendChild(cell5);//action
|
---|
346 | row.appendChild(cell8);//min
|
---|
347 | row.appendChild(cell9);//max
|
---|
348 | tabBody.appendChild(row);
|
---|
349 |
|
---|
350 | // to be removed later when solution for adding multiple new rows is found
|
---|
351 | document.getElementById('addrowvals').style.display = "none";
|
---|
352 | document.getElementById('addrowvals2').style.display = "none";
|
---|
353 | document.getElementById('addrowkey').style.display = "none";
|
---|
354 | document.getElementById('addrowprog').style.display = "none";
|
---|
355 | }
|
---|
356 |
|
---|
357 | function CancelAddRow(prog, key)
|
---|
358 | {
|
---|
359 | //get select program and key
|
---|
360 | if (!prog)
|
---|
361 | {
|
---|
362 | progselect=document.getElementById("prog");
|
---|
363 | prog=progselect.options[progselect.selectedIndex].value;
|
---|
364 | }
|
---|
365 | if (!key)
|
---|
366 | {
|
---|
367 | keyselect=document.getElementById("key");
|
---|
368 | key=keyselect.options[keyselect.selectedIndex].value;
|
---|
369 | }
|
---|
370 | //reload the original content in case of cancel
|
---|
371 | get_values(1, prog, key);
|
---|
372 |
|
---|
373 | // to be removed later when solution for adding multiple new rows is found
|
---|
374 | document.getElementById('addrowvals').style.display = "";
|
---|
375 | document.getElementById('addrowvals2').style.display = "";
|
---|
376 | document.getElementById('addrowkey').style.display = "";
|
---|
377 | document.getElementById('addrowprog').style.display = "";
|
---|
378 | }
|
---|
379 |
|
---|
380 | function CancelUpdate()
|
---|
381 | {
|
---|
382 | //get select program and key
|
---|
383 | progselect=document.getElementById("prog");
|
---|
384 | prog=progselect.options[progselect.selectedIndex].value;
|
---|
385 | keyselect=document.getElementById("key");
|
---|
386 | key=keyselect.options[keyselect.selectedIndex].value;
|
---|
387 | //reload the original table in case of cancel
|
---|
388 | get_values(1, prog, key);
|
---|
389 | }
|
---|
390 |
|
---|
391 | function EditRow(index)
|
---|
392 | {
|
---|
393 | for (var i = 1 ; i <= document.getElementById('maxindex').innerHTML ; i++)
|
---|
394 | if(document.getElementById('action'+i) && i!=index)
|
---|
395 | //document.getElementById('action'+i).innerHTML = "";
|
---|
396 | document.getElementById('action'+i).style.display = "none";
|
---|
397 |
|
---|
398 | //get current values
|
---|
399 | oldval=document.getElementById('val'+index).innerHTML;
|
---|
400 | olddescr=document.getElementById('descr'+index).innerHTML;
|
---|
401 | oldtype=document.getElementById('type'+index).innerHTML;
|
---|
402 | if (!oldval)
|
---|
403 | delcase=6;
|
---|
404 | else
|
---|
405 | delcase=4;
|
---|
406 | //set field for value
|
---|
407 | if (oldtype=='bool')
|
---|
408 | {
|
---|
409 | if (oldval=='yes')
|
---|
410 | textval="<input name='boolbox' type='radio' id='newval"+index+"' value='yes' checked> yes";
|
---|
411 | else
|
---|
412 | textval="<input name='boolbox' type='radio' id='newval"+index+"' value='yes'> yes";
|
---|
413 | if (oldval=='no')
|
---|
414 | textval=textval+"<input name='boolbox' type='radio' id='newval"+index+"' value='no' checked> no"
|
---|
415 | else
|
---|
416 | textval=textval+"<input name='boolbox' type='radio' id='newval"+index+"' value='no'> no"
|
---|
417 | }
|
---|
418 | else
|
---|
419 | textval="<input align='right' id='newval"+index+"' value='"+oldval+"'>";
|
---|
420 | document.getElementById('val'+index).innerHTML = textval;
|
---|
421 | //set field for description
|
---|
422 | document.getElementById('descr'+index).innerHTML = "<input align='right' id='newdescr"+index+"' value='"+olddescr+"'>";
|
---|
423 | /*
|
---|
424 | //set field for type
|
---|
425 | typeselecttext="<select id='newtype"+index+"' value='"+oldtype+"'>"+"<option>-</option>";
|
---|
426 | if (oldtype=='int')
|
---|
427 | typeselecttext=typeselecttext+"<option selected>int</option>";
|
---|
428 | else
|
---|
429 | typeselecttext=typeselecttext+"<option>int</option>";
|
---|
430 | if (oldtype=='float')
|
---|
431 | typeselecttext=typeselecttext+"<option selected>float</option>";
|
---|
432 | else
|
---|
433 | typeselecttext=typeselecttext+"<option>float</option>";
|
---|
434 | if (oldtype=='string')
|
---|
435 | typeselecttext=typeselecttext+"<option selected>string</option>";
|
---|
436 | else
|
---|
437 | typeselecttext=typeselecttext+"<option>string</option>";
|
---|
438 | if (oldtype=='bool')
|
---|
439 | typeselecttext=typeselecttext+"<option selected>bool</option>";
|
---|
440 | else
|
---|
441 | typeselecttext=typeselecttext+"<option>bool</option>";
|
---|
442 | typeselecttext=typeselecttext+"</select>";
|
---|
443 | document.getElementById('type'+index).innerHTML = typeselecttext;
|
---|
444 | */
|
---|
445 |
|
---|
446 | //set field for action
|
---|
447 | actiontext="<input type='button' value='Update' onclick='UpdateRow(3,"+index+")'>";
|
---|
448 | notyetvalid=document.getElementById('notyetvalid'+index)
|
---|
449 | if (delcase!=6 || notyetvalid)
|
---|
450 | actiontext=actiontext+"<input type='button' value='Delete' onclick='UpdateRow("+delcase+","+index+")'>";
|
---|
451 | actiontext=actiontext+"<input type='button' value='Cancel' onclick='CancelUpdate()'>";
|
---|
452 | document.getElementById('action'+index).innerHTML =actiontext;
|
---|
453 | }
|
---|
454 |
|
---|
455 | function UpdateRow(updcase,index)
|
---|
456 | {
|
---|
457 | // five cases of update corresponds to
|
---|
458 | // 5: add new prog + key addcase 1
|
---|
459 | // 1: add new key addcase 2
|
---|
460 | // 2: add new val (for same key) addcase 3 -> same type
|
---|
461 | // 3: edit val -> same type
|
---|
462 | // 4: delete val (ie set to NULL) -> same type
|
---|
463 | // 6: delete new key (ie val still NULL) -> real delete
|
---|
464 | descr=document.getElementById('newdescr'+index).value;
|
---|
465 | origindex=0;
|
---|
466 | switch(updcase)
|
---|
467 | {
|
---|
468 | case 5:
|
---|
469 | prog=document.getElementById('prog'+index).value;
|
---|
470 | key1=document.getElementById('1key'+index).value;
|
---|
471 | key2=document.getElementById('2key'+index).value;
|
---|
472 | val=document.getElementById('newval'+index).innerHTML;
|
---|
473 | type=document.getElementById('newtype'+index).value;
|
---|
474 | break;
|
---|
475 | case 1:
|
---|
476 | //prog=document.getElementById('prog'+index).value;
|
---|
477 | prog=document.getElementById('prog'+index).innerHTML;
|
---|
478 | key1=document.getElementById('1key'+index).value;
|
---|
479 | key2=document.getElementById('2key'+index).value;
|
---|
480 | val=document.getElementById('newval'+index).innerHTML;
|
---|
481 | type=document.getElementById('newtype'+index).value;
|
---|
482 | break;
|
---|
483 | case 2:
|
---|
484 | //prog=document.getElementById('prog'+index).value;
|
---|
485 | prog=document.getElementById('prog'+index).innerHTML;
|
---|
486 | key1=document.getElementById('1key'+index).innerHTML;
|
---|
487 | key2=document.getElementById('2key'+index).innerHTML;
|
---|
488 | val=document.getElementById('newval'+index).value;
|
---|
489 | type=document.getElementById('type'+index).innerHTML;
|
---|
490 | break;
|
---|
491 | case 3:
|
---|
492 | prog=document.getElementById('prog'+index).innerHTML;
|
---|
493 | key1=document.getElementById('1key'+index).innerHTML;
|
---|
494 | key2=document.getElementById('2key'+index).innerHTML;
|
---|
495 | type=document.getElementById('type'+index).innerHTML;
|
---|
496 | val="hallo";
|
---|
497 | if (type=="bool")
|
---|
498 | {
|
---|
499 | radio=document.getElementsByName('boolbox');
|
---|
500 | for (i=0; i< radio.length; i++)
|
---|
501 | if (radio[i].checked)
|
---|
502 | val=radio[i].value;
|
---|
503 | }
|
---|
504 | else
|
---|
505 | val=document.getElementById('newval'+index).value;
|
---|
506 | origindex=document.getElementById('1origindex'+index).innerHTML;
|
---|
507 | break;
|
---|
508 | case 4:
|
---|
509 | case 6:
|
---|
510 | answer = confirm("Do you really want to delete the value?");
|
---|
511 | if (!answer)
|
---|
512 | return;
|
---|
513 | prog=document.getElementById('prog'+index).innerHTML;
|
---|
514 | key1=document.getElementById('1key'+index).innerHTML;
|
---|
515 | key2=document.getElementById('2key'+index).innerHTML;
|
---|
516 | val=document.getElementById('newval'+index).value;
|
---|
517 | if (!val)
|
---|
518 | val="NULL";
|
---|
519 | type=document.getElementById('type'+index).innerHTML;
|
---|
520 | origindex=document.getElementById('1origindex'+index).innerHTML;
|
---|
521 | break;
|
---|
522 | }
|
---|
523 | if (!descr)
|
---|
524 | alert("Please insert description!");
|
---|
525 | if (!key1)
|
---|
526 | alert("Please insert key1!");
|
---|
527 | if (!key2)
|
---|
528 | alert("Please insert key2!");
|
---|
529 | if (!val)
|
---|
530 | alert("Please insert value!");
|
---|
531 | if (!val || !descr || !key1 || !key2)
|
---|
532 | return;
|
---|
533 | if (index==0)
|
---|
534 | index=-1;
|
---|
535 |
|
---|
536 | //check if value has correct type
|
---|
537 | // for string no check needed
|
---|
538 | if (updcase==3)
|
---|
539 | {
|
---|
540 | if (type=='int' && parseInt(val)!=val)
|
---|
541 | {
|
---|
542 | alert("Value is not a int.");
|
---|
543 | return;
|
---|
544 | }
|
---|
545 | if (type=='float' && parseFloat(val)!=val)
|
---|
546 | {
|
---|
547 | alert("Value is not a float.");
|
---|
548 | return;
|
---|
549 | }
|
---|
550 | if (type=='bool' && val!='yes' && val!='no')
|
---|
551 | {
|
---|
552 | alert("Value is neither 'yes' not 'no'.");
|
---|
553 | return;
|
---|
554 | }
|
---|
555 | }
|
---|
556 | if (!type && (updcase==2 || updcase==3 || updcase==4))
|
---|
557 | {
|
---|
558 | alert("Please select type!");
|
---|
559 | return;
|
---|
560 | }
|
---|
561 |
|
---|
562 | phpcall="insert_po.php?fUpdCase="+updcase+"&fIndex="+index+"&fOriginalIndex="+origindex+"&fProgram="+prog
|
---|
563 | +"&fKey1="+key1+"&fKey2="+key2+"&fValue="+val+"&fDescription="+descr+"&fType="+type;
|
---|
564 | //alert(phpcall);
|
---|
565 |
|
---|
566 | xmlhttp.open("GET", phpcall, false);
|
---|
567 | xmlhttp.send();
|
---|
568 |
|
---|
569 | // get somehow return value of inser_po.php
|
---|
570 | // to catch cases where insert was rejected due to no update
|
---|
571 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
572 | {
|
---|
573 | if (xmlhttp.responseText=="no change")
|
---|
574 | {
|
---|
575 | alert("You didn't change anything.");
|
---|
576 | return;
|
---|
577 | }
|
---|
578 | if (xmlhttp.responseText=="key exists")
|
---|
579 | {
|
---|
580 | alert("This key already exists. You cannot insert it a second time.");
|
---|
581 | return;
|
---|
582 | }
|
---|
583 | if (xmlhttp.responseText=="prog exists")
|
---|
584 | {
|
---|
585 | alert("This program already exists. You cannot insert it a second time.");
|
---|
586 | return;
|
---|
587 | }
|
---|
588 | alert(xmlhttp.responseText);
|
---|
589 | }
|
---|
590 | else
|
---|
591 | alert("Mist! "+xmlhttp.responseText);
|
---|
592 |
|
---|
593 | //reload the content of the page
|
---|
594 | progselect=document.getElementById("prog");
|
---|
595 | if (!progselect)
|
---|
596 | oldprog=prog;
|
---|
597 | else
|
---|
598 | if (progselect.options[progselect.selectedIndex])
|
---|
599 | oldprog=progselect.options[progselect.selectedIndex].value;
|
---|
600 | else
|
---|
601 | oldprog=prog;
|
---|
602 | keyselect=document.getElementById("key");
|
---|
603 | if (!keyselect)
|
---|
604 | oldkey=key1+"."+key2;
|
---|
605 | else
|
---|
606 | if (keyselect.options[keyselect.selectedIndex])
|
---|
607 | oldkey=keyselect.options[keyselect.selectedIndex].value;
|
---|
608 | else
|
---|
609 | oldkey=key1+"."+key2;
|
---|
610 | //reload progs and keys
|
---|
611 | get_progs(oldprog, "10", "edit");
|
---|
612 | get_keys(oldprog, oldkey, "10", "edit");
|
---|
613 | //reload values
|
---|
614 | xmlhttp.open("GET","get_values.php?fGetValCase=1&fKey="+oldkey+"&fProgram="+oldprog,false);
|
---|
615 | xmlhttp.send();
|
---|
616 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
617 | document.getElementById('valuefield1').innerHTML = xmlhttp.responseText;
|
---|
618 | else
|
---|
619 | document.getElementById('valuefield1').innerHTML = "argh";
|
---|
620 | }
|
---|
621 |
|
---|
622 | function ShowCurrent()
|
---|
623 | {
|
---|
624 | for (var i = 1 ; i <= document.getElementById('maxindex').innerHTML ; i++)
|
---|
625 | if(document.getElementById('old'+i))
|
---|
626 | document.getElementById('old'+i).style.display = "none";
|
---|
627 | document.getElementById('showcurrent').style.display = "none";
|
---|
628 | document.getElementById('showcurrent2').style.display = "none";
|
---|
629 | document.getElementById('showall').style.display = "";
|
---|
630 | document.getElementById('showall2').style.display = "";
|
---|
631 | }
|
---|
632 |
|
---|
633 | function ShowAll()
|
---|
634 | {
|
---|
635 | for (var i = 1 ; i <= document.getElementById('maxindex').innerHTML ; i++)
|
---|
636 | if(document.getElementById('old'+i))
|
---|
637 | {
|
---|
638 | document.getElementById('old'+i).style.display = "";
|
---|
639 | document.getElementById('old'+i).style.color = "grey";
|
---|
640 | }
|
---|
641 | document.getElementById('showcurrent').style.display = "";
|
---|
642 | document.getElementById('showcurrent2').style.display = "";
|
---|
643 | document.getElementById('showall').style.display = "none";
|
---|
644 | document.getElementById('showall2').style.display = "none";
|
---|
645 | }
|
---|
646 |
|
---|
647 | function InsertRow(table, row)
|
---|
648 | {
|
---|
649 | var x=document.getElementById('valtable'+table).insertRow(row);
|
---|
650 | for (var i = 0 ; i < 9 ; i++)
|
---|
651 | {
|
---|
652 | y=x.insertCell(i);
|
---|
653 | y.innerHTML=" ";
|
---|
654 | }
|
---|
655 | }
|
---|
656 |
|
---|
657 | function CompareValues()
|
---|
658 | {
|
---|
659 | counter=0;
|
---|
660 | maxindex2=document.getElementById('maxindex').innerHTML;
|
---|
661 | maxindex3=document.getElementById('maxindex3').innerHTML;
|
---|
662 | //alert(maxindex2);
|
---|
663 | //alert(maxindex3);
|
---|
664 | if (parseInt(maxindex2)>parseInt(maxindex3))
|
---|
665 | maxindex=maxindex2;
|
---|
666 | else
|
---|
667 | maxindex=maxindex3;
|
---|
668 |
|
---|
669 | for (var i = 1 ; i <= maxindex ; i++)
|
---|
670 | {
|
---|
671 | if (document.getElementById('2compare'+i))
|
---|
672 | {
|
---|
673 | counter++;
|
---|
674 | if (!document.getElementById('3compare'+i))
|
---|
675 | {
|
---|
676 | InsertRow(3,counter);
|
---|
677 | document.getElementById('2compare'+i).style.color='red';
|
---|
678 | }
|
---|
679 | else
|
---|
680 | {
|
---|
681 | val2=document.getElementById('2compare'+i).cells[5].innerHTML;
|
---|
682 | val3=document.getElementById('3compare'+i).cells[5].innerHTML;
|
---|
683 | if (val2!=val3)
|
---|
684 | {
|
---|
685 | document.getElementById('2compare'+i).style.color='blue';
|
---|
686 | document.getElementById('3compare'+i).style.color='blue';
|
---|
687 | }
|
---|
688 | }
|
---|
689 | }
|
---|
690 | else
|
---|
691 | if (document.getElementById('3compare'+i))
|
---|
692 | {
|
---|
693 | counter++;
|
---|
694 | InsertRow(2,counter);
|
---|
695 | document.getElementById('3compare'+i).style.color='green';
|
---|
696 | }
|
---|
697 | }
|
---|
698 | //document.getElementById('comparevals').style.display = "none";
|
---|
699 | }
|
---|
700 |
|
---|
701 | function HideDescription(getvalcase)
|
---|
702 | {
|
---|
703 | for(var i=0;i<document.getElementsByTagName('*').length;i++)
|
---|
704 | if(document.getElementsByTagName('*')[i].className == 'description'+getvalcase)
|
---|
705 | document.getElementsByTagName('*')[i].style.display = 'none';
|
---|
706 | document.getElementById('hidedescr'+getvalcase).style.display = "none";
|
---|
707 | document.getElementById('showdescr'+getvalcase).style.display = "";
|
---|
708 | }
|
---|
709 |
|
---|
710 | function ShowDescription(getvalcase)
|
---|
711 | {
|
---|
712 | for(var i=0;i<document.getElementsByTagName('*').length;i++)
|
---|
713 | if(document.getElementsByTagName('*')[i].className == 'description'+getvalcase)
|
---|
714 | document.getElementsByTagName('*')[i].style.display = '';
|
---|
715 | document.getElementById('showdescr'+getvalcase).style.display = "none";
|
---|
716 | document.getElementById('hidedescr'+getvalcase).style.display = "";
|
---|
717 | }
|
---|
718 |
|
---|
719 | function ShowDateInput(idx)
|
---|
720 | {
|
---|
721 | document.getElementById('datepulldown'+idx).style.display = "none";
|
---|
722 | document.getElementById('dateinput'+idx).style.display = "";
|
---|
723 | set_statusdate(idx, get_statusdate(idx, 'pulldown'));
|
---|
724 | }
|
---|
725 |
|
---|
726 | function ShowDatePulldown(idx)
|
---|
727 | {
|
---|
728 | document.getElementById('datepulldown'+idx).style.display = "";
|
---|
729 | document.getElementById('dateinput'+idx).style.display = "none";
|
---|
730 | set_statusdate(idx, get_statusdate(idx, 'textinput'));
|
---|
731 | }
|
---|
732 |
|
---|
733 | function reset_dates(datename, dateval, dateval2, idx)
|
---|
734 | {
|
---|
735 | radio=document.getElementsByName('dateformat'+idx);
|
---|
736 | for (i=0; i< radio.length; i++)
|
---|
737 | if (radio[i].checked)
|
---|
738 | val=radio[i].value;
|
---|
739 | if (val=="pulldown")
|
---|
740 | {
|
---|
741 | //alert("reset:"+datename+"-"+dateval+"-"+dateval2+"-"+idx);
|
---|
742 | if (datename=="year")
|
---|
743 | {
|
---|
744 | get_dates("year", dateval, dateval2, idx);
|
---|
745 | get_dates("month", dateval, dateval2, idx);
|
---|
746 | }
|
---|
747 |
|
---|
748 | if (datename=="year" || datename=="month")
|
---|
749 | if (datename=="month")
|
---|
750 | get_dates("day", dateval, dateval2, idx);
|
---|
751 | else
|
---|
752 | get_dates("day", "empty", "empty", idx);
|
---|
753 |
|
---|
754 | if (datename=="year" || datename=="month" || datename=="day")
|
---|
755 | if (datename=="day")
|
---|
756 | get_dates("hour", dateval, dateval2, idx);
|
---|
757 | else
|
---|
758 | get_dates("hour", "empty", "empty", idx);
|
---|
759 |
|
---|
760 | if (datename=="year" || datename=="month" || datename=="day" || datename=="hour")
|
---|
761 | if (datename=="hour")
|
---|
762 | get_dates("min", dateval, dateval2, idx);
|
---|
763 | else
|
---|
764 | get_dates("min", "empty", "empty", idx);
|
---|
765 |
|
---|
766 | if (datename=="year" || datename=="month" || datename=="day" || datename=="hour" || datename=="min")
|
---|
767 | if (datename=="min")
|
---|
768 | get_dates("sec", dateval, dateval2, idx);
|
---|
769 | else
|
---|
770 | get_dates("sec", "empty", "empty", idx);
|
---|
771 | }
|
---|
772 | if (val=="textinput")
|
---|
773 | document.getElementById('statusdate'+idx).value="";
|
---|
774 | }
|
---|
775 | function get_dates(datename, dateval, datevalprev, idx, reset)
|
---|
776 | {
|
---|
777 | //alert(datename+"_"+dateval+"_"+datevalprev+"_"+idx);
|
---|
778 | phpcall="get_date.php?fDateValue="+dateval+"&fDateValuePrev="+datevalprev+"&fDateName="+datename+"&fIdx="+idx;
|
---|
779 | //alert(phpcall);
|
---|
780 | xmlhttp.open("GET",phpcall,false);
|
---|
781 | xmlhttp.send();
|
---|
782 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
783 | document.getElementById(datename+'select'+idx).innerHTML = xmlhttp.responseText;
|
---|
784 | else
|
---|
785 | document.getElementById(datename+'select'+idx).innerHTML = "argh";
|
---|
786 |
|
---|
787 | //to be able to do no reset in case when the function is called from reset_dates()
|
---|
788 | if (reset)
|
---|
789 | reset_dates(datename, "empty", "empty", idx);
|
---|
790 | }
|
---|
791 |
|
---|
792 | function set_statusdate(getvalcase, statusdate)
|
---|
793 | {
|
---|
794 | //alert(statusdate);
|
---|
795 |
|
---|
796 | radio=document.getElementsByName('dateformat'+getvalcase);
|
---|
797 | for (i=0; i< radio.length; i++)
|
---|
798 | if (radio[i].checked)
|
---|
799 | val=radio[i].value;
|
---|
800 | if (val=="pulldown")
|
---|
801 | {
|
---|
802 | //check whole string
|
---|
803 | if (statusdate=="")
|
---|
804 | {
|
---|
805 | //set all values to 'empty'
|
---|
806 | get_dates("year", "empty", "empty", getvalcase, "yes");
|
---|
807 | return;
|
---|
808 | }
|
---|
809 | dates=statusdate.split("-",3);
|
---|
810 | //check year
|
---|
811 | if (!dates[0])
|
---|
812 | {
|
---|
813 | get_dates("year", "empty", "empty", getvalcase, "yes");
|
---|
814 | return;
|
---|
815 | }
|
---|
816 | else
|
---|
817 | get_dates("year", dates[0], dates[0], getvalcase);
|
---|
818 | //check month
|
---|
819 | if (!dates[1])
|
---|
820 | {
|
---|
821 | get_dates("month", "empty", "empty", getvalcase, "yes");
|
---|
822 | return;
|
---|
823 | }
|
---|
824 | else
|
---|
825 | get_dates("month", dates[1], dates[0], getvalcase);
|
---|
826 | //check rest of string
|
---|
827 | if (!dates[2])
|
---|
828 | {
|
---|
829 | get_dates("day", "empty", "empty", getvalcase, "yes");
|
---|
830 | return;
|
---|
831 | }
|
---|
832 | rests=dates[2].split(" ",2);
|
---|
833 | //check day
|
---|
834 | if (!rests[0])
|
---|
835 | {
|
---|
836 | get_dates("day", "empty", "empty", getvalcase, "yes");
|
---|
837 | return;
|
---|
838 | }
|
---|
839 | else
|
---|
840 | get_dates("day", rests[0], dates[1], getvalcase);
|
---|
841 | //check rest of string
|
---|
842 | if (!rests[1])
|
---|
843 | {
|
---|
844 | get_dates("hour", "empty", "empty", getvalcase, "yes");
|
---|
845 | return;
|
---|
846 | }
|
---|
847 | times=rests[1].split(":",3);
|
---|
848 | //check hour
|
---|
849 | if (!times[0])
|
---|
850 | {
|
---|
851 | get_dates("hour", "empty", "empty", getvalcase, "yes");
|
---|
852 | return;
|
---|
853 | }
|
---|
854 | else
|
---|
855 | get_dates("hour", times[0], rests[0], getvalcase);
|
---|
856 | //check minutes
|
---|
857 | if (!times[1])
|
---|
858 | {
|
---|
859 | get_dates("min", "empty", "empty", getvalcase, "yes");
|
---|
860 | return;
|
---|
861 | }
|
---|
862 | else
|
---|
863 | get_dates("min", times[1], times[0], getvalcase);
|
---|
864 | //check seconds
|
---|
865 | if (!times[2])
|
---|
866 | {
|
---|
867 | get_dates("sec", "empty", "empty", getvalcase, "yes");
|
---|
868 | return;
|
---|
869 | }
|
---|
870 | else
|
---|
871 | get_dates("sec", times[2], times[1], getvalcase);
|
---|
872 |
|
---|
873 | }
|
---|
874 | if (val=="textinput")
|
---|
875 | document.getElementById('statusdate'+getvalcase).value=statusdate;
|
---|
876 |
|
---|
877 | }
|
---|
878 |
|
---|
879 |
|
---|
880 | function get_timestamp(getvalcase, direction)
|
---|
881 | {
|
---|
882 | statusdate=get_statusdate(getvalcase);
|
---|
883 |
|
---|
884 | xmlhttp.open("GET","get_timestamp.php?fStatusDate="+statusdate+"&fDirection="+direction,false);
|
---|
885 | xmlhttp.send();
|
---|
886 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
887 | newstatusdate = xmlhttp.responseText;
|
---|
888 | else
|
---|
889 | newstatusdate = "argh";
|
---|
890 |
|
---|
891 | set_statusdate(getvalcase, newstatusdate);
|
---|
892 | }
|
---|