source: schedule/function/SplitDelete.php@ 16535

Last change on this file since 16535 was 16535, checked in by tanio, 12 years ago
File size: 20.7 KB
Line 
1<script type="text/javascript">
2 $(document).ready(function(){
3 var timeValue;
4var meas;
5var meas2;
6var getTableId;
7 window.cnt=2;
8 var table = document.createElement("table");
9 table.setAttribute('id',"table2");
10 table.setAttribute('width','100%');
11 var tr = document.createElement('tr');
12 var td3=document.createElement('td');
13 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
14 td3.appendChild(
15 input = document.createElement("input"),
16 input.setAttribute("type","time"),
17 input.setAttribute("id","Time1"),
18 input.setAttribute("max","24"),
19 input.setAttribute("min","1"),
20 input.setAttribute("required",true)
21
22 );
23 td3.appendChild(
24 button=document.createElement('input'),
25 button.setAttribute('type','button'),
26 button.setAttribute('value','[+]'),
27 button.setAttribute('id','btnAddTime'),
28 button.onclick=function(){
29
30
31
32 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01;
33
34 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
35
36 function pad(number, length) {
37
38 var str = '' + number;
39 while (str.length < length) {
40 str = '0' + str;
41 }
42
43 return str;
44
45 }
46
47 meas = "name"; meas2 = "time"; getTableId = '#table2'; split1(); }else{ alert("please enter value for time to add measurement"); }
48
49
50 }
51 );
52 var td=document.createElement('td');
53 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
54 td.appendChild(
55 sourcecbo= document.createElement('select'),
56 sourcecbo.setAttribute('id','source1'),
57<?php
58 $source=mysql_query("SELECT*FROM source");
59 while($rowsource=mysql_fetch_array($source))
60 {
61?>
62 sourcecbo.appendChild(
63 option=document.createElement('option'),
64
65 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
66 option.setAttribute('selected',true),
67
68 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
69
70
71 ),
72<?php
73 }
74?>
75 sourcecbo.setAttribute('id','source1')
76
77 );
78 var td1=document.createElement('td');
79 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
80 td1.appendChild(
81 measurementcbo= document.createElement('select'),
82 measurementcbo.setAttribute('id','measurement1'),
83<?php
84 $measure=mysql_query("SELECT*FROM measurement");
85 while($rowmeasure=mysql_fetch_array($measure))
86 {
87?>
88 measurementcbo.appendChild(
89 option=document.createElement('option'),
90 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
91 option.setAttribute('selected',true),
92 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
93 ),
94<?php
95 }
96?>
97 measurementcbo.setAttribute('id','measurement1')
98 );
99 td1.appendChild(
100 button=document.createElement('input'),
101 button.setAttribute('type','button'),
102 button.setAttribute('value','[+]'),
103 button.setAttribute('id','btnAddTime'),
104 button.onclick=function(){
105 if($('#Time1').val() != ""){ timeValue = $('#Time1').val(); meas = "hidden"; meas2 = true; getTableId = '#table2'; split1(); }else{ alert("please enter value for time to add measurement"); }
106
107
108 }
109 );
110 var td2=document.createElement('td');
111 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
112 td2.appendChild(
113 input = document.createElement('input'),
114 input.setAttribute('type','text'),
115 input.setAttribute('id','txtData1')
116
117
118 );
119 var td4=document.createElement('td');
120 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
121 td4.appendChild(
122 button = document.createElement('input'),
123 button.setAttribute("type",'button'),
124 button.setAttribute('id','btnSplit'),
125 button.setAttribute('value','Split'),
126 button.onclick= function()
127 {
128
129 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 30;
130
131
132 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
133
134 function pad(number, length) {
135
136 var str = '' + number;
137 while (str.length < length) {
138 str = '0' + str;
139 }
140
141 return str;
142
143 }
144
145 meas = "name"; meas2 = "time"; getTableId = '#table2'; split1(); }else{ alert("please enter value for time to add measurement"); }
146
147
148
149 }
150 );
151 td4.appendChild(
152 button=document.createElement('input'),
153 button.setAttribute('type','button'),
154 button.setAttribute('value','Delete'),
155 button.setAttribute('id','btnDelete'),
156 button.onclick=function(){
157 $('#table2').remove();
158 }
159 );
160
161 tr.appendChild(td3);
162 tr.appendChild(td1);
163 tr.appendChild(td);
164
165 tr.appendChild(td2);
166 tr.appendChild(td4);
167 table.appendChild(tr);
168
169 $('#TableH1').append(table);
170
171
172
173 var table = document.createElement("table");
174 table.setAttribute('id',"table1");
175 table.setAttribute('width','100%');
176 var tr = document.createElement('tr');
177 tr.setAttribute('id','');
178 tr.setAttribute('class','');
179 var td3=document.createElement('td');
180 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
181 td3.appendChild(
182 input = document.createElement("input"),
183 input.setAttribute("type","time"),
184 input.setAttribute("id","Time2"),
185 input.setAttribute("max","24"),
186 input.setAttribute("min","1"),
187 input.setAttribute("required",true)
188 );
189 td3.appendChild(
190 button=document.createElement('input'),
191 button.setAttribute('type','button'),
192 button.setAttribute('value','[+]'),
193 button.setAttribute('id','btnAddTime'),
194 button.onclick=function(){
195 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;
196
197 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
198
199 function pad(number, length) {
200
201 var str = '' + number;
202 while (str.length < length) {
203 str = '0' + str;
204 }
205
206 return str;
207
208 } meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
209
210
211 }
212 );
213 var td=document.createElement('td');
214 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
215 td.appendChild(
216 sourcecbo= document.createElement('select'),
217 sourcecbo.setAttribute('id','source2'),
218<?php
219 $source=mysql_query("SELECT*FROM source");
220 while($rowsource=mysql_fetch_array($source))
221 {
222?>
223 sourcecbo.appendChild(
224 option=document.createElement('option'),
225 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
226 option.setAttribute('selected',true),
227 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
228
229 ),
230<?php
231 }
232 ?>
233 sourcecbo.setAttribute('id','source2')
234
235 );
236 var td1=document.createElement('td');
237 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
238 td1.appendChild(
239 measurementcbo= document.createElement('select'),
240 measurementcbo.setAttribute('id','measurement2'),
241<?php
242 $measure=mysql_query("SELECT*FROM measurement");
243 while($rowmeasure=mysql_fetch_array($measure))
244 {
245?>
246 measurementcbo.appendChild(
247 option=document.createElement('option'),
248 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
249 option.setAttribute('selected',true),
250 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
251 ),
252<?php
253 }
254?>
255 measurementcbo.setAttribute('id','measurement2')
256 );
257 td1.appendChild(
258 button=document.createElement('input'),
259 button.setAttribute('type','button'),
260 button.setAttribute('value','[+]'),
261 button.setAttribute('id','btnAddTime'),
262 button.onclick=function(){
263 if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); meas = "hidden"; meas2 = true; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
264
265
266 }
267 );
268 var td2=document.createElement('td');
269 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
270 td2.appendChild(
271 input = document.createElement('input'),
272 input.setAttribute('type','text'),
273 input.setAttribute('id','txtData2')
274
275 );
276 var td4=document.createElement('td');
277 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
278 td4.appendChild(
279 button = document.createElement('input'),
280 button.setAttribute("type",'button'),
281 button.setAttribute('id','btnSplit'),
282 button.setAttribute('value','Split'),
283 button.onclick= function()
284 {
285 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 30;
286
287 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
288
289 function pad(number, length) {
290
291 var str = '' + number;
292 while (str.length < length) {
293 str = '0' + str;
294 }
295
296 return str;
297
298 }
299
300 meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); }
301
302 }
303 );
304 td4.appendChild(
305 button=document.createElement('input'),
306 button.setAttribute('type','button'),
307 button.setAttribute('value','Delete'),
308 button.setAttribute('id','btnDelete'),
309 button.onclick=function(){
310 $('#table1').remove();
311
312 }
313 );
314
315 tr.appendChild(td3);
316 tr.appendChild(td1);
317 tr.appendChild(td);
318
319 tr.appendChild(td2);
320 tr.appendChild(td4);
321 table.appendChild(tr);
322
323 $('#TableH1').append(table);
324
325 var meas;
326 var timeValue;
327
328 function split()
329 {
330
331 cnt++;
332 var table = document.createElement("table");
333 table.setAttribute('id',"table"+cnt);
334 table.setAttribute('width','100%');
335 var tr = document.createElement('tr');
336 tr.setAttribute('id','');
337 tr.setAttribute('class','');
338
339 var td3=document.createElement('td');
340 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
341 td3.setAttribute('class','first');
342
343 td3.appendChild(
344 input = document.createElement("input"),
345 input.setAttribute("type","time"),
346 input.setAttribute("id","Time"+cnt),
347 input.setAttribute("max","24"),
348 input.setAttribute("min","1"),
349 input.setAttribute("required",true),
350 input.setAttribute(meas,meas2),
351 input.setAttribute("value",timeValue)
352
353 );
354 td3.appendChild(
355 button=document.createElement('input'),
356 button.setAttribute('type','button'),
357 button.setAttribute('value','[+]'),
358 button.setAttribute('id','btnAddTime'),
359 button.setAttribute(meas,meas2),
360 button.onclick=function(){
361 if($('#Time'+cnt).val() != ""){var splitting = $('#Time'+cnt).val().split(':'); var add = 01;
362
363 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
364
365 function pad(number, length) {
366
367 var str = '' + number;
368 while (str.length < length) {
369 str = '0' + str;
370 }
371
372 return str;
373
374 } meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
375
376
377 }
378 );
379
380 var td=document.createElement('td');
381 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
382 td.appendChild(
383 sourcecbo= document.createElement('select'),
384 sourcecbo.setAttribute('id','source'+cnt),
385<?php
386 $source=mysql_query("SELECT*FROM source");
387 while($rowsource=mysql_fetch_array($source))
388 {
389?>
390 sourcecbo.appendChild(
391 option=document.createElement('option'),
392 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
393 option.setAttribute('selected',true),
394 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
395
396 ),
397<?php
398 }
399 ?>
400 sourcecbo.setAttribute('id','source'+cnt)
401
402 );
403 var td1=document.createElement('td');
404 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
405 td1.appendChild(
406 measurementcbo= document.createElement('select'),
407 measurementcbo.setAttribute('id','measurement'+cnt),
408<?php
409 $measure=mysql_query("SELECT*FROM measurement");
410 while($rowmeasure=mysql_fetch_array($measure))
411 {
412?>
413 measurementcbo.appendChild(
414 option=document.createElement('option'),
415 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
416 option.setAttribute('selected',true),
417 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
418 ),
419<?php
420 }
421?>
422 measurementcbo.setAttribute('id','measurement'+cnt)
423 );
424 td1.appendChild(
425 button=document.createElement('input'),
426 button.setAttribute('type','button'),
427 button.setAttribute('value','[+]'),
428 button.setAttribute('id','btnAddTime'),
429 button.onclick=function(){
430
431 if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
432
433
434 }
435 );
436
437 var td2=document.createElement('td');
438 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
439 td2.appendChild(
440 input = document.createElement('input'),
441 input.setAttribute('type','text'),
442 input.setAttribute('id','txtData'+cnt)
443
444 );
445 var td4=document.createElement('td');
446 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
447 td4.appendChild(
448 button = document.createElement('input'),
449 button.setAttribute("type",'button'),
450 button.setAttribute('id','btnSplit'),
451 button.setAttribute('value','Split'),
452 button.onclick=function(){
453 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 30;
454
455 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
456
457 function pad(number, length) {
458
459 var str = '' + number;
460 while (str.length < length) {
461 str = '0' + str;
462 }
463
464 return str;
465
466 }
467
468 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split(); }else{ alert("please enter value for time to add measurement"); }
469 }
470 );
471 td4.appendChild(
472 button=document.createElement('input'),
473 button.setAttribute('type','button'),
474 button.setAttribute('value','Delete'),
475 button.setAttribute('id','btnDelete'),
476 button.onclick=function(){
477 $('#table'+cnt).remove();
478 cnt--;
479 }
480 );
481
482 tr.appendChild(td3);
483 tr.appendChild(td1);
484 tr.appendChild(td);
485
486 tr.appendChild(td2);
487 tr.appendChild(td4);
488 table.appendChild(tr);
489
490 $(table).insertAfter($(getTableId));
491
492
493
494 }
495 function split1()
496 {
497
498 cnt++;
499 var table = document.createElement("table");
500 table.setAttribute('id',"table"+cnt);
501 table.setAttribute('width','100%');
502 var tr = document.createElement('tr');
503 tr.setAttribute('id','');
504 tr.setAttribute('class','');
505
506 var td3=document.createElement('td');
507 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
508 td3.setAttribute('class','first');
509 td3.appendChild(
510 input = document.createElement("input"),
511 input.setAttribute("type","time"),
512 input.setAttribute("id","Time"+cnt),
513 input.setAttribute("max","24"),
514 input.setAttribute("min","1"),
515 input.setAttribute("required",true),
516 input.setAttribute(meas,meas2),
517 input.setAttribute("value",timeValue)
518 );
519 td3.appendChild(
520 button=document.createElement('input'),
521 button.setAttribute('type','button'),
522 button.setAttribute('value','[+]'),
523 button.setAttribute('id','btnAddTime'),
524 button.setAttribute(meas,meas2),
525 button.onclick=function(){
526 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 01;
527
528 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
529
530 function pad(number, length) {
531
532 var str = '' + number;
533 while (str.length < length) {
534 str = '0' + str;
535 }
536
537 return str;
538
539 } meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
540
541
542 }
543 );
544
545 var td=document.createElement('td');
546 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
547 td.appendChild(
548 sourcecbo= document.createElement('select'),
549 sourcecbo.setAttribute('id','source'+cnt),
550<?php
551 $source=mysql_query("SELECT*FROM source");
552 while($rowsource=mysql_fetch_array($source))
553 {
554?>
555 sourcecbo.appendChild(
556 option=document.createElement('option'),
557 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
558 option.setAttribute('selected',true),
559 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
560
561 ),
562<?php
563 }
564 ?>
565 sourcecbo.setAttribute('id','source'+cnt)
566
567 );
568 var td1=document.createElement('td');
569 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
570
571 td1.appendChild(
572 measurementcbo= document.createElement('select'),
573 measurementcbo.setAttribute('id','measurement'+cnt),
574<?php
575 $measure=mysql_query("SELECT*FROM measurement");
576 while($rowmeasure=mysql_fetch_array($measure))
577 {
578?>
579 measurementcbo.appendChild(
580 option=document.createElement('option'),
581 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
582 option.setAttribute('selected',true),
583 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
584 ),
585<?php
586 }
587?>
588 measurementcbo.setAttribute('id','measurement'+cnt)
589 );
590 td1.appendChild(
591 button=document.createElement('input'),
592 button.setAttribute('type','button'),
593 button.setAttribute('value','[+]'),
594 button.setAttribute('id','btnAddTime'),
595 button.onclick=function(){
596
597 if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); }
598
599
600 }
601 );
602
603 var td2=document.createElement('td');
604 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
605 td2.appendChild(
606 input = document.createElement('input'),
607 input.setAttribute('type','text'),
608 input.setAttribute('id','txtData'+cnt)
609
610 );
611 var td4=document.createElement('td');
612 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
613 td4.appendChild(
614 button = document.createElement('input'),
615 button.setAttribute("type",'button'),
616 button.setAttribute('id','btnSplit'),
617 button.setAttribute('value','Split'),
618 button.onclick=function(){
619 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 30;
620
621 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
622
623 function pad(number, length) {
624
625 var str = '' + number;
626 while (str.length < length) {
627 str = '0' + str;
628 }
629
630 return str;
631
632 }
633
634 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split(); }else{ alert("please enter value for time to add measurement"); }
635 }
636 );
637 td4.appendChild(
638 button=document.createElement('input'),
639 button.setAttribute('type','button'),
640 button.setAttribute('value','Delete'),
641 button.setAttribute('id','btnDelete'),
642 button.onclick=function(){
643 $('#table'+cnt).remove();
644 cnt--;
645 });
646
647 tr.appendChild(td3);
648 tr.appendChild(td1);
649 tr.appendChild(td);
650
651 tr.appendChild(td2);
652 tr.appendChild(td4);
653 table.appendChild(tr);
654
655 $(table).insertAfter($(getTableId));
656 }
657
658 });
659 </script>
Note: See TracBrowser for help on using the repository browser.