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.visibility = 'hidden';
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('hint').style.left = (Glob_X + 20) + 'px';
163 document.getElementById('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.visibility = 'visible';
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('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('hint').innerHTML = PMA_messages['strSelectReferencedKey'];
539 document.getElementById('hint').style.visibility = "visible";
540 document.getElementById('rel_button').className = 'M_butt_Selected_down';
542 document.getElementById('hint').innerHTML = "";
543 document.getElementById('hint').style.visibility = "hidden";
544 document.getElementById('rel_button').className = 'M_butt';
550 function Click_field(T, f, PK) // table field
554 //.style.display=='none' .style.visibility = "hidden"
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('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.visibility = "visible";
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('hint').innerHTML = "";
600 document.getElementById('hint').style.visibility = "hidden";
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.visibility = 'hidden';
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.visibility = 'visible';
780 link_relation = 'T1=' + Key0 + '&F1=' + Key1 + '&T2=' + Key2 + '&F2=' + Key3 + '&K=' + Key;
784 function Upd_relation()
786 document.getElementById('layer_upd_relation').style.visibility = 'hidden';
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.visibility = 'visible';
797 document.getElementById(t_n).style.visibility = 'hidden';
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.visibility = 'visible';
818 E.elements[i].checked = false;
819 document.getElementById(E.elements[i].value).style.visibility = 'hidden';
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.visibility = 'visible';
864 E.elements[i].checked = false;
865 document.getElementById(E.elements[i].value).style.visibility = 'hidden';
873 var WinHelp = window.open("pmd_help.php", "wind1", "top=200,left=400,width=300,height=200,resizable=yes,scrollbars=yes,menubar=no");
879 // window.open("pmd_pdf.php?token="+token+"&db="+db,"wind1", "top=200,left=200,width=200,height=100,resizable=yes,scrollbars=yes,menubar=no");
880 Save('pmd_pdf.php?server=' + server + '&token=' + token + '&db=' + db);
883 function General_scroll()
886 if (!document.getElementById('show_relation_olways').checked) {
887 document.getElementById("canvas").style.visibility = 'hidden';
888 clearTimeout(timeoutID);
889 timeoutID = setTimeout(General_scroll_end, 500);
893 clearTimeout(timeoutID);
894 timeoutID = setTimeout
898 document.getElementById('top_menu').style.left = document.body.scrollLeft + 'px';
899 document.getElementById('top_menu').style.top = document.body.scrollTop + 'px';
900 document.getElementById('layer_menu').style.left = document.body.scrollLeft + 'px';
901 document.getElementById('layer_menu').style.top = (document.body.scrollTop + document.getElementById('top_menu').offsetHeight) + 'px';
908 function General_scroll_end()
910 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
911 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
913 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
914 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
916 document.getElementById("canvas").style.visibility = 'visible';
920 function Show_left_menu(id_this) // max/min all tables
922 if (id_this.alt == "v") {
923 document.getElementById("layer_menu").style.top = document.getElementById('top_menu').offsetHeight + 'px';
924 document.getElementById("layer_menu").style.visibility = 'visible';
926 id_this.src = "pmd/images/uparrow2_m.png";
931 document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
932 document.getElementById("layer_menu").style.visibility = 'hidden';
934 id_this.src = "pmd/images/downarrow2_m.png";
937 //------------------------------------------------------------------------------
938 function Top_menu_right(id_this)
940 if (id_this.alt == ">") {
941 document.getElementById('top_menu').style.marginLeft = document.getElementById('top_menu').offsetWidth + 'px'; // = 350
943 id_this.src = "pmd/images/2leftarrow_m.png";
945 document.getElementById('top_menu').style.marginLeft = 0;
947 id_this.src = "pmd/images/2rightarrow_m.png";
950 //------------------------------------------------------------------------------
951 function Start_display_field()
956 if (!ON_display_field) {
957 ON_display_field = 1;
958 document.getElementById('hint').innerHTML = PMA_messages['strChangeDisplay'];
959 document.getElementById('hint').style.visibility = "visible";
960 document.getElementById('display_field_button').className = 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA
962 if (isIE) { // correct for IE
963 document.getElementById('display_field_button').className = 'M_butt_Selected_down_IE';
966 document.getElementById('hint').innerHTML = "";
967 document.getElementById('hint').style.visibility = "hidden";
968 document.getElementById('display_field_button').className = 'M_butt';
969 ON_display_field = 0;
972 //------------------------------------------------------------------------------
973 var TargetColors = new Array();
974 function getColorByTarget( target )
976 var color = ''; //"rgba(0,100,150,1)";
978 for (i in TargetColors)
979 if (TargetColors[i][0]==target) {
980 color = TargetColors[i][1];
987 var i = TargetColors.length+1;
992 var color_case = new Array(
1000 var a = color_case[d][0];
1001 var b = color_case[d][1];
1002 var c = color_case[d][2];
1003 e = (1 - (j - 1) / 6);
1005 var r = Math.round(a * 200 * e);
1006 var g = Math.round(b * 200 * e);
1007 var b = Math.round(c * 200 * e);
1008 var color = "rgba("+r+","+g+","+b+",1)";
1010 TargetColors.push( new Array(target, color) );
1018 function Click_option(id_this,column_name,table_name)
1020 var left = Glob_X - (document.getElementById(id_this).offsetWidth>>1);
1021 document.getElementById(id_this).style.left = left + 'px';
1022 // var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
1023 document.getElementById(id_this).style.top = (screen.height / 4) + 'px';
1024 document.getElementById(id_this).style.visibility = "visible";
1025 document.getElementById('option_col_name').innerHTML = '<strong>' + PMA_messages['strAddOption'] +'"' +column_name+ '"</strong>';
1026 col_name = column_name;
1027 tab_name = table_name;
1030 function Close_option()
1032 document.getElementById('pmd_optionse').style.visibility = "hidden";
1035 function Select_all(id_this,owner)
1037 var parent= document.form1;
1041 for(i = 0; i < parent.elements.length; i++) {
1042 if (parent.elements[i].type == "checkbox" && parent.elements[i].id.substring(0,(9 + id_this.length)) == 'select_' + id_this + '._') {
1043 if(document.getElementById('select_all_' + id_this).checked == true) {
1044 parent.elements[i].checked = true;
1045 parent.elements[i].disabled = true;
1046 var temp = '`' + id_this.substring(owner.length +1) + '`.*';
1049 parent.elements[i].checked = false;
1050 parent.elements[i].disabled = false;
1054 if(document.getElementById('select_all_' + id_this).checked == true) {
1055 select_field.push('`' + id_this.substring(owner.length +1) + '`.*');
1056 tab = id_this.split(".");
1057 from_array.push(tab[1]);
1060 for (i =0; i < select_field.length; i++) {
1061 if (select_field[i] == ('`' + id_this.substring(owner.length +1) + '`.*')) {
1062 select_field.splice(i,1);
1065 for(k =0 ;k < from_array.length;k++){
1066 if(from_array[k] == id_this){
1067 from_array.splice(k,1);
1075 function Table_onover(id_this,val,buil)
1078 document.getElementById("id_zag_" + id_this).className="tab_zag_2";
1080 document.getElementById("id_zag_" + id_this + "_2").className="tab_zag_2";
1084 document.getElementById("id_zag_" + id_this).className="tab_zag";
1086 document.getElementById("id_zag_" + id_this + "_2").className="tab_zag";
1091 /* This function stores selected column information in select_field[]
1092 * In case column is checked it add else it deletes
1095 function store_column(id_this,owner,col) {
1098 if (document.getElementById('select_' + owner + '.' + id_this + '._' + col).checked == true) {
1099 select_field.push('`' + id_this + '`.`' + col +'`');
1100 from_array.push(id_this);
1103 for(i; i < select_field.length ;i++) {
1104 if (select_field[i] == ('`' + id_this + '`.`' + col +'`')) {
1105 select_field.splice(i,1);
1109 for(k =0 ;k < from_array.length;k++){
1110 if(from_array[k] == id_this){
1111 from_array.splice(k,1);
1119 * This function builds object and adds them to history_array
1120 * first it does a few checks on each object, then makes an object(where,rename,groupby,aggregate,orderby)
1121 * then a new history object is made and finally all these history objects are addded to history_array[]
1131 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('hint').innerHTML = "value/subQuery is empty" ;
1138 document.getElementById('hint').style.visibility = "visible";
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('hint').innerHTML = "value/subQuery is empty" ;
1170 document.getElementById('hint').style.visibility = "visible";
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('hint').innerHTML = sum + "object created" ;
1188 document.getElementById('hint').style.visibility = "visible";
1189 //output sum new objects created
1190 var existingDiv = document.getElementById('ab');
1191 existingDiv.innerHTML = display(init,history_array.length);