1 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * @package phpMyAdmin-Designer
13 var sm_x
= 2, sm_y
= 2;
20 var ON_display_field
= 0;
21 // relation_style: 0 - angular 1 - direct
22 var ON_angular_direct
= 1;
24 var link_relation
= "";
27 var canvas_height
= 0;
28 var osn_tab_width
= 0;
29 var osn_tab_height
= 0;
33 var layer_menu_cur_click
= 0;
39 //------------------------------------------------------------------------------
40 //------------------------------------------------------------------------------
41 //------------------------------------------------------------------------------
44 //window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
46 document
.onmousedown
= MouseDown
;
47 document
.onmouseup
= MouseUp
;
48 document
.onmousemove
= MouseMove
;
50 var isIE
= document
.all
&& !window
.opera
;
51 var isNN
= !document
.all
&& document
.getElementById
;
52 var isN4
= document
.layers
;
55 window
.onscroll
= General_scroll
;
56 document
.onselectstart = function () {return false;};
59 //document.onmouseup = function(){General_scroll_end();}
63 if (cur_click
!= null) {
64 offsetx
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
65 offsety
= isIE
? event
.clientY
+ document
.body
.scrollTop
: e
.pageY
;
66 dx
= offsetx
- parseInt(cur_click
.style
.left
);
67 dy
= offsety
- parseInt(cur_click
.style
.top
);
68 //alert(" dx = " + dx + " dy = " +dy);
69 document
.getElementById("canvas").style
.visibility
= 'hidden';
71 var left = parseInt(cur_click.style.left);
72 var top = parseInt(cur_click.style.top);
76 alert(" dx = " + dx + " dy = " +dy);
78 cur_click
.style
.zIndex
= 2;
80 if (layer_menu_cur_click
) {
81 offsetx
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
82 dx
= offsetx
- parseInt(document
.getElementById("layer_menu").style
.width
);
90 Glob_X
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
91 Glob_Y
= isIE
? event
.clientY
+ document
.body
.scrollTop
: e
.pageY
;
93 //mouseX = (bw.ns4||bw.ns6)? e.pageX: bw.ie&&bw.win&&!bw.ie4? (event.clientX-2)+document.body.scrollLeft : event.clientX+document.body.scrollLeft;
94 //mouseY = (bw.ns4||bw.ns6)? e.pageY: bw.ie&&bw.win&&!bw.ie4? (event.clientY-2)+document.body.scrollTop : event.clientY+document.body.scrollTop;
96 //window.status = "X = "+ Glob_X + " Y = "+ Glob_Y;
98 if (cur_click
!= null) {
99 var mGx
= Glob_X
- dx
;
100 var mGy
= Glob_Y
- dy
;
101 mGx
= mGx
> 0 ? mGx
: 0;
102 mGy
= mGy
> 0 ? mGy
: 0;
105 mGx
= mGx
% step
< step
/ 2 ? mGx
- mGx
% step
: mGx
- mGx
% step
+ step
;
106 mGy
= mGy
% step
< step
/ 2 ? mGy
- mGy
% step
: mGy
- mGy
% step
+ step
;
109 cur_click
.style
.left
= mGx
+ 'px';
110 cur_click
.style
.top
= mGy
+ 'px';
113 if (ON_relation
|| ON_display_field
) {
114 document
.getElementById('hint').style
.left
= (Glob_X
+ 20) + 'px';
115 document
.getElementById('hint').style
.top
= (Glob_Y
+ 20) + 'px';
118 if (layer_menu_cur_click
) {
119 document
.getElementById("layer_menu").style
.width
= ((Glob_X
- dx
) >= 150 ? Glob_X
- dx
: 150) + 'px';
120 //document.getElementById("layer_menu").style.height = Glob_Y - dy>=200?Glob_Y - dy:200;
121 //document.getElementById("id_scroll_tab").style.height = Glob_Y - dy2;
127 if (cur_click
!= null) {
128 document
.getElementById("canvas").style
.visibility
= 'visible';
130 cur_click
.style
.zIndex
= 1;
133 layer_menu_cur_click
= 0;
134 //window.releaseEvents(Event.MOUSEMOVE);
136 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
138 //------------------------------------------------------------------------------
143 // return s.substring(0,s.length-2)*1; //re = /(\d+)\w*/; newstr = str.replace(re, "$1");
146 function Canvas_pos()
148 canvas_width
= document
.getElementById('canvas').width
= osn_tab_width
- 3;
149 canvas_height
= document
.getElementById('canvas').height
= osn_tab_height
- 3;
152 document
.getElementById('canvas').style
.width
= ((osn_tab_width
- 3)?(osn_tab_width
- 3):0) + 'px';
153 document
.getElementById('canvas').style
.height
= ((osn_tab_height
- 3)?(osn_tab_height
- 3):0) + 'px';
157 function Osn_tab_pos()
159 osn_tab_width
= parseInt(document
.getElementById('osn_tab').style
.width
);
160 osn_tab_height
= parseInt(document
.getElementById('osn_tab').style
.height
);
166 //alert( document.getElementById('osn_tab').offsetTop);
169 document
.getElementById('top_menu').style
.position
= 'absolute';
170 document
.getElementById('layer_menu').style
.position
= 'absolute';
173 document
.getElementById("layer_menu").style
.top
= -1000 + 'px'; //fast scroll
174 sm_x
+= document
.getElementById('osn_tab').offsetLeft
;
175 sm_y
+= document
.getElementById('osn_tab').offsetTop
;
180 id_hint
= document
.getElementById('hint');
187 //-------------------------------- new -----------------------------------------
188 function Rezize_osn_tab()
192 for (key
in j_tabs
) {
193 var k_x
= parseInt(document
.getElementById(key
).style
.left
) + document
.getElementById(key
).offsetWidth
;
194 var k_y
= parseInt(document
.getElementById(key
).style
.top
) + document
.getElementById(key
).offsetHeight
;
195 max_X
= max_X
< k_x
? k_x
: max_X
;
196 max_Y
= max_Y
< k_y
? k_y
: max_Y
;
199 osn_tab_width
= max_X
+ 50;
200 osn_tab_height
= max_Y
+ 50;
202 document
.getElementById('osn_tab').style
.width
= osn_tab_width
+ 'px';
203 document
.getElementById('osn_tab').style
.height
= osn_tab_height
+ 'px';
205 //------------------------------------------------------------------------------
208 * refreshes display, must be called after state changes
219 for (key
in contr
[K
]) // contr name
220 for (key2
in contr
[K
][key
]) // table name
221 for (key3
in contr
[K
][key
][key2
]) // field name
223 if (!document
.getElementById("check_vis_" + key2
).checked
||
224 !document
.getElementById("check_vis_" + contr
[K
][key
][key2
][key3
][0]).checked
) {
228 var x1_left
= document
.getElementById(key2
).offsetLeft
+1;
229 var x1_right
= x1_left
+ document
.getElementById(key2
).offsetWidth
;
230 var x2_left
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetLeft
;
231 var x2_right
= x2_left
+ document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetWidth
;
232 a
[0] = Math
.abs(x1_left
- x2_left
);
233 a
[1] = Math
.abs(x1_left
- x2_right
);
234 a
[2] = Math
.abs(x1_right
- x2_left
);
235 a
[3] = Math
.abs(x1_right
- x2_right
);
236 n
= s_left
= s_right
= 0;
237 for (var i
= 1; i
< 4; i
++) {
244 x2
= x2_right
+ sm_s
;
250 x1
= x1_right
+ sm_s
;
257 x1
= x1_right
+ sm_s
;
258 x2
= x2_right
+ sm_s
;
266 //alert(key2 + "." + key3);
268 var row_offset_top
= 0;
269 //alert('id_tbody_' + key2);
270 //alert(document.getElementById('id_hide_tbody_' + key2));
271 var tab_hide_button
= document
.getElementById('id_hide_tbody_' + key2
);
273 //alert(tab_hide_button.innerHTML);
274 if (tab_hide_button
.innerHTML
== 'v') {
275 row_offset_top
= document
.getElementById(key2
+ "." + key3
).offsetTop
;
278 var y1
= document
.getElementById(key2
).offsetTop
284 var tab_hide_button
= document
.getElementById('id_hide_tbody_' + contr
[K
][key
][key2
][key3
][0]);
285 if (tab_hide_button
.innerHTML
== 'v') {
286 row_offset_top
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]
287 + '.' + contr
[K
][key
][key2
][key3
][1]).offsetTop
;
291 document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetTop
295 //alert(y1 + ' - ' + key2 + "." + key3);
296 Line0(x1
- sm_x
, y1
- sm_y
, x2
- sm_x
, y2
- sm_y
, getColorByTarget( contr
[K
][key
][key2
][key3
][0]+'.'+contr
[K
][key
][key2
][key3
][1] ) );
301 * draws a line from x1:y1 to x2:y2 with color
303 function Line(x1
, y1
, x2
, y2
, color_line
)
305 var canvas
= document
.getElementById("canvas");
306 var ctx
= canvas
.getContext("2d");
307 ctx
.strokeStyle
= color_line
;
316 * draws a relation/constraint line, whether angular or not
318 function Line0(x1
, y1
, x2
, y2
, color_line
)
320 Circle(x1
, y1
, 3, 3, color_line
);
321 Rect(x2
- 1, y2
- 2, 4, 4, color_line
);
323 if (ON_angular_direct
) {
324 Line2(x1
, y1
, x2
, y2
, color_line
);
326 Line3(x1
, y1
, x2
, y2
, color_line
);
331 * draws a angualr relation/constraint line
333 function Line2(x1
, y1
, x2
, y2
, color_line
)
344 } else if (x1
< x2
) {
352 Line(x1
, y1
, x1_
, y1
, color_line
);
353 Line(x2
, y2
, x2_
, y2
, color_line
);
354 Line(x1_
, y1
, x2_
, y2
, color_line
);
358 * draws a relation/constraint line
360 function Line3(x1
, y1
, x2
, y2
, color_line
)
367 x1_
+= x2
- x1
+ sm_add
;
370 x2_
+= x1
- x2
+ sm_add
;
374 Line(x1
, y1
, x1_
, y1
, color_line
);
375 Line(x2
, y2
, x2_
, y2
, color_line
);
376 Line(x1_
, y1
, x2_
, y2
, color_line
);
381 x2_
-= x2
- x1
+ sm_add
;
384 x1_
-= x1
- x2
+ sm_add
;
388 Line(x1
, y1
, x1_
, y1
, color_line
);
389 Line(x2
, y2
, x2_
, y2
, color_line
);
390 Line(x1_
, y1
, x2_
, y2
, color_line
);
394 var x_s
= (x1
+ x2
) / 2;
395 Line(x1
, y1
, x_s
, y1
, color_line
);
396 Line(x_s
, y2
, x2
, y2
, color_line
);
397 Line(x_s
, y1
, x_s
, y2
, color_line
);
400 function Circle(x
, y
, r
, w
, color
)
402 var ctx
= document
.getElementById('canvas').getContext('2d');
406 ctx
.strokeStyle
= color
;
407 ctx
.arc(x
, y
, r
, 0, 2 * Math
.PI
, true);
413 var canvas
= document
.getElementById("canvas");
414 var ctx
= canvas
.getContext("2d");
415 ctx
.clearRect(0, 0, canvas_width
, canvas_height
);
418 function Rect(x1
, y1
, w
, h
, color
)
420 var ctx
= document
.getElementById('canvas').getContext('2d');
421 ctx
.fillStyle
= color
;
422 ctx
.fillRect(x1
, y1
, w
, h
);
425 //------------------------------ SAVE ------------------------------------------
426 function Save(url
) // (del?) no for pdf
428 for (key
in j_tabs
) {
429 document
.getElementById('t_x_' + key
+ '_').value
= parseInt(document
.getElementById(key
).style
.left
);
430 document
.getElementById('t_y_' + key
+ '_').value
= parseInt(document
.getElementById(key
).style
.top
);
431 document
.getElementById('t_v_' + key
+ '_').value
= document
.getElementById('id_tbody_' + key
).style
.display
== 'none' ? 0 : 1;
432 document
.getElementById('t_h_' + key
+ '_').value
= document
.getElementById('check_vis_' + key
).checked
? 1 : 0;
434 document
.form1
.action
= url
;
435 document
.form1
.submit();
438 function Get_url_pos()
441 for (key
in j_tabs
) {
442 poststr
+= '&t_x[' + key
+ ']=' + parseInt(document
.getElementById(key
).style
.left
);
443 poststr
+= '&t_y[' + key
+ ']=' + parseInt(document
.getElementById(key
).style
.top
);
444 poststr
+= '&t_v[' + key
+ ']=' + (document
.getElementById('id_tbody_' + key
).style
.display
== 'none' ? 0 : 1);
445 poststr
+= '&t_h[' + key
+ ']=' + (document
.getElementById('check_vis_' + key
).checked
? 1 : 0);
452 var poststr
= 'IS_AJAX=1&server='+server
+'&db=' + db
+ '&token=' + token
+ '&die_save_pos=1';
453 poststr
+= Get_url_pos();
454 makeRequest('pmd_save_pos.php', poststr
);
461 document
.getElementById('grid_button').className
= 'M_butt_Selected_down';
463 document
.getElementById('grid_button').className
= 'M_butt';
468 function Angular_direct()
470 if (ON_angular_direct
) {
471 ON_angular_direct
= 0;
472 document
.getElementById('angular_direct_button').className
= 'M_butt_Selected_down';
474 ON_angular_direct
= 1;
475 document
.getElementById('angular_direct_button').className
= 'M_butt';
479 //++++++++++++++++++++++++++++++ RELATION ++++++++++++++++++++++++++++++++++++++
480 function Start_relation()
482 if (ON_display_field
) {
487 document
.getElementById('foreign_relation').style
.display
= '';
489 document
.getElementById('hint').innerHTML
= PMA_messages
['strSelectReferencedKey'];
490 document
.getElementById('hint').style
.visibility
= "visible";
491 document
.getElementById('rel_button').className
= 'M_butt_Selected_down';
493 document
.getElementById('hint').innerHTML
= "";
494 document
.getElementById('hint').style
.visibility
= "hidden";
495 document
.getElementById('rel_button').className
= 'M_butt';
501 function Click_field(T
, f
, PK
) // table field
505 //.style.display=='none' .style.visibility = "hidden"
507 alert(PMA_messages
['strPleaseSelectPrimaryOrUniqueKey']);
510 if (j_tabs
[db
+ '.' + T
] != '1') {
511 document
.getElementById('foreign_relation').style
.display
= 'none';
514 link_relation
= "T1=" + T
+ "&F1=" + f
;
515 document
.getElementById('hint').innerHTML
= PMA_messages
['strSelectForeignKey'];
517 Start_relation(); // hidden hint...
518 if (j_tabs
[db
+ '.' + T
] != '1' || !PK
) {
519 document
.getElementById('foreign_relation').style
.display
= 'none';
521 var left
= Glob_X
- (document
.getElementById('layer_new_relation').offsetWidth
>>1);
522 document
.getElementById('layer_new_relation').style
.left
= left
+ 'px';
523 var top
= Glob_Y
- document
.getElementById('layer_new_relation').offsetHeight
- 10;
524 document
.getElementById('layer_new_relation').style
.top
= top
+ 'px';
525 document
.getElementById('layer_new_relation').style
.visibility
= "visible";
526 link_relation
+= '&T2=' + T
+ '&F2=' + f
;
530 if (ON_display_field
) {
531 // if is display field
532 if (display_field
[T
] == f
) {
534 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ',';alert(s);
535 old_class
= 'tab_field';
536 //display_field.splice(T, 1);
537 delete display_field
[T
];
538 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ', ';alert(s);
539 //n = 0;for(k in display_field)n++;alert(n);
541 old_class
= 'tab_field_3';
542 if (display_field
[T
]) {
543 document
.getElementById('id_tr_' + T
+ '.' + display_field
[T
]).className
= 'tab_field';
544 //display_field.splice(T, 1);
545 delete display_field
[T
];
547 display_field
[T
] = f
;
549 ON_display_field
= 0;
550 document
.getElementById('hint').innerHTML
= "";
551 document
.getElementById('hint').style
.visibility
= "hidden";
552 document
.getElementById('display_field_button').className
= 'M_butt';
553 makeRequest('pmd_display_field.php', 'T=' + T
+ '&F=' + f
+ '&server=' + server
+ '&db=' + db
+ '&token=' + token
);
557 function New_relation()
559 document
.getElementById('layer_new_relation').style
.visibility
= 'hidden';
560 link_relation
+= '&server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&die_save_pos=0';
561 link_relation
+= '&on_delete=' + document
.getElementById('on_delete').value
+ '&on_update=' + document
.getElementById('on_update').value
;
562 link_relation
+= Get_url_pos();
564 //alert(link_relation);
565 makeRequest('pmd_relation_new.php', link_relation
);
568 //-------------------------- create tables -------------------------------------
570 function Start_table_new()
572 window
.location
.href
= 'db_operations.php?server=' + server
+ '&db=' + db
+ '&token=' + token
;
575 function Start_tab_upd(table
)
577 window
.location
.href
= 'tbl_structure.php?server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&table=' + table
;
579 //--------------------------- hide tables --------------------------------------
581 function Small_tab_all(id_this
) // max/min all tables
583 if (id_this
.alt
== "v") {
584 for (key
in j_tabs
) {
585 if (document
.getElementById('id_hide_tbody_'+key
).innerHTML
== "v") {
590 id_this
.src
= "pmd/images/rightarrow1.png";
592 for (key
in j_tabs
) {
593 if (document
.getElementById('id_hide_tbody_'+key
).innerHTML
!= "v") {
598 id_this
.src
= "pmd/images/downarrow1.png";
603 function Small_tab_invert() // invert max/min all tables
605 for (key
in j_tabs
) {
611 function Small_tab_refresh()
613 for (key
in j_tabs
) {
614 if(document
.getElementById('id_hide_tbody_'+key
).innerHTML
!= "v") {
621 function Small_tab(t
, re_load
)
623 var id
= document
.getElementById('id_tbody_' + t
);
624 var id_this
= document
.getElementById('id_hide_tbody_' + t
);
625 var id_t
= document
.getElementById(t
);
626 id_t
.style
.width
= id_t
.offsetWidth
+ 'px';
627 if (id_this
.innerHTML
== "v") {
629 id
.style
.display
= 'none';
630 id_this
.innerHTML
= '>';
632 id
.style
.display
= '';
633 id_this
.innerHTML
= 'v';
639 //------------------------------------------------------------------------------
640 function Select_tab(t
)
642 var id_zag
= document
.getElementById('id_zag_' + t
);
643 if (id_zag
.className
!= 'tab_zag_3') {
644 document
.getElementById('id_zag_' + t
).className
= 'tab_zag_2';
646 document
.getElementById('id_zag_' + t
).className
= 'tab_zag';
649 var id_t
= document
.getElementById(t
);
650 window
.scrollTo(parseInt(id_t
.style
.left
) - 300, parseInt(id_t
.style
.top
) - 300);
651 setTimeout(function(){document
.getElementById('id_zag_' + t
).className
= 'tab_zag';}, 800);
653 //------------------------------------------------------------------------------
655 function Canvas_click(id
)
658 var relation_name
= 0;
661 var Key0
, Key1
, Key2
, Key3
, Key
, x1
, x2
;
664 for (key
in contr
[K
])
665 for (key2
in contr
[K
][key
])
666 for (key3
in contr
[K
][key
][key2
]) {
667 if (!document
.getElementById("check_vis_"+key2
).checked
||
668 !document
.getElementById("check_vis_"+contr
[K
][key
][key2
][key3
][0]).checked
) continue; // if hide
669 var x1_left
= document
.getElementById(key2
).offsetLeft
+ 1;//document.getElementById(key2+"."+key3).offsetLeft;
670 var x1_right
= x1_left
+ document
.getElementById(key2
).offsetWidth
;
671 var x2_left
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetLeft
;//+document.getElementById(contr[K][key2][key3][0]+"."+contr[K][key2][key3][1]).offsetLeft
672 var x2_right
= x2_left
+ document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetWidth
;
673 a
[0] = Math
.abs(x1_left
- x2_left
);
674 a
[1] = Math
.abs(x1_left
- x2_right
);
675 a
[2] = Math
.abs(x1_right
- x2_left
);
676 a
[3] = Math
.abs(x1_right
- x2_right
);
677 n
= s_left
= s_right
= 0;
678 for (var i
= 1; i
< 4; i
++) {
685 x2
= x2_right
+ sm_s
;
691 x1
= x1_right
+ sm_s
;
698 x1
= x1_right
+ sm_s
;
699 x2
= x2_right
+ sm_s
;
708 var y1
= document
.getElementById(key2
).offsetTop
+ document
.getElementById(key2
+"."+key3
).offsetTop
+ height_field
;
709 var y2
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetTop
+
710 document
.getElementById(contr
[K
][key
][key2
][key3
][0]+"."+contr
[K
][key
][key2
][key3
][1]).offsetTop
+ height_field
;
711 if (!selected
&& Glob_X
> x1
- 10 && Glob_X
< x1
+ 10 && Glob_Y
> y1
- 7 && Glob_Y
< y1
+ 7) {
712 Line0(x1
- sm_x
, y1
- sm_y
, x2
- sm_x
, y2
- sm_y
, "rgba(255,0,0,1)");
713 selected
= 1; // Rect(x1-sm_x,y1-sm_y,10,10,"rgba(0,255,0,1)");
714 relation_name
= key
; //
715 Key0
= contr
[K
][key
][key2
][key3
][0];
716 Key1
= contr
[K
][key
][key2
][key3
][1];
717 Key2
= key2
; Key3
= key3
;
720 Line0(x1
- sm_x
, y1
- sm_y
, x2
- sm_x
, y2
- sm_y
, getColorByTarget( contr
[K
][key
][key2
][key3
][0]+'.'+contr
[K
][key
][key2
][key3
][1] ));
725 //alert(Key0+' - '+Key1+' - '+Key2+' - '+Key3);
726 var left
= Glob_X
- (document
.getElementById('layer_upd_relation').offsetWidth
>>1);
727 document
.getElementById('layer_upd_relation').style
.left
= left
+ 'px';
728 var top
= Glob_Y
- document
.getElementById('layer_upd_relation').offsetHeight
- 10;
729 document
.getElementById('layer_upd_relation').style
.top
= top
+ 'px';
730 document
.getElementById('layer_upd_relation').style
.visibility
= 'visible';
731 link_relation
= 'T1=' + Key0
+ '&F1=' + Key1
+ '&T2=' + Key2
+ '&F2=' + Key3
+ '&K=' + Key
;
735 function Upd_relation()
737 document
.getElementById('layer_upd_relation').style
.visibility
= 'hidden';
738 link_relation
+= '&server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&die_save_pos=0';
739 link_relation
+= Get_url_pos();
740 makeRequest('pmd_relation_upd.php', link_relation
);
743 function VisibleTab(id
, t_n
)
746 document
.getElementById(t_n
).style
.visibility
= 'visible';
748 document
.getElementById(t_n
).style
.visibility
= 'hidden';
753 function Hide_tab_all(id_this
) // max/min all tables
755 if (id_this
.alt
== 'v') {
757 id_this
.src
= "pmd/images/rightarrow1.png";
760 id_this
.src
= "pmd/images/downarrow1.png";
762 var E
= document
.form1
;
763 for (i
= 0; i
< E
.elements
.length
; i
++) {
764 if (E
.elements
[i
].type
== "checkbox" && E
.elements
[i
].id
.substring(0, 10) == 'check_vis_') {
765 if (id_this
.alt
== 'v') {
766 E
.elements
[i
].checked
= true;
767 document
.getElementById(E
.elements
[i
].value
).style
.visibility
= 'visible';
769 E
.elements
[i
].checked
= false;
770 document
.getElementById(E
.elements
[i
].value
).style
.visibility
= 'hidden';
777 function in_array_k(x
, m
)
789 function No_have_constr(id_this
)
793 for (key
in contr
[K
]) // contr name
794 for (key2
in contr
[K
][key
]) // table name
795 for (key3
in contr
[K
][key
][key2
]) // field name
796 a
[key2
] = a
[contr
[K
][key
][key2
][key3
][0]] = 1; // exist constr
799 if (id_this
.alt
== 'v') {
801 id_this
.src
= "pmd/images/rightarrow2.png";
804 id_this
.src
= "pmd/images/downarrow2.png";
806 var E
= document
.form1
;
807 for (i
= 0; i
< E
.elements
.length
; i
++) {
808 if (E
.elements
[i
].type
== "checkbox" && E
.elements
[i
].id
.substring(0, 10) == 'check_vis_')
810 if (!in_array_k(E
.elements
[i
].value
, a
))
811 if (id_this
.alt
== 'v') {
812 E
.elements
[i
].checked
= true;
813 document
.getElementById(E
.elements
[i
].value
).style
.visibility
= 'visible';
815 E
.elements
[i
].checked
= false;
816 document
.getElementById(E
.elements
[i
].value
).style
.visibility
= 'hidden';
824 var WinHelp
= window
.open("pmd_help.php", "wind1", "top=200,left=400,width=300,height=200,resizable=yes,scrollbars=yes,menubar=no");
830 // window.open("pmd_pdf.php?token="+token+"&db="+db,"wind1", "top=200,left=200,width=200,height=100,resizable=yes,scrollbars=yes,menubar=no");
831 Save('pmd_pdf.php?server=' + server
+ '&token=' + token
+ '&db=' + db
);
834 function General_scroll()
837 if (!document.getElementById('show_relation_olways').checked) {
838 document.getElementById("canvas").style.visibility = 'hidden';
839 clearTimeout(timeoutID);
840 timeoutID = setTimeout(General_scroll_end, 500);
844 clearTimeout(timeoutID
);
845 timeoutID
= setTimeout
849 document
.getElementById('top_menu').style
.left
= document
.body
.scrollLeft
+ 'px';
850 document
.getElementById('top_menu').style
.top
= document
.body
.scrollTop
+ 'px';
851 document
.getElementById('layer_menu').style
.left
= document
.body
.scrollLeft
+ 'px';
852 document
.getElementById('layer_menu').style
.top
= (document
.body
.scrollTop
+ document
.getElementById('top_menu').offsetHeight
) + 'px';
859 function General_scroll_end()
861 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
862 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
864 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
865 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
867 document.getElementById("canvas").style.visibility = 'visible';
871 function Show_left_menu(id_this
) // max/min all tables
873 if (id_this
.alt
== "v") {
874 document
.getElementById("layer_menu").style
.top
= document
.getElementById('top_menu').offsetHeight
+ 'px';
875 document
.getElementById("layer_menu").style
.visibility
= 'visible';
877 id_this
.src
= "pmd/images/uparrow2_m.png";
882 document
.getElementById("layer_menu").style
.top
= -1000 + 'px'; //fast scroll
883 document
.getElementById("layer_menu").style
.visibility
= 'hidden';
885 id_this
.src
= "pmd/images/downarrow2_m.png";
888 //------------------------------------------------------------------------------
889 function Top_menu_right(id_this
)
891 if (id_this
.alt
== ">") {
892 document
.getElementById('top_menu').style
.marginLeft
= document
.getElementById('top_menu').offsetWidth
+ 'px'; // = 350
894 id_this
.src
= "pmd/images/2leftarrow_m.png";
896 document
.getElementById('top_menu').style
.marginLeft
= 0;
898 id_this
.src
= "pmd/images/2rightarrow_m.png";
901 //------------------------------------------------------------------------------
902 function Start_display_field()
907 if (!ON_display_field
) {
908 ON_display_field
= 1;
909 document
.getElementById('hint').innerHTML
= PMA_messages
['strChangeDisplay'];
910 document
.getElementById('hint').style
.visibility
= "visible";
911 document
.getElementById('display_field_button').className
= 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA
913 if (isIE
) { // correct for IE
914 document
.getElementById('display_field_button').className
= 'M_butt_Selected_down_IE';
917 document
.getElementById('hint').innerHTML
= "";
918 document
.getElementById('hint').style
.visibility
= "hidden";
919 document
.getElementById('display_field_button').className
= 'M_butt';
920 ON_display_field
= 0;
923 //------------------------------------------------------------------------------
924 var TargetColors
= new Array();
925 function getColorByTarget( target
)
927 var color
= ''; //"rgba(0,100,150,1)";
929 for (i
in TargetColors
)
930 if (TargetColors
[i
][0]==target
) {
931 color
= TargetColors
[i
][1];
938 var i
= TargetColors
.length
+1;
943 var color_case
= new Array(
951 var a
= color_case
[d
][0];
952 var b
= color_case
[d
][1];
953 var c
= color_case
[d
][2];
954 e
= (1 - (j
- 1) / 6);
956 var r
= Math
.round(a
* 200 * e
);
957 var g
= Math
.round(b
* 200 * e
);
958 var b
= Math
.round(c
* 200 * e
);
959 var color
= "rgba("+r
+","+g
+","+b
+",1)";
961 TargetColors
.push( new Array(target
, color
) );
969 function Click_option(id_this
,column_name
,table_name
)
971 var left
= Glob_X
- (document
.getElementById(id_this
).offsetWidth
>>1);
972 document
.getElementById(id_this
).style
.left
= left
+ 'px';
973 // var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
974 document
.getElementById(id_this
).style
.top
= (screen
.height
/ 4) + 'px';
975 document
.getElementById(id_this
).style
.visibility
= "visible";
976 document
.getElementById('option_col_name').innerHTML
= '<strong>Options For "' +column_name
+ '" column</strong>';
977 col_name
= column_name
;
978 tab_name
= table_name
;
981 function Close_option()
983 document
.getElementById('pmd_optionse').style
.visibility
= "hidden";
986 function Select_all(id_this
,owner
)
988 var parent
= document
.form1
;
992 for(i
= 0; i
< parent
.elements
.length
; i
++) {
993 if (parent
.elements
[i
].type
== "checkbox" && parent
.elements
[i
].id
.substring(0,(9 + id_this
.length
)) == 'select_' + id_this
+ '._') {
994 if(document
.getElementById('select_all_' + id_this
).checked
== true) {
995 parent
.elements
[i
].checked
= true;
996 parent
.elements
[i
].disabled
= true;
997 var temp
= '`' + id_this
.substring(owner
.length
+1) + '`.*';
1000 parent
.elements
[i
].checked
= false;
1001 parent
.elements
[i
].disabled
= false;
1005 if(document
.getElementById('select_all_' + id_this
).checked
== true) {
1006 select_field
.push('`' + id_this
.substring(owner
.length
+1) + '`.*');
1007 tab
= id_this
.split(".");
1008 from_array
.push(tab
[1]);
1011 for (i
=0; i
< select_field
.length
; i
++) {
1012 if (select_field
[i
] == ('`' + id_this
.substring(owner
.length
+1) + '`.*')) {
1013 select_field
.splice(i
,1);
1016 for(k
=0 ;k
< from_array
.length
;k
++){
1017 if(from_array
[k
] == id_this
){
1018 from_array
.splice(k
,1);
1026 function Table_onover(id_this
,val
,buil
)
1029 document
.getElementById("id_zag_" + id_this
).className
="tab_zag_2";
1031 document
.getElementById("id_zag_" + id_this
+ "_2").className
="tab_zag_2";
1035 document
.getElementById("id_zag_" + id_this
).className
="tab_zag";
1037 document
.getElementById("id_zag_" + id_this
+ "_2").className
="tab_zag";
1042 /* This function stores selected column information in select_field[]
1043 * In case column is checked it add else it deletes
1046 function store_column(id_this
,owner
,col
) {
1049 if (document
.getElementById('select_' + owner
+ '.' + id_this
+ '._' + col
).checked
== true) {
1050 select_field
.push('`' + id_this
+ '`.`' + col
+'`');
1051 from_array
.push(id_this
);
1054 for(i
; i
< select_field
.length
;i
++) {
1055 if (select_field
[i
] == ('`' + id_this
+ '`.`' + col
+'`')) {
1056 select_field
.splice(i
,1);
1060 for(k
=0 ;k
< from_array
.length
;k
++){
1061 if(from_array
[k
] == id_this
){
1062 from_array
.splice(k
,1);
1070 * This function builds object and adds them to history_array
1071 * first it does a few checks on each object, then makes an object(where,rename,groupby,aggregate,orderby)
1072 * then a new history object is made and finally all these history objects are addded to history_array[]
1082 function add_object() {
1083 var rel
= document
.getElementById('rel_opt');
1085 var init
= history_array
.length
;
1086 if (rel
.value
!= '--') {
1087 if (document
.getElementById('Query').value
== "") {
1088 document
.getElementById('hint').innerHTML
= "value/subQuery is empty" ;
1089 document
.getElementById('hint').style
.visibility
= "visible";
1092 var p
= document
.getElementById('Query');
1093 var where_obj
= new where(rel
.value
,p
.value
);//make where object
1094 history_array
.push(new history(col_name
,where_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Where"));
1099 if (document
.getElementById('new_name').value
!="") {
1100 var rename_obj
= new rename(document
.getElementById('new_name').value
);//make Rename object
1101 history_array
.push(new history(col_name
,rename_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Rename"));
1103 document
.getElementById('new_name').value
= "" ;
1105 if (document
.getElementById('operator').value
!= '---') {
1106 var aggregate_obj
= new aggregate(document
.getElementById('operator').value
) ;
1107 history_array
.push(new history(col_name
,aggregate_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Aggregate"));
1109 document
.getElementById('operator').value
= '---';
1110 //make aggregate operator
1112 if (document
.getElementById('groupby').checked
== true ) {
1113 history_array
.push(new history(col_name
,'GroupBy',tab_name
,h_tabs
[downer
+ '.' +tab_name
],"GroupBy"));
1115 document
.getElementById('groupby').checked
= false;
1118 if (document
.getElementById('h_rel_opt').value
!= '--') {
1119 if (document
.getElementById('having').value
== "") {
1120 document
.getElementById('hint').innerHTML
= "value/subQuery is empty" ;
1121 document
.getElementById('hint').style
.visibility
= "visible";
1124 var p
= document
.getElementById('having');
1125 var where_obj
= new having(document
.getElementById('h_rel_opt').value
,p
.value
,document
.getElementById('h_operator').value
);//make where object
1126 history_array
.push(new history(col_name
,where_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Having"));
1128 document
.getElementById('h_rel_opt').value
= '--';
1129 document
.getElementById('h_operator').value
= '---';
1130 p
.value
= ""; //make having
1132 if (document
.getElementById('orderby').checked
== true) {
1133 history_array
.push(new history(col_name
,'OrderBy',tab_name
,h_tabs
[downer
+ '.' + tab_name
],"OrderBy"));
1135 document
.getElementById('orderby').checked
= false;
1138 document
.getElementById('hint').innerHTML
= sum
+ "object created" ;
1139 document
.getElementById('hint').style
.visibility
= "visible";
1140 //output sum new objects created
1141 var existingDiv
= document
.getElementById('ab');
1142 existingDiv
.innerHTML
= display(init
,history_array
.length
);