1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @package phpMyAdmin-Designer
11 var _change
= 0; // variable to track any change in designer layout.
12 var _staying
= 0; // variable to check if the user stayed after seeing the confirmation prompt.
14 // Below is the function to change the href attributes to '#' while the href script is called using
15 // the onclick event. It fixes the Internet Explorer issue with href.
17 $(document
).ready(function(){
18 $('a').filter(function(){
19 return ( /^javascript\:/i).test($(this).attr('href'));
21 var hrefscript
= $(this).attr('href');
22 hrefscript
= hrefscript
.substr(11);
23 $(this).data('hrefscript', hrefscript
);
25 var hrefscript
= $(this).data('hrefscript');
31 // Below is the function to bind onbeforeunload events with the content_frame as well as the top window.
33 $(document
).ready(function(){
34 $(window
).bind('beforeunload', function(){ // onbeforeunload for the frame window.
35 if (_change
== 1 && _staying
== 0)
36 return PMA_messages
['strLeavingDesigner'];
37 else if (_change
== 1 && _staying
== 1)
40 $(window
).unload(function(){
43 window
.top
.onbeforeunload = function(){ // onbeforeunload for the browser main window.
44 if (_change
== 1 && _staying
== 0){
45 _staying
= 1; // Helps if the user stays on the page as there
46 setTimeout('make_zero();', 100); // is no other way of knowing whether the user stayed or not.
47 return PMA_messages
['strLeavingDesigner'];
52 function make_zero(){ // Function called if the user stays after seeing the confirmation prompt.
60 var sm_x
= 2, sm_y
= 2;
67 var ON_display_field
= 0;
68 // relation_style: 0 - angular 1 - direct
69 var ON_angular_direct
= 1;
71 var link_relation
= "";
74 var canvas_height
= 0;
75 var osn_tab_width
= 0;
76 var osn_tab_height
= 0;
80 var layer_menu_cur_click
= 0;
86 //------------------------------------------------------------------------------
87 //------------------------------------------------------------------------------
88 //------------------------------------------------------------------------------
91 //window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
93 document
.onmousedown
= MouseDown
;
94 document
.onmouseup
= MouseUp
;
95 document
.onmousemove
= MouseMove
;
97 var isIE
= document
.all
&& !window
.opera
;
98 var isNN
= !document
.all
&& document
.getElementById
;
99 var isN4
= document
.layers
;
102 window
.onscroll
= General_scroll
;
103 document
.onselectstart = function () {return false;};
106 //document.onmouseup = function(){General_scroll_end();}
107 function MouseDown(e
)
109 var offsetx
, offsety
;
110 if (cur_click
!= null) {
111 offsetx
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
112 offsety
= isIE
? event
.clientY
+ document
.body
.scrollTop
: e
.pageY
;
113 dx
= offsetx
- parseInt(cur_click
.style
.left
);
114 dy
= offsety
- parseInt(cur_click
.style
.top
);
115 //alert(" dx = " + dx + " dy = " +dy);
116 document
.getElementById("canvas").style
.display
= 'none';
118 var left = parseInt(cur_click.style.left);
119 var top = parseInt(cur_click.style.top);
123 alert(" dx = " + dx + " dy = " +dy);
125 cur_click
.style
.zIndex
= 2;
127 if (layer_menu_cur_click
) {
128 offsetx
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
129 dx
= offsetx
- parseInt(document
.getElementById("layer_menu").style
.width
);
133 function MouseMove(e
)
137 Glob_X
= isIE
? event
.clientX
+ document
.body
.scrollLeft
: e
.pageX
;
138 Glob_Y
= isIE
? event
.clientY
+ document
.body
.scrollTop
: e
.pageY
;
140 //mouseX = (bw.ns4||bw.ns6)? e.pageX: bw.ie&&bw.win&&!bw.ie4? (event.clientX-2)+document.body.scrollLeft : event.clientX+document.body.scrollLeft;
141 //mouseY = (bw.ns4||bw.ns6)? e.pageY: bw.ie&&bw.win&&!bw.ie4? (event.clientY-2)+document.body.scrollTop : event.clientY+document.body.scrollTop;
143 //window.status = "X = "+ Glob_X + " Y = "+ Glob_Y;
145 if (cur_click
!= null) {
147 var mGx
= Glob_X
- dx
;
148 var mGy
= Glob_Y
- dy
;
149 mGx
= mGx
> 0 ? mGx
: 0;
150 mGy
= mGy
> 0 ? mGy
: 0;
153 mGx
= mGx
% step
< step
/ 2 ? mGx
- mGx
% step
: mGx
- mGx
% step
+ step
;
154 mGy
= mGy
% step
< step
/ 2 ? mGy
- mGy
% step
: mGy
- mGy
% step
+ step
;
157 cur_click
.style
.left
= mGx
+ 'px';
158 cur_click
.style
.top
= mGy
+ 'px';
161 if (ON_relation
|| ON_display_field
) {
162 document
.getElementById('pmd_hint').style
.left
= (Glob_X
+ 20) + 'px';
163 document
.getElementById('pmd_hint').style
.top
= (Glob_Y
+ 20) + 'px';
166 if (layer_menu_cur_click
) {
167 document
.getElementById("layer_menu").style
.width
= ((Glob_X
- dx
) >= 150 ? Glob_X
- dx
: 150) + 'px';
168 //document.getElementById("layer_menu").style.height = Glob_Y - dy>=200?Glob_Y - dy:200;
169 //document.getElementById("id_scroll_tab").style.height = Glob_Y - dy2;
175 if (cur_click
!= null) {
176 document
.getElementById("canvas").style
.display
= 'inline-block';
178 cur_click
.style
.zIndex
= 1;
181 layer_menu_cur_click
= 0;
182 //window.releaseEvents(Event.MOUSEMOVE);
184 //------------------------------------------------------------------------------
185 //------------------------------------------------------------------------------
186 //------------------------------------------------------------------------------
191 // return s.substring(0,s.length-2)*1; //re = /(\d+)\w*/; newstr = str.replace(re, "$1");
194 function Canvas_pos()
196 canvas_width
= document
.getElementById('canvas').width
= osn_tab_width
- 3;
197 canvas_height
= document
.getElementById('canvas').height
= osn_tab_height
- 3;
200 document
.getElementById('canvas').style
.width
= ((osn_tab_width
- 3)?(osn_tab_width
- 3):0) + 'px';
201 document
.getElementById('canvas').style
.height
= ((osn_tab_height
- 3)?(osn_tab_height
- 3):0) + 'px';
205 function Osn_tab_pos()
207 osn_tab_width
= parseInt(document
.getElementById('osn_tab').style
.width
);
208 osn_tab_height
= parseInt(document
.getElementById('osn_tab').style
.height
);
214 //alert( document.getElementById('osn_tab').offsetTop);
217 document
.getElementById('top_menu').style
.position
= 'absolute';
218 document
.getElementById('layer_menu').style
.position
= 'absolute';
221 document
.getElementById("layer_menu").style
.top
= -1000 + 'px'; //fast scroll
222 sm_x
+= document
.getElementById('osn_tab').offsetLeft
;
223 sm_y
+= document
.getElementById('osn_tab').offsetTop
;
228 id_hint
= document
.getElementById('pmd_hint');
235 //-------------------------------- new -----------------------------------------
236 function Rezize_osn_tab()
240 for (key
in j_tabs
) {
241 var k_x
= parseInt(document
.getElementById(key
).style
.left
) + document
.getElementById(key
).offsetWidth
;
242 var k_y
= parseInt(document
.getElementById(key
).style
.top
) + document
.getElementById(key
).offsetHeight
;
243 max_X
= max_X
< k_x
? k_x
: max_X
;
244 max_Y
= max_Y
< k_y
? k_y
: max_Y
;
247 osn_tab_width
= max_X
+ 50;
248 osn_tab_height
= max_Y
+ 50;
250 document
.getElementById('osn_tab').style
.width
= osn_tab_width
+ 'px';
251 document
.getElementById('osn_tab').style
.height
= osn_tab_height
+ 'px';
253 //------------------------------------------------------------------------------
256 * refreshes display, must be called after state changes
267 for (key
in contr
[K
]) // contr name
268 for (key2
in contr
[K
][key
]) // table name
269 for (key3
in contr
[K
][key
][key2
]) // field name
271 if (!document
.getElementById("check_vis_" + key2
).checked
||
272 !document
.getElementById("check_vis_" + contr
[K
][key
][key2
][key3
][0]).checked
) {
276 var x1_left
= document
.getElementById(key2
).offsetLeft
+1;
277 var x1_right
= x1_left
+ document
.getElementById(key2
).offsetWidth
;
278 var x2_left
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetLeft
;
279 var x2_right
= x2_left
+ document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetWidth
;
280 a
[0] = Math
.abs(x1_left
- x2_left
);
281 a
[1] = Math
.abs(x1_left
- x2_right
);
282 a
[2] = Math
.abs(x1_right
- x2_left
);
283 a
[3] = Math
.abs(x1_right
- x2_right
);
284 n
= s_left
= s_right
= 0;
285 for (var i
= 1; i
< 4; i
++) {
292 x2
= x2_right
+ sm_s
;
298 x1
= x1_right
+ sm_s
;
305 x1
= x1_right
+ sm_s
;
306 x2
= x2_right
+ sm_s
;
314 //alert(key2 + "." + key3);
316 var row_offset_top
= 0;
317 //alert('id_tbody_' + key2);
318 //alert(document.getElementById('id_hide_tbody_' + key2));
319 var tab_hide_button
= document
.getElementById('id_hide_tbody_' + key2
);
321 //alert(tab_hide_button.innerHTML);
322 if (tab_hide_button
.innerHTML
== 'v') {
323 row_offset_top
= document
.getElementById(key2
+ "." + key3
).offsetTop
;
326 var y1
= document
.getElementById(key2
).offsetTop
332 var tab_hide_button
= document
.getElementById('id_hide_tbody_' + contr
[K
][key
][key2
][key3
][0]);
333 if (tab_hide_button
.innerHTML
== 'v') {
334 row_offset_top
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]
335 + '.' + contr
[K
][key
][key2
][key3
][1]).offsetTop
;
339 document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetTop
343 //alert(y1 + ' - ' + key2 + "." + key3);
344 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] ) );
349 * draws a line from x1:y1 to x2:y2 with color
351 function Line(x1
, y1
, x2
, y2
, color_line
)
353 var canvas
= document
.getElementById("canvas");
354 var ctx
= canvas
.getContext("2d");
355 ctx
.strokeStyle
= color_line
;
364 * draws a relation/constraint line, whether angular or not
366 function Line0(x1
, y1
, x2
, y2
, color_line
)
368 Circle(x1
, y1
, 3, 3, color_line
);
369 Rect(x2
- 1, y2
- 2, 4, 4, color_line
);
371 if (ON_angular_direct
) {
372 Line2(x1
, y1
, x2
, y2
, color_line
);
374 Line3(x1
, y1
, x2
, y2
, color_line
);
379 * draws a angualr relation/constraint line
381 function Line2(x1
, y1
, x2
, y2
, color_line
)
392 } else if (x1
< x2
) {
400 Line(x1
, y1
, x1_
, y1
, color_line
);
401 Line(x2
, y2
, x2_
, y2
, color_line
);
402 Line(x1_
, y1
, x2_
, y2
, color_line
);
406 * draws a relation/constraint line
408 function Line3(x1
, y1
, x2
, y2
, color_line
)
415 x1_
+= x2
- x1
+ sm_add
;
418 x2_
+= x1
- x2
+ sm_add
;
422 Line(x1
, y1
, x1_
, y1
, color_line
);
423 Line(x2
, y2
, x2_
, y2
, color_line
);
424 Line(x1_
, y1
, x2_
, y2
, color_line
);
429 x2_
-= x2
- x1
+ sm_add
;
432 x1_
-= x1
- x2
+ sm_add
;
436 Line(x1
, y1
, x1_
, y1
, color_line
);
437 Line(x2
, y2
, x2_
, y2
, color_line
);
438 Line(x1_
, y1
, x2_
, y2
, color_line
);
442 var x_s
= (x1
+ x2
) / 2;
443 Line(x1
, y1
, x_s
, y1
, color_line
);
444 Line(x_s
, y2
, x2
, y2
, color_line
);
445 Line(x_s
, y1
, x_s
, y2
, color_line
);
448 function Circle(x
, y
, r
, w
, color
)
450 var ctx
= document
.getElementById('canvas').getContext('2d');
454 ctx
.strokeStyle
= color
;
455 ctx
.arc(x
, y
, r
, 0, 2 * Math
.PI
, true);
461 var canvas
= document
.getElementById("canvas");
462 var ctx
= canvas
.getContext("2d");
463 ctx
.clearRect(0, 0, canvas_width
, canvas_height
);
466 function Rect(x1
, y1
, w
, h
, color
)
468 var ctx
= document
.getElementById('canvas').getContext('2d');
469 ctx
.fillStyle
= color
;
470 ctx
.fillRect(x1
, y1
, w
, h
);
473 //------------------------------ SAVE ------------------------------------------
474 function Save(url
) // (del?) no for pdf
476 for (key
in j_tabs
) {
477 document
.getElementById('t_x_' + key
+ '_').value
= parseInt(document
.getElementById(key
).style
.left
);
478 document
.getElementById('t_y_' + key
+ '_').value
= parseInt(document
.getElementById(key
).style
.top
);
479 document
.getElementById('t_v_' + key
+ '_').value
= document
.getElementById('id_tbody_' + key
).style
.display
== 'none' ? 0 : 1;
480 document
.getElementById('t_h_' + key
+ '_').value
= document
.getElementById('check_vis_' + key
).checked
? 1 : 0;
482 document
.form1
.action
= url
;
483 document
.form1
.submit();
486 function Get_url_pos()
489 for (key
in j_tabs
) {
490 poststr
+= '&t_x[' + key
+ ']=' + parseInt(document
.getElementById(key
).style
.left
);
491 poststr
+= '&t_y[' + key
+ ']=' + parseInt(document
.getElementById(key
).style
.top
);
492 poststr
+= '&t_v[' + key
+ ']=' + (document
.getElementById('id_tbody_' + key
).style
.display
== 'none' ? 0 : 1);
493 poststr
+= '&t_h[' + key
+ ']=' + (document
.getElementById('check_vis_' + key
).checked
? 1 : 0);
501 var poststr
= 'IS_AJAX=1&server='+server
+'&db=' + db
+ '&token=' + token
+ '&die_save_pos=1';
502 poststr
+= Get_url_pos();
503 makeRequest('pmd_save_pos.php', poststr
);
510 document
.getElementById('grid_button').className
= 'M_butt_Selected_down';
512 document
.getElementById('grid_button').className
= 'M_butt';
517 function Angular_direct()
519 if (ON_angular_direct
) {
520 ON_angular_direct
= 0;
521 document
.getElementById('angular_direct_button').className
= 'M_butt_Selected_down';
523 ON_angular_direct
= 1;
524 document
.getElementById('angular_direct_button').className
= 'M_butt';
528 //++++++++++++++++++++++++++++++ RELATION ++++++++++++++++++++++++++++++++++++++
529 function Start_relation()
531 if (ON_display_field
) {
536 document
.getElementById('foreign_relation').style
.display
= '';
538 document
.getElementById('pmd_hint').innerHTML
= PMA_messages
['strSelectReferencedKey'];
539 document
.getElementById('pmd_hint').style
.display
= 'block';
540 document
.getElementById('rel_button').className
= 'M_butt_Selected_down';
542 document
.getElementById('pmd_hint').innerHTML
= "";
543 document
.getElementById('pmd_hint').style
.display
= 'none';
544 document
.getElementById('rel_button').className
= 'M_butt';
550 function Click_field(T
, f
, PK
) // table field
554 //.style.display=='none' .style.display = 'none'
556 alert(PMA_messages
['strPleaseSelectPrimaryOrUniqueKey']);
559 if (j_tabs
[db
+ '.' + T
] != '1') {
560 document
.getElementById('foreign_relation').style
.display
= 'none';
563 link_relation
= "T1=" + T
+ "&F1=" + f
;
564 document
.getElementById('pmd_hint').innerHTML
= PMA_messages
['strSelectForeignKey'];
566 Start_relation(); // hidden hint...
567 if (j_tabs
[db
+ '.' + T
] != '1' || !PK
) {
568 document
.getElementById('foreign_relation').style
.display
= 'none';
570 var left
= Glob_X
- (document
.getElementById('layer_new_relation').offsetWidth
>>1);
571 document
.getElementById('layer_new_relation').style
.left
= left
+ 'px';
572 var top
= Glob_Y
- document
.getElementById('layer_new_relation').offsetHeight
+ 40;
573 document
.getElementById('layer_new_relation').style
.top
= top
+ 'px';
574 document
.getElementById('layer_new_relation').style
.display
= 'block';
575 link_relation
+= '&T2=' + T
+ '&F2=' + f
;
579 if (ON_display_field
) {
580 // if is display field
581 if (display_field
[T
] == f
) {
583 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ',';alert(s);
584 old_class
= 'tab_field';
585 //display_field.splice(T, 1);
586 delete display_field
[T
];
587 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ', ';alert(s);
588 //n = 0;for(k in display_field)n++;alert(n);
590 old_class
= 'tab_field_3';
591 if (display_field
[T
]) {
592 document
.getElementById('id_tr_' + T
+ '.' + display_field
[T
]).className
= 'tab_field';
593 //display_field.splice(T, 1);
594 delete display_field
[T
];
596 display_field
[T
] = f
;
598 ON_display_field
= 0;
599 document
.getElementById('pmd_hint').innerHTML
= "";
600 document
.getElementById('pmd_hint').style
.display
= 'none';
601 document
.getElementById('display_field_button').className
= 'M_butt';
602 makeRequest('pmd_display_field.php', 'T=' + T
+ '&F=' + f
+ '&server=' + server
+ '&db=' + db
+ '&token=' + token
);
606 function New_relation()
608 document
.getElementById('layer_new_relation').style
.display
= 'none';
609 link_relation
+= '&server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&die_save_pos=0';
610 link_relation
+= '&on_delete=' + document
.getElementById('on_delete').value
+ '&on_update=' + document
.getElementById('on_update').value
;
611 link_relation
+= Get_url_pos();
613 //alert(link_relation);
614 makeRequest('pmd_relation_new.php', link_relation
);
617 //-------------------------- create tables -------------------------------------
619 function Start_table_new()
621 window
.location
.href
= 'tbl_create.php?server=' + server
+ '&db=' + db
+ '&token=' + token
;
624 function Start_tab_upd(table
)
626 window
.location
.href
= 'tbl_structure.php?server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&table=' + table
;
628 //--------------------------- hide tables --------------------------------------
630 function Small_tab_all(id_this
) // max/min all tables
632 if (id_this
.alt
== "v") {
633 for (key
in j_tabs
) {
634 if (document
.getElementById('id_hide_tbody_'+key
).innerHTML
== "v") {
639 id_this
.src
= "pmd/images/rightarrow1.png";
641 for (key
in j_tabs
) {
642 if (document
.getElementById('id_hide_tbody_'+key
).innerHTML
!= "v") {
647 id_this
.src
= "pmd/images/downarrow1.png";
652 function Small_tab_invert() // invert max/min all tables
654 for (key
in j_tabs
) {
660 function Small_tab_refresh()
662 for (key
in j_tabs
) {
663 if(document
.getElementById('id_hide_tbody_'+key
).innerHTML
!= "v") {
670 function Small_tab(t
, re_load
)
672 var id
= document
.getElementById('id_tbody_' + t
);
673 var id_this
= document
.getElementById('id_hide_tbody_' + t
);
674 var id_t
= document
.getElementById(t
);
675 id_t
.style
.width
= id_t
.offsetWidth
+ 'px';
676 if (id_this
.innerHTML
== "v") {
678 id
.style
.display
= 'none';
679 id_this
.innerHTML
= '>';
681 id
.style
.display
= '';
682 id_this
.innerHTML
= 'v';
688 //------------------------------------------------------------------------------
689 function Select_tab(t
)
691 var id_zag
= document
.getElementById('id_zag_' + t
);
692 if (id_zag
.className
!= 'tab_zag_3') {
693 document
.getElementById('id_zag_' + t
).className
= 'tab_zag_2';
695 document
.getElementById('id_zag_' + t
).className
= 'tab_zag';
698 var id_t
= document
.getElementById(t
);
699 window
.scrollTo(parseInt(id_t
.style
.left
) - 300, parseInt(id_t
.style
.top
) - 300);
700 setTimeout(function(){document
.getElementById('id_zag_' + t
).className
= 'tab_zag';}, 800);
702 //------------------------------------------------------------------------------
704 function Canvas_click(id
)
707 var relation_name
= 0;
710 var Key0
, Key1
, Key2
, Key3
, Key
, x1
, x2
;
713 for (key
in contr
[K
])
714 for (key2
in contr
[K
][key
])
715 for (key3
in contr
[K
][key
][key2
]) {
716 if (!document
.getElementById("check_vis_"+key2
).checked
||
717 !document
.getElementById("check_vis_"+contr
[K
][key
][key2
][key3
][0]).checked
) continue; // if hide
718 var x1_left
= document
.getElementById(key2
).offsetLeft
+ 1;//document.getElementById(key2+"."+key3).offsetLeft;
719 var x1_right
= x1_left
+ document
.getElementById(key2
).offsetWidth
;
720 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
721 var x2_right
= x2_left
+ document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetWidth
;
722 a
[0] = Math
.abs(x1_left
- x2_left
);
723 a
[1] = Math
.abs(x1_left
- x2_right
);
724 a
[2] = Math
.abs(x1_right
- x2_left
);
725 a
[3] = Math
.abs(x1_right
- x2_right
);
726 n
= s_left
= s_right
= 0;
727 for (var i
= 1; i
< 4; i
++) {
734 x2
= x2_right
+ sm_s
;
740 x1
= x1_right
+ sm_s
;
747 x1
= x1_right
+ sm_s
;
748 x2
= x2_right
+ sm_s
;
757 var y1
= document
.getElementById(key2
).offsetTop
+ document
.getElementById(key2
+"."+key3
).offsetTop
+ height_field
;
758 var y2
= document
.getElementById(contr
[K
][key
][key2
][key3
][0]).offsetTop
+
759 document
.getElementById(contr
[K
][key
][key2
][key3
][0]+"."+contr
[K
][key
][key2
][key3
][1]).offsetTop
+ height_field
;
760 if (!selected
&& Glob_X
> x1
- 10 && Glob_X
< x1
+ 10 && Glob_Y
> y1
- 7 && Glob_Y
< y1
+ 7) {
761 Line0(x1
- sm_x
, y1
- sm_y
, x2
- sm_x
, y2
- sm_y
, "rgba(255,0,0,1)");
762 selected
= 1; // Rect(x1-sm_x,y1-sm_y,10,10,"rgba(0,255,0,1)");
763 relation_name
= key
; //
764 Key0
= contr
[K
][key
][key2
][key3
][0];
765 Key1
= contr
[K
][key
][key2
][key3
][1];
766 Key2
= key2
; Key3
= key3
;
769 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] ));
774 //alert(Key0+' - '+Key1+' - '+Key2+' - '+Key3);
775 var left
= Glob_X
- (document
.getElementById('layer_upd_relation').offsetWidth
>>1);
776 document
.getElementById('layer_upd_relation').style
.left
= left
+ 'px';
777 var top
= Glob_Y
- document
.getElementById('layer_upd_relation').offsetHeight
- 10;
778 document
.getElementById('layer_upd_relation').style
.top
= top
+ 'px';
779 document
.getElementById('layer_upd_relation').style
.display
= 'block';
780 link_relation
= 'T1=' + Key0
+ '&F1=' + Key1
+ '&T2=' + Key2
+ '&F2=' + Key3
+ '&K=' + Key
;
784 function Upd_relation()
786 document
.getElementById('layer_upd_relation').style
.display
= 'none';
787 link_relation
+= '&server=' + server
+ '&db=' + db
+ '&token=' + token
+ '&die_save_pos=0';
788 link_relation
+= Get_url_pos();
789 makeRequest('pmd_relation_upd.php', link_relation
);
792 function VisibleTab(id
, t_n
)
795 document
.getElementById(t_n
).style
.display
= 'block';
797 document
.getElementById(t_n
).style
.display
= 'none';
802 function Hide_tab_all(id_this
) // max/min all tables
804 if (id_this
.alt
== 'v') {
806 id_this
.src
= "pmd/images/rightarrow1.png";
809 id_this
.src
= "pmd/images/downarrow1.png";
811 var E
= document
.form1
;
812 for (i
= 0; i
< E
.elements
.length
; i
++) {
813 if (E
.elements
[i
].type
== "checkbox" && E
.elements
[i
].id
.substring(0, 10) == 'check_vis_') {
814 if (id_this
.alt
== 'v') {
815 E
.elements
[i
].checked
= true;
816 document
.getElementById(E
.elements
[i
].value
).style
.display
= 'block';
818 E
.elements
[i
].checked
= false;
819 document
.getElementById(E
.elements
[i
].value
).style
.display
= 'none';
826 function in_array_k(x
, m
)
838 function No_have_constr(id_this
)
842 for (key
in contr
[K
]) // contr name
843 for (key2
in contr
[K
][key
]) // table name
844 for (key3
in contr
[K
][key
][key2
]) // field name
845 a
[key2
] = a
[contr
[K
][key
][key2
][key3
][0]] = 1; // exist constr
848 if (id_this
.alt
== 'v') {
850 id_this
.src
= "pmd/images/rightarrow2.png";
853 id_this
.src
= "pmd/images/downarrow2.png";
855 var E
= document
.form1
;
856 for (i
= 0; i
< E
.elements
.length
; i
++) {
857 if (E
.elements
[i
].type
== "checkbox" && E
.elements
[i
].id
.substring(0, 10) == 'check_vis_')
859 if (!in_array_k(E
.elements
[i
].value
, a
))
860 if (id_this
.alt
== 'v') {
861 E
.elements
[i
].checked
= true;
862 document
.getElementById(E
.elements
[i
].value
).style
.display
= 'block';
864 E
.elements
[i
].checked
= false;
865 document
.getElementById(E
.elements
[i
].value
).style
.display
= 'none';
874 // window.open("pmd_pdf.php?token="+token+"&db="+db,"wind1", "top=200,left=200,width=200,height=100,resizable=yes,scrollbars=yes,menubar=no");
875 Save('pmd_pdf.php?server=' + server
+ '&token=' + token
+ '&db=' + db
);
878 function General_scroll()
881 if (!document.getElementById('show_relation_olways').checked) {
882 document.getElementById("canvas").style.display = 'none';
883 clearTimeout(timeoutID);
884 timeoutID = setTimeout(General_scroll_end, 500);
888 clearTimeout(timeoutID
);
889 timeoutID
= setTimeout
893 document
.getElementById('top_menu').style
.left
= document
.body
.scrollLeft
+ 'px';
894 document
.getElementById('top_menu').style
.top
= document
.body
.scrollTop
+ 'px';
895 document
.getElementById('layer_menu').style
.left
= document
.body
.scrollLeft
+ 'px';
896 document
.getElementById('layer_menu').style
.top
= (document
.body
.scrollTop
+ document
.getElementById('top_menu').offsetHeight
) + 'px';
903 function General_scroll_end()
905 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
906 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
908 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
909 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
911 document.getElementById("canvas").style.display = 'block';
915 function Show_left_menu(id_this
) // max/min all tables
917 if (id_this
.alt
== "v") {
918 var pos
= $("#top_menu").offset();
919 var height
= $("#top_menu").height();
920 document
.getElementById("layer_menu").style
.top
= (pos
.top
+ height
) + 'px';
921 document
.getElementById("layer_menu").style
.left
= pos
.left
+ 'px';
922 document
.getElementById("layer_menu").style
.display
= 'block';
924 id_this
.src
= "pmd/images/uparrow2_m.png";
929 document
.getElementById("layer_menu").style
.top
= -1000 + 'px'; //fast scroll
930 document
.getElementById("layer_menu").style
.display
= 'none';
932 id_this
.src
= "pmd/images/downarrow2_m.png";
935 //------------------------------------------------------------------------------
936 function Top_menu_right(id_this
)
938 if (id_this
.alt
== ">") {
939 document
.getElementById('top_menu').style
.marginLeft
= document
.getElementById('top_menu').offsetWidth
+ 'px'; // = 350
941 id_this
.src
= "pmd/images/2leftarrow_m.png";
943 document
.getElementById('top_menu').style
.marginLeft
= 0;
945 id_this
.src
= "pmd/images/2rightarrow_m.png";
948 //------------------------------------------------------------------------------
949 function Start_display_field()
954 if (!ON_display_field
) {
955 ON_display_field
= 1;
956 document
.getElementById('pmd_hint').innerHTML
= PMA_messages
['strChangeDisplay'];
957 document
.getElementById('pmd_hint').style
.display
= 'block';
958 document
.getElementById('display_field_button').className
= 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA
960 if (isIE
) { // correct for IE
961 document
.getElementById('display_field_button').className
= 'M_butt_Selected_down_IE';
964 document
.getElementById('pmd_hint').innerHTML
= "";
965 document
.getElementById('pmd_hint').style
.display
= 'none';
966 document
.getElementById('display_field_button').className
= 'M_butt';
967 ON_display_field
= 0;
970 //------------------------------------------------------------------------------
971 var TargetColors
= new Array();
972 function getColorByTarget( target
)
974 var color
= ''; //"rgba(0,100,150,1)";
976 for (i
in TargetColors
)
977 if (TargetColors
[i
][0]==target
) {
978 color
= TargetColors
[i
][1];
985 var i
= TargetColors
.length
+1;
990 var color_case
= new Array(
998 var a
= color_case
[d
][0];
999 var b
= color_case
[d
][1];
1000 var c
= color_case
[d
][2];
1001 e
= (1 - (j
- 1) / 6);
1003 var r
= Math
.round(a
* 200 * e
);
1004 var g
= Math
.round(b
* 200 * e
);
1005 var b
= Math
.round(c
* 200 * e
);
1006 var color
= "rgba("+r
+","+g
+","+b
+",1)";
1008 TargetColors
.push( new Array(target
, color
) );
1016 function Click_option(id_this
,column_name
,table_name
)
1018 var left
= Glob_X
- (document
.getElementById(id_this
).offsetWidth
>>1);
1019 document
.getElementById(id_this
).style
.left
= left
+ 'px';
1020 // var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
1021 document
.getElementById(id_this
).style
.top
= (screen
.height
/ 4) + 'px';
1022 document
.getElementById(id_this
).style
.display
= 'block';
1023 document
.getElementById('option_col_name').innerHTML
= '<strong>' + PMA_messages
['strAddOption'] +'"' +column_name
+ '"</strong>';
1024 col_name
= column_name
;
1025 tab_name
= table_name
;
1028 function Close_option()
1030 document
.getElementById('pmd_optionse').style
.display
= 'none';
1033 function Select_all(id_this
,owner
)
1035 var parent
= document
.form1
;
1039 for (i
= 0; i
< parent
.elements
.length
; i
++) {
1040 if (parent
.elements
[i
].type
== "checkbox" && parent
.elements
[i
].id
.substring(0,(9 + id_this
.length
)) == 'select_' + id_this
+ '._') {
1041 if(document
.getElementById('select_all_' + id_this
).checked
== true) {
1042 parent
.elements
[i
].checked
= true;
1043 parent
.elements
[i
].disabled
= true;
1044 var temp
= '`' + id_this
.substring(owner
.length
+1) + '`.*';
1047 parent
.elements
[i
].checked
= false;
1048 parent
.elements
[i
].disabled
= false;
1052 if(document
.getElementById('select_all_' + id_this
).checked
== true) {
1053 select_field
.push('`' + id_this
.substring(owner
.length
+1) + '`.*');
1054 tab
= id_this
.split(".");
1055 from_array
.push(tab
[1]);
1058 for (i
=0; i
< select_field
.length
; i
++) {
1059 if (select_field
[i
] == ('`' + id_this
.substring(owner
.length
+1) + '`.*')) {
1060 select_field
.splice(i
,1);
1063 for(k
=0 ;k
< from_array
.length
;k
++){
1064 if(from_array
[k
] == id_this
){
1065 from_array
.splice(k
,1);
1073 function Table_onover(id_this
,val
,buil
)
1076 document
.getElementById("id_zag_" + id_this
).className
="tab_zag_2";
1078 document
.getElementById("id_zag_" + id_this
+ "_2").className
="tab_zag_2";
1082 document
.getElementById("id_zag_" + id_this
).className
="tab_zag";
1084 document
.getElementById("id_zag_" + id_this
+ "_2").className
="tab_zag";
1089 /* This function stores selected column information in select_field[]
1090 * In case column is checked it add else it deletes
1093 function store_column(id_this
,owner
,col
)
1097 if (document
.getElementById('select_' + owner
+ '.' + id_this
+ '._' + col
).checked
== true) {
1098 select_field
.push('`' + id_this
+ '`.`' + col
+'`');
1099 from_array
.push(id_this
);
1102 for (i
= 0; i
< select_field
.length
;i
++) {
1103 if (select_field
[i
] == ('`' + id_this
+ '`.`' + col
+'`')) {
1104 select_field
.splice(i
,1);
1108 for (k
= 0 ;k
< from_array
.length
;k
++){
1109 if(from_array
[k
] == id_this
){
1110 from_array
.splice(k
,1);
1118 * This function builds object and adds them to history_array
1119 * first it does a few checks on each object, then makes an object(where,rename,groupby,aggregate,orderby)
1120 * then a new history object is made and finally all these history objects are addded to history_array[]
1130 function add_object()
1132 var rel
= document
.getElementById('rel_opt');
1134 var init
= history_array
.length
;
1135 if (rel
.value
!= '--') {
1136 if (document
.getElementById('Query').value
== "") {
1137 document
.getElementById('pmd_hint').innerHTML
= "value/subQuery is empty" ;
1138 document
.getElementById('pmd_hint').style
.display
= 'block';
1141 var p
= document
.getElementById('Query');
1142 var where_obj
= new where(rel
.value
,p
.value
);//make where object
1143 history_array
.push(new history(col_name
,where_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Where"));
1148 if (document
.getElementById('new_name').value
!="") {
1149 var rename_obj
= new rename(document
.getElementById('new_name').value
);//make Rename object
1150 history_array
.push(new history(col_name
,rename_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Rename"));
1152 document
.getElementById('new_name').value
= "" ;
1154 if (document
.getElementById('operator').value
!= '---') {
1155 var aggregate_obj
= new aggregate(document
.getElementById('operator').value
) ;
1156 history_array
.push(new history(col_name
,aggregate_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Aggregate"));
1158 document
.getElementById('operator').value
= '---';
1159 //make aggregate operator
1161 if (document
.getElementById('groupby').checked
== true ) {
1162 history_array
.push(new history(col_name
,'GroupBy',tab_name
,h_tabs
[downer
+ '.' +tab_name
],"GroupBy"));
1164 document
.getElementById('groupby').checked
= false;
1167 if (document
.getElementById('h_rel_opt').value
!= '--') {
1168 if (document
.getElementById('having').value
== "") {
1169 document
.getElementById('pmd_hint').innerHTML
= "value/subQuery is empty" ;
1170 document
.getElementById('pmd_hint').style
.display
= 'block';
1173 var p
= document
.getElementById('having');
1174 var where_obj
= new having(document
.getElementById('h_rel_opt').value
,p
.value
,document
.getElementById('h_operator').value
);//make where object
1175 history_array
.push(new history(col_name
,where_obj
,tab_name
,h_tabs
[downer
+ '.' + tab_name
],"Having"));
1177 document
.getElementById('h_rel_opt').value
= '--';
1178 document
.getElementById('h_operator').value
= '---';
1179 p
.value
= ""; //make having
1181 if (document
.getElementById('orderby').checked
== true) {
1182 history_array
.push(new history(col_name
,'OrderBy',tab_name
,h_tabs
[downer
+ '.' + tab_name
],"OrderBy"));
1184 document
.getElementById('orderby').checked
= false;
1187 document
.getElementById('pmd_hint').innerHTML
= sum
+ "object created" ;
1188 document
.getElementById('pmd_hint').style
.display
= 'block';
1189 //output sum new objects created
1190 var existingDiv
= document
.getElementById('ab');
1191 existingDiv
.innerHTML
= display(init
,history_array
.length
);