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;
37 //------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------
39 //------------------------------------------------------------------------------
42 //window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
44 document
.onmousedown
= MouseDown
;
45 document
.onmouseup
= MouseUp
;
46 document
.onmousemove
= MouseMove
;
48 var isIE
= document
.all
&& !window
.opera
;
49 var isNN
= !document
.all
&& document
.getElementById
;
50 var isN4
= document
.layers
;
53 window
.onscroll
= General_scroll
;
54 document
.onselectstart = function () {return false;};
57 //document.onmouseup = function(){General_scroll_end();}
61 if (cur_click
!= null) {
62 offsetx
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
63 offsety
= isIE
? event
.clientY
+ document
.body
.scrollTop
: e
.pageY
;
64 dx
= offsetx
- parseInt(cur_click
.style
.left
);
65 dy
= offsety
- parseInt(cur_click
.style
.top
);
66 //alert(" dx = " + dx + " dy = " +dy);
67 document
.getElementById("canvas").style
.visibility
= 'hidden';
69 var left = parseInt(cur_click.style.left);
70 var top = parseInt(cur_click.style.top);
74 alert(" dx = " + dx + " dy = " +dy);
76 cur_click
.style
.zIndex
= 2;
78 if (layer_menu_cur_click
) {
79 offsetx
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
80 dx
= offsetx
- parseInt(document
.getElementById("layer_menu").style
.width
);
88 Glob_X
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
89 Glob_Y
= isIE
? event
.clientY
+ document
.body
.scrollTop
: e
.pageY
;
91 //mouseX = (bw.ns4||bw.ns6)? e.pageX: bw.ie&&bw.win&&!bw.ie4? (event.clientX-2)+document.body.scrollLeft : event.clientX+document.body.scrollLeft;
92 //mouseY = (bw.ns4||bw.ns6)? e.pageY: bw.ie&&bw.win&&!bw.ie4? (event.clientY-2)+document.body.scrollTop : event.clientY+document.body.scrollTop;
94 //window.status = "X = "+ Glob_X + " Y = "+ Glob_Y;
96 if (cur_click
!= null) {
97 var mGx
= Glob_X
- dx
;
98 var mGy
= Glob_Y
- dy
;
99 mGx
= mGx
> 0 ? mGx
: 0;
100 mGy
= mGy
> 0 ? mGy
: 0;
103 mGx
= mGx
% step
< step
/ 2 ? mGx
- mGx
% step
: mGx
- mGx
% step
+ step
;
104 mGy
= mGy
% step
< step
/ 2 ? mGy
- mGy
% step
: mGy
- mGy
% step
+ step
;
107 cur_click
.style
.left
= mGx
+ 'px';
108 cur_click
.style
.top
= mGy
+ 'px';
111 if (ON_relation
|| ON_display_field
) {
112 document
.getElementById('hint').style
.left
= (Glob_X
+ 20) + 'px';
113 document
.getElementById('hint').style
.top
= (Glob_Y
+ 20) + 'px';
116 if (layer_menu_cur_click
) {
117 document
.getElementById("layer_menu").style
.width
= ((Glob_X
- dx
) >= 150 ? Glob_X
- dx
: 150) + 'px';
118 //document.getElementById("layer_menu").style.height = Glob_Y - dy>=200?Glob_Y - dy:200;
119 //document.getElementById("id_scroll_tab").style.height = Glob_Y - dy2;
125 if (cur_click
!= null) {
126 document
.getElementById("canvas").style
.visibility
= 'visible';
128 cur_click
.style
.zIndex
= 1;
131 layer_menu_cur_click
= 0;
132 //window.releaseEvents(Event.MOUSEMOVE);
134 //------------------------------------------------------------------------------
135 //------------------------------------------------------------------------------
136 //------------------------------------------------------------------------------
141 // return s.substring(0,s.length-2)*1; //re = /(\d+)\w*/; newstr = str.replace(re, "$1");
144 function Canvas_pos()
146 canvas_width
= document
.getElementById('canvas').width
= osn_tab_width
- 3;
147 canvas_height
= document
.getElementById('canvas').height
= osn_tab_height
- 3;
150 document
.getElementById('canvas').style
.width
= ((osn_tab_width
- 3)?(osn_tab_width
- 3):0) + 'px';
151 document
.getElementById('canvas').style
.height
= ((osn_tab_height
- 3)?(osn_tab_height
- 3):0) + 'px';
155 function Osn_tab_pos()
157 osn_tab_width
= parseInt(document
.getElementById('osn_tab').style
.width
);
158 osn_tab_height
= parseInt(document
.getElementById('osn_tab').style
.height
);
164 //alert( document.getElementById('osn_tab').offsetTop);
167 document
.getElementById('top_menu').style
.position
= 'absolute';
168 document
.getElementById('layer_menu').style
.position
= 'absolute';
171 document
.getElementById("layer_menu").style
.top
= -1000 + 'px'; //fast scroll
172 sm_x
+= document
.getElementById('osn_tab').offsetLeft
;
173 sm_y
+= document
.getElementById('osn_tab').offsetTop
;
178 id_hint
= document
.getElementById('hint');
185 //-------------------------------- new -----------------------------------------
186 function Rezize_osn_tab()
190 for (key
in j_tabs
) {
191 var k_x
= parseInt(document
.getElementById(key
).style
.left
) + document
.getElementById(key
).offsetWidth
;
192 var k_y
= parseInt(document
.getElementById(key
).style
.top
) + document
.getElementById(key
).offsetHeight
;
193 max_X
= max_X
< k_x
? k_x
: max_X
;
194 max_Y
= max_Y
< k_y
? k_y
: max_Y
;
197 osn_tab_width
= max_X
+ 50;
198 osn_tab_height
= max_Y
+ 50;
200 document
.getElementById('osn_tab').style
.width
= osn_tab_width
+ 'px';
201 document
.getElementById('osn_tab').style
.height
= osn_tab_height
+ 'px';
203 //------------------------------------------------------------------------------
206 * refreshes display, must be called after state changes
217 for (key
in contr
[K
]) // contr name
218 for (key2
in contr
[K
][key
]) // table name
219 for (key3
in contr
[K
][key
][key2
]) // field name
221 if (!document
.getElementById("check_vis_" + key2
).checked
||
222 !document
.getElementById("check_vis_" + contr
[K
][key
][key2
][key3
][0]).checked
) {
226 var x1_left
= document
.getElementById(key2
).offsetLeft
+1;
227 var x1_right
= x1_left
+ document
.getElementById(key2
).offsetWidth
;
228 var x2_left
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetLeft
;
229 var x2_right
= x2_left
+ document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetWidth
;
230 a
[0] = Math
.abs(x1_left
- x2_left
);
231 a
[1] = Math
.abs(x1_left
- x2_right
);
232 a
[2] = Math
.abs(x1_right
- x2_left
);
233 a
[3] = Math
.abs(x1_right
- x2_right
);
234 n
= s_left
= s_right
= 0;
235 for (var i
= 1; i
< 4; i
++) {
242 x2
= x2_right
+ sm_s
;
248 x1
= x1_right
+ sm_s
;
255 x1
= x1_right
+ sm_s
;
256 x2
= x2_right
+ sm_s
;
264 //alert(key2 + "." + key3);
266 var row_offset_top
= 0;
267 //alert('id_tbody_' + key2);
268 //alert(document.getElementById('id_hide_tbody_' + key2));
269 var tab_hide_button
= document
.getElementById('id_hide_tbody_' + key2
);
271 //alert(tab_hide_button.innerHTML);
272 if (tab_hide_button
.innerHTML
== 'v') {
273 row_offset_top
= document
.getElementById(key2
+ "." + key3
).offsetTop
;
276 var y1
= document
.getElementById(key2
).offsetTop
282 var tab_hide_button
= document
.getElementById('id_hide_tbody_' + contr
[K
][key
][key2
][key3
][0]);
283 if (tab_hide_button
.innerHTML
== 'v') {
284 row_offset_top
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]
285 + '.' + contr
[K
][key
][key2
][key3
][1]).offsetTop
;
289 document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetTop
293 //alert(y1 + ' - ' + key2 + "." + key3);
294 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] ) );
299 * draws a line from x1:y1 to x2:y2 with color
301 function Line(x1
, y1
, x2
, y2
, color_line
)
303 var canvas
= document
.getElementById("canvas");
304 var ctx
= canvas
.getContext("2d");
305 ctx
.strokeStyle
= color_line
;
314 * draws a relation/constraint line, whether angular or not
316 function Line0(x1
, y1
, x2
, y2
, color_line
)
318 Circle(x1
, y1
, 3, 3, color_line
);
319 Rect(x2
- 1, y2
- 2, 4, 4, color_line
);
321 if (ON_angular_direct
) {
322 Line2(x1
, y1
, x2
, y2
, color_line
);
324 Line3(x1
, y1
, x2
, y2
, color_line
);
329 * draws a angualr relation/constraint line
331 function Line2(x1
, y1
, x2
, y2
, color_line
)
342 } else if (x1
< x2
) {
350 Line(x1
, y1
, x1_
, y1
, color_line
);
351 Line(x2
, y2
, x2_
, y2
, color_line
);
352 Line(x1_
, y1
, x2_
, y2
, color_line
);
356 * draws a relation/constraint line
358 function Line3(x1
, y1
, x2
, y2
, color_line
)
365 x1_
+= x2
- x1
+ sm_add
;
368 x2_
+= x1
- x2
+ sm_add
;
372 Line(x1
, y1
, x1_
, y1
, color_line
);
373 Line(x2
, y2
, x2_
, y2
, color_line
);
374 Line(x1_
, y1
, x2_
, y2
, color_line
);
379 x2_
-= x2
- x1
+ sm_add
;
382 x1_
-= x1
- x2
+ sm_add
;
386 Line(x1
, y1
, x1_
, y1
, color_line
);
387 Line(x2
, y2
, x2_
, y2
, color_line
);
388 Line(x1_
, y1
, x2_
, y2
, color_line
);
392 var x_s
= (x1
+ x2
) / 2;
393 Line(x1
, y1
, x_s
, y1
, color_line
);
394 Line(x_s
, y2
, x2
, y2
, color_line
);
395 Line(x_s
, y1
, x_s
, y2
, color_line
);
398 function Circle(x
, y
, r
, w
, color
)
400 var ctx
= document
.getElementById('canvas').getContext('2d');
404 ctx
.strokeStyle
= color
;
405 ctx
.arc(x
, y
, r
, 0, 2 * Math
.PI
, true);
411 var canvas
= document
.getElementById("canvas");
412 var ctx
= canvas
.getContext("2d");
413 ctx
.clearRect(0, 0, canvas_width
, canvas_height
);
416 function Rect(x1
, y1
, w
, h
, color
)
418 var ctx
= document
.getElementById('canvas').getContext('2d');
419 ctx
.fillStyle
= color
;
420 ctx
.fillRect(x1
, y1
, w
, h
);
423 //------------------------------ SAVE ------------------------------------------
424 function Save(url
) // (del?) no for pdf
426 for (key
in j_tabs
) {
427 document
.getElementById('t_x_' + key
+ '_').value
= parseInt(document
.getElementById(key
).style
.left
);
428 document
.getElementById('t_y_' + key
+ '_').value
= parseInt(document
.getElementById(key
).style
.top
);
429 document
.getElementById('t_v_' + key
+ '_').value
= document
.getElementById('id_tbody_' + key
).style
.display
== 'none' ? 0 : 1;
430 document
.getElementById('t_h_' + key
+ '_').value
= document
.getElementById('check_vis_' + key
).checked
? 1 : 0;
432 document
.form1
.action
= url
;
433 document
.form1
.submit();
436 function Get_url_pos()
439 for (key
in j_tabs
) {
440 poststr
+= '&t_x[' + key
+ ']=' + parseInt(document
.getElementById(key
).style
.left
);
441 poststr
+= '&t_y[' + key
+ ']=' + parseInt(document
.getElementById(key
).style
.top
);
442 poststr
+= '&t_v[' + key
+ ']=' + (document
.getElementById('id_tbody_' + key
).style
.display
== 'none' ? 0 : 1);
443 poststr
+= '&t_h[' + key
+ ']=' + (document
.getElementById('check_vis_' + key
).checked
? 1 : 0);
450 var poststr
= 'IS_AJAX=1&server='+server
+'&db=' + db
+ '&token=' + token
+ '&die_save_pos=1';
451 poststr
+= Get_url_pos();
452 makeRequest('pmd_save_pos.php', poststr
);
459 document
.getElementById('grid_button').className
= 'M_butt_Selected_down';
461 document
.getElementById('grid_button').className
= 'M_butt';
466 function Angular_direct()
468 if (ON_angular_direct
) {
469 ON_angular_direct
= 0;
470 document
.getElementById('angular_direct_button').className
= 'M_butt_Selected_down';
472 ON_angular_direct
= 1;
473 document
.getElementById('angular_direct_button').className
= 'M_butt';
477 //++++++++++++++++++++++++++++++ RELATION ++++++++++++++++++++++++++++++++++++++
478 function Start_relation()
480 if (ON_display_field
) {
485 document
.getElementById('foreign_relation').style
.display
= '';
487 document
.getElementById('hint').innerHTML
= PMA_messages
['strSelectReferencedKey'];
488 document
.getElementById('hint').style
.visibility
= "visible";
489 document
.getElementById('rel_button').className
= 'M_butt_Selected_down';
491 document
.getElementById('hint').innerHTML
= "";
492 document
.getElementById('hint').style
.visibility
= "hidden";
493 document
.getElementById('rel_button').className
= 'M_butt';
499 function Click_field(T
, f
, PK
) // table field
503 //.style.display=='none' .style.visibility = "hidden"
505 alert(PMA_messages
['strPleaseSelectPrimaryOrUniqueKey']);
508 if (j_tabs
[db
+ '.' + T
] != '1') {
509 document
.getElementById('foreign_relation').style
.display
= 'none';
512 link_relation
= "T1=" + T
+ "&F1=" + f
;
513 document
.getElementById('hint').innerHTML
= PMA_messages
['strSelectForeignKey'];
515 Start_relation(); // hidden hint...
516 if (j_tabs
[db
+ '.' + T
] != '1' || !PK
) {
517 document
.getElementById('foreign_relation').style
.display
= 'none';
519 var left
= Glob_X
- (document
.getElementById('layer_new_relation').offsetWidth
>>1);
520 document
.getElementById('layer_new_relation').style
.left
= left
+ 'px';
521 var top
= Glob_Y
- document
.getElementById('layer_new_relation').offsetHeight
- 10;
522 document
.getElementById('layer_new_relation').style
.top
= top
+ 'px';
523 document
.getElementById('layer_new_relation').style
.visibility
= "visible";
524 link_relation
+= '&T2=' + T
+ '&F2=' + f
;
528 if (ON_display_field
) {
529 // if is display field
530 if (display_field
[T
] == f
) {
532 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ',';alert(s);
533 old_class
= 'tab_field';
534 //display_field.splice(T, 1);
535 delete display_field
[T
];
536 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ', ';alert(s);
537 //n = 0;for(k in display_field)n++;alert(n);
539 old_class
= 'tab_field_3';
540 if (display_field
[T
]) {
541 document
.getElementById('id_tr_' + T
+ '.' + display_field
[T
]).className
= 'tab_field';
542 //display_field.splice(T, 1);
543 delete display_field
[T
];
545 display_field
[T
] = f
;
547 ON_display_field
= 0;
548 document
.getElementById('hint').innerHTML
= "";
549 document
.getElementById('hint').style
.visibility
= "hidden";
550 document
.getElementById('display_field_button').className
= 'M_butt';
551 makeRequest('pmd_display_field.php', 'T=' + T
+ '&F=' + f
+ '&server=' + server
+ '&db=' + db
+ '&token=' + token
);
555 function New_relation()
557 document
.getElementById('layer_new_relation').style
.visibility
= 'hidden';
558 link_relation
+= '&server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&die_save_pos=0';
559 link_relation
+= '&on_delete=' + document
.getElementById('on_delete').value
+ '&on_update=' + document
.getElementById('on_update').value
;
560 link_relation
+= Get_url_pos();
562 //alert(link_relation);
563 makeRequest('pmd_relation_new.php', link_relation
);
566 //-------------------------- create tables -------------------------------------
568 function Start_table_new()
570 window
.location
.href
= 'db_operations.php?server=' + server
+ '&db=' + db
+ '&token=' + token
;
573 function Start_tab_upd(table
)
575 window
.location
.href
= 'tbl_structure.php?server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&table=' + table
;
577 //--------------------------- hide tables --------------------------------------
579 function Small_tab_all(id_this
) // max/min all tables
581 if (id_this
.alt
== "v") {
582 for (key
in j_tabs
) {
583 if (document
.getElementById('id_hide_tbody_'+key
).innerHTML
== "v") {
588 id_this
.src
= "pmd/images/rightarrow1.png";
590 for (key
in j_tabs
) {
591 if (document
.getElementById('id_hide_tbody_'+key
).innerHTML
!= "v") {
596 id_this
.src
= "pmd/images/downarrow1.png";
601 function Small_tab_invert() // invert max/min all tables
603 for (key
in j_tabs
) {
609 function Small_tab_refresh()
611 for (key
in j_tabs
) {
612 if(document
.getElementById('id_hide_tbody_'+key
).innerHTML
!= "v") {
619 function Small_tab(t
, re_load
)
621 var id
= document
.getElementById('id_tbody_' + t
);
622 var id_this
= document
.getElementById('id_hide_tbody_' + t
);
623 var id_t
= document
.getElementById(t
);
625 id_t
.style
.width
= id_t
.offsetWidth
+ 'px';
626 if (id_this
.innerHTML
== "v") {
628 id
.style
.display
= 'none';
629 id_this
.innerHTML
= '>';
631 id
.style
.display
= '';
632 id_this
.innerHTML
= 'v';
638 //------------------------------------------------------------------------------
639 function Select_tab(t
)
641 var id_zag
= document
.getElementById('id_zag_' + t
);
642 if (id_zag
.className
!= 'tab_zag_3') {
643 document
.getElementById('id_zag_' + t
).className
= 'tab_zag_2';
645 document
.getElementById('id_zag_' + t
).className
= 'tab_zag';
648 var id_t
= document
.getElementById(t
);
649 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
)
988 var parent
= document
.form1
;
989 for(i
= 0; i
< parent
.elements
.length
; i
++) {
990 if (parent
.elements
[i
].type
== "checkbox" && parent
.elements
[i
].id
.substring(0,(7 + id_this
.length
)) == 'select_' + id_this
) {
991 if(document
.getElementById('select_all_' + id_this
).checked
== true)
992 parent
.elements
[i
].checked
= true;
994 parent
.elements
[i
].checked
= false;
1000 function Table_onover(id_this
,val
)
1003 document
.getElementById("id_zag_" + id_this
).className
="tab_zag_2";
1004 document
.getElementById("id_zag_" + id_this
+ "_2").className
="tab_zag_2";
1007 document
.getElementById("id_zag_" + id_this
).className
="tab_zag";
1008 document
.getElementById("id_zag_" + id_this
+ "_2").className
="tab_zag";
1012 function add_object() {
1013 var rel
= document
.getElementById('rel_opt');
1015 var init
= history_array
.length
;
1016 if (rel
.value
!= '--') {
1017 if (document
.getElementsByName('Query').value
== "") {
1018 document
.getElementById('hint').innerHTML
= "value/subQuery is empty" ;
1019 document
.getElementById('hint').style
.visibility
= "visible";
1022 var p
= document
.getElementsByName('Query');
1023 var where_obj
= new where(rel
.value
,p
.value
);//make where object
1024 history_array
.push(new history(col_name
,where_obj
,tab_name
,h_tabs
[tab_name
],"Where"));
1029 if (document
.getElementById('new_name').value
!="") {
1030 var rename_obj
= new rename(document
.getElementById('new_name').value
);//make Rename object
1031 history_array
.push(new history(col_name
,rename_obj
,tab_name
,h_tabs
[tab_name
],"Rename"));
1033 document
.getElementById('new_name').value
= "" ;
1035 if (document
.getElementById('operator').value
!= '---') {
1036 var aggregate_obj
= new aggregate(document
.getElementById('operator').value
) ;
1037 history_array
.push(new history(col_name
,aggregate_obj
,tab_name
,h_tabs
[tab_name
],"Aggregate"));
1039 document
.getElementById('operator').value
= '---';
1040 //make aggregate operator
1042 if (document
.getElementById('groupby').checked
== true ) {
1043 history_array
.push(new history(col_name
,'GroupBy',tab_name
,h_tabs
[tab_name
],"Group By"));
1045 document
.getElementById('groupby').checked
= false;
1048 if (document
.getElementById('orderby').checked
== true) {
1049 history_array
.push(new history(col_name
,'OrderBy',tab_name
,h_tabs
[tab_name
],"Order By"));
1051 document
.getElementById('orderby').checked
= false;
1054 document
.getElementById('hint').innerHTML
= sum
+ "object created" ;
1055 document
.getElementById('hint').style
.visibility
= "visible";
1056 //output sum new objects created
1057 var existingDiv
= document
.getElementById('ab');
1058 existingDiv
.innerHTML
= display(init
,history_array
.length
);