1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @package phpMyAdmin-Designer
12 var sm_x = 2, sm_y = 2;
19 var ON_display_field = 0;
20 // relation_style: 0 - angular 1 - direct
21 var ON_angular_direct = 1;
23 var link_relation = "";
26 var canvas_height = 0;
27 var osn_tab_width = 0;
28 var osn_tab_height = 0;
32 var layer_menu_cur_click = 0;
38 //------------------------------------------------------------------------------
39 //------------------------------------------------------------------------------
40 //------------------------------------------------------------------------------
43 //window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
45 document.onmousedown = MouseDown;
46 document.onmouseup = MouseUp;
47 document.onmousemove = MouseMove;
49 var isIE = document.all && !window.opera;
50 var isNN = !document.all && document.getElementById;
51 var isN4 = document.layers;
54 window.onscroll = General_scroll;
55 document.onselectstart = function () {return false;};
58 //document.onmouseup = function(){General_scroll_end();}
62 if (cur_click != null) {
63 offsetx = isIE ? event.clientX + document.body.scrollLeft : e.pageX;
64 offsety = isIE ? event.clientY + document.body.scrollTop : e.pageY;
65 dx = offsetx - parseInt(cur_click.style.left);
66 dy = offsety - parseInt(cur_click.style.top);
67 //alert(" dx = " + dx + " dy = " +dy);
68 document.getElementById("canvas").style.visibility = 'hidden';
70 var left = parseInt(cur_click.style.left);
71 var top = parseInt(cur_click.style.top);
75 alert(" dx = " + dx + " dy = " +dy);
77 cur_click.style.zIndex = 2;
79 if (layer_menu_cur_click) {
80 offsetx = isIE ? event.clientX + document.body.scrollLeft : e.pageX;
81 dx = offsetx - parseInt(document.getElementById("layer_menu").style.width);
89 Glob_X = isIE ? event.clientX + document.body.scrollLeft : e.pageX;
90 Glob_Y = isIE ? event.clientY + document.body.scrollTop : e.pageY;
92 //mouseX = (bw.ns4||bw.ns6)? e.pageX: bw.ie&&bw.win&&!bw.ie4? (event.clientX-2)+document.body.scrollLeft : event.clientX+document.body.scrollLeft;
93 //mouseY = (bw.ns4||bw.ns6)? e.pageY: bw.ie&&bw.win&&!bw.ie4? (event.clientY-2)+document.body.scrollTop : event.clientY+document.body.scrollTop;
95 //window.status = "X = "+ Glob_X + " Y = "+ Glob_Y;
97 if (cur_click != null) {
98 var mGx = Glob_X - dx;
99 var mGy = Glob_Y - dy;
100 mGx = mGx > 0 ? mGx : 0;
101 mGy = mGy > 0 ? mGy : 0;
104 mGx = mGx % step < step / 2 ? mGx - mGx % step : mGx - mGx % step + step;
105 mGy = mGy % step < step / 2 ? mGy - mGy % step : mGy - mGy % step + step;
108 cur_click.style.left = mGx + 'px';
109 cur_click.style.top = mGy + 'px';
112 if (ON_relation || ON_display_field) {
113 document.getElementById('hint').style.left = (Glob_X + 20) + 'px';
114 document.getElementById('hint').style.top = (Glob_Y + 20) + 'px';
117 if (layer_menu_cur_click) {
118 document.getElementById("layer_menu").style.width = ((Glob_X - dx) >= 150 ? Glob_X - dx : 150) + 'px';
119 //document.getElementById("layer_menu").style.height = Glob_Y - dy>=200?Glob_Y - dy:200;
120 //document.getElementById("id_scroll_tab").style.height = Glob_Y - dy2;
126 if (cur_click != null) {
127 document.getElementById("canvas").style.visibility = 'visible';
129 cur_click.style.zIndex = 1;
132 layer_menu_cur_click = 0;
133 //window.releaseEvents(Event.MOUSEMOVE);
135 //------------------------------------------------------------------------------
136 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
142 // return s.substring(0,s.length-2)*1; //re = /(\d+)\w*/; newstr = str.replace(re, "$1");
145 function Canvas_pos()
147 canvas_width = document.getElementById('canvas').width = osn_tab_width - 3;
148 canvas_height = document.getElementById('canvas').height = osn_tab_height - 3;
151 document.getElementById('canvas').style.width = ((osn_tab_width - 3)?(osn_tab_width - 3):0) + 'px';
152 document.getElementById('canvas').style.height = ((osn_tab_height - 3)?(osn_tab_height - 3):0) + 'px';
156 function Osn_tab_pos()
158 osn_tab_width = parseInt(document.getElementById('osn_tab').style.width);
159 osn_tab_height = parseInt(document.getElementById('osn_tab').style.height);
165 //alert( document.getElementById('osn_tab').offsetTop);
168 document.getElementById('top_menu').style.position = 'absolute';
169 document.getElementById('layer_menu').style.position = 'absolute';
172 document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
173 sm_x += document.getElementById('osn_tab').offsetLeft;
174 sm_y += document.getElementById('osn_tab').offsetTop;
179 id_hint = document.getElementById('hint');
186 //-------------------------------- new -----------------------------------------
187 function Rezize_osn_tab()
191 for (key in j_tabs) {
192 var k_x = parseInt(document.getElementById(key).style.left) + document.getElementById(key).offsetWidth;
193 var k_y = parseInt(document.getElementById(key).style.top) + document.getElementById(key).offsetHeight;
194 max_X = max_X < k_x ? k_x : max_X;
195 max_Y = max_Y < k_y ? k_y : max_Y;
198 osn_tab_width = max_X + 50;
199 osn_tab_height = max_Y + 50;
201 document.getElementById('osn_tab').style.width = osn_tab_width + 'px';
202 document.getElementById('osn_tab').style.height = osn_tab_height + 'px';
204 //------------------------------------------------------------------------------
207 * refreshes display, must be called after state changes
218 for (key in contr[K]) // contr name
219 for (key2 in contr[K][key]) // table name
220 for (key3 in contr[K][key][key2]) // field name
222 if (!document.getElementById("check_vis_" + key2).checked ||
223 !document.getElementById("check_vis_" + contr[K][key][key2][key3][0]).checked) {
227 var x1_left = document.getElementById(key2).offsetLeft+1;
228 var x1_right = x1_left + document.getElementById(key2).offsetWidth;
229 var x2_left = document.getElementById(contr[K][key][key2][key3][0]).offsetLeft;
230 var x2_right = x2_left + document.getElementById(contr[K][key][key2][key3][0]).offsetWidth;
231 a[0] = Math.abs(x1_left - x2_left);
232 a[1] = Math.abs(x1_left - x2_right);
233 a[2] = Math.abs(x1_right - x2_left);
234 a[3] = Math.abs(x1_right - x2_right);
235 n = s_left = s_right = 0;
236 for (var i = 1; i < 4; i++) {
243 x2 = x2_right + sm_s;
249 x1 = x1_right + sm_s;
256 x1 = x1_right + sm_s;
257 x2 = x2_right + sm_s;
265 //alert(key2 + "." + key3);
267 var row_offset_top = 0;
268 //alert('id_tbody_' + key2);
269 //alert(document.getElementById('id_hide_tbody_' + key2));
270 var tab_hide_button = document.getElementById('id_hide_tbody_' + key2);
272 //alert(tab_hide_button.innerHTML);
273 if (tab_hide_button.innerHTML == 'v') {
274 row_offset_top = document.getElementById(key2 + "." + key3).offsetTop;
277 var y1 = document.getElementById(key2).offsetTop
283 var tab_hide_button = document.getElementById('id_hide_tbody_' + contr[K][key][key2][key3][0]);
284 if (tab_hide_button.innerHTML == 'v') {
285 row_offset_top = document.getElementById(contr[K][key][key2][key3][0]
286 + '.' + contr[K][key][key2][key3][1]).offsetTop;
290 document.getElementById(contr[K][key][key2][key3][0]).offsetTop
294 //alert(y1 + ' - ' + key2 + "." + key3);
295 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] ) );
300 * draws a line from x1:y1 to x2:y2 with color
302 function Line(x1, y1, x2, y2, color_line)
304 var canvas = document.getElementById("canvas");
305 var ctx = canvas.getContext("2d");
306 ctx.strokeStyle = color_line;
315 * draws a relation/constraint line, whether angular or not
317 function Line0(x1, y1, x2, y2, color_line)
319 Circle(x1, y1, 3, 3, color_line);
320 Rect(x2 - 1, y2 - 2, 4, 4, color_line);
322 if (ON_angular_direct) {
323 Line2(x1, y1, x2, y2, color_line);
325 Line3(x1, y1, x2, y2, color_line);
330 * draws a angualr relation/constraint line
332 function Line2(x1, y1, x2, y2, color_line)
343 } else if (x1 < x2) {
351 Line(x1, y1, x1_, y1, color_line);
352 Line(x2, y2, x2_, y2, color_line);
353 Line(x1_, y1, x2_, y2, color_line);
357 * draws a relation/constraint line
359 function Line3(x1, y1, x2, y2, color_line)
366 x1_ += x2 - x1 + sm_add;
369 x2_ += x1 - x2 + sm_add;
373 Line(x1, y1, x1_, y1, color_line);
374 Line(x2, y2, x2_, y2, color_line);
375 Line(x1_, y1, x2_, y2, color_line);
380 x2_ -= x2 - x1 + sm_add;
383 x1_ -= x1 - x2 + sm_add;
387 Line(x1, y1, x1_, y1, color_line);
388 Line(x2, y2, x2_, y2, color_line);
389 Line(x1_, y1, x2_, y2, color_line);
393 var x_s = (x1 + x2) / 2;
394 Line(x1, y1, x_s, y1, color_line);
395 Line(x_s, y2, x2, y2, color_line);
396 Line(x_s, y1, x_s, y2, color_line);
399 function Circle(x, y, r, w, color)
401 var ctx = document.getElementById('canvas').getContext('2d');
405 ctx.strokeStyle = color;
406 ctx.arc(x, y, r, 0, 2 * Math.PI, true);
412 var canvas = document.getElementById("canvas");
413 var ctx = canvas.getContext("2d");
414 ctx.clearRect(0, 0, canvas_width, canvas_height);
417 function Rect(x1, y1, w, h, color)
419 var ctx = document.getElementById('canvas').getContext('2d');
420 ctx.fillStyle = color;
421 ctx.fillRect(x1, y1, w, h);
424 //------------------------------ SAVE ------------------------------------------
425 function Save(url) // (del?) no for pdf
427 for (key in j_tabs) {
428 document.getElementById('t_x_' + key + '_').value = parseInt(document.getElementById(key).style.left);
429 document.getElementById('t_y_' + key + '_').value = parseInt(document.getElementById(key).style.top);
430 document.getElementById('t_v_' + key + '_').value = document.getElementById('id_tbody_' + key).style.display == 'none' ? 0 : 1;
431 document.getElementById('t_h_' + key + '_').value = document.getElementById('check_vis_' + key).checked ? 1 : 0;
433 document.form1.action = url;
434 document.form1.submit();
437 function Get_url_pos()
440 for (key in j_tabs) {
441 poststr += '&t_x[' + key + ']=' + parseInt(document.getElementById(key).style.left);
442 poststr += '&t_y[' + key + ']=' + parseInt(document.getElementById(key).style.top);
443 poststr += '&t_v[' + key + ']=' + (document.getElementById('id_tbody_' + key).style.display == 'none' ? 0 : 1);
444 poststr += '&t_h[' + key + ']=' + (document.getElementById('check_vis_' + key).checked ? 1 : 0);
451 var poststr = 'IS_AJAX=1&server='+server+'&db=' + db + '&token=' + token + '&die_save_pos=1';
452 poststr += Get_url_pos();
453 makeRequest('pmd_save_pos.php', poststr);
460 document.getElementById('grid_button').className = 'M_butt_Selected_down';
462 document.getElementById('grid_button').className = 'M_butt';
467 function Angular_direct()
469 if (ON_angular_direct) {
470 ON_angular_direct = 0;
471 document.getElementById('angular_direct_button').className = 'M_butt_Selected_down';
473 ON_angular_direct = 1;
474 document.getElementById('angular_direct_button').className = 'M_butt';
478 //++++++++++++++++++++++++++++++ RELATION ++++++++++++++++++++++++++++++++++++++
479 function Start_relation()
481 if (ON_display_field) {
486 document.getElementById('foreign_relation').style.display = '';
488 document.getElementById('hint').innerHTML = PMA_messages['strSelectReferencedKey'];
489 document.getElementById('hint').style.visibility = "visible";
490 document.getElementById('rel_button').className = 'M_butt_Selected_down';
492 document.getElementById('hint').innerHTML = "";
493 document.getElementById('hint').style.visibility = "hidden";
494 document.getElementById('rel_button').className = 'M_butt';
500 function Click_field(T, f, PK) // table field
504 //.style.display=='none' .style.visibility = "hidden"
506 alert(PMA_messages['strPleaseSelectPrimaryOrUniqueKey']);
509 if (j_tabs[db + '.' + T] != '1') {
510 document.getElementById('foreign_relation').style.display = 'none';
513 link_relation = "T1=" + T + "&F1=" + f;
514 document.getElementById('hint').innerHTML = PMA_messages['strSelectForeignKey'];
516 Start_relation(); // hidden hint...
517 if (j_tabs[db + '.' + T] != '1' || !PK) {
518 document.getElementById('foreign_relation').style.display = 'none';
520 var left = Glob_X - (document.getElementById('layer_new_relation').offsetWidth>>1);
521 document.getElementById('layer_new_relation').style.left = left + 'px';
522 var top = Glob_Y - document.getElementById('layer_new_relation').offsetHeight + 40;
523 document.getElementById('layer_new_relation').style.top = top + 'px';
524 document.getElementById('layer_new_relation').style.visibility = "visible";
525 link_relation += '&T2=' + T + '&F2=' + f;
529 if (ON_display_field) {
530 // if is display field
531 if (display_field[T] == f) {
533 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ',';alert(s);
534 old_class = 'tab_field';
535 //display_field.splice(T, 1);
536 delete display_field[T];
537 //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ', ';alert(s);
538 //n = 0;for(k in display_field)n++;alert(n);
540 old_class = 'tab_field_3';
541 if (display_field[T]) {
542 document.getElementById('id_tr_' + T + '.' + display_field[T]).className = 'tab_field';
543 //display_field.splice(T, 1);
544 delete display_field[T];
546 display_field[T] = f;
548 ON_display_field = 0;
549 document.getElementById('hint').innerHTML = "";
550 document.getElementById('hint').style.visibility = "hidden";
551 document.getElementById('display_field_button').className = 'M_butt';
552 makeRequest('pmd_display_field.php', 'T=' + T + '&F=' + f + '&server=' + server + '&db=' + db + '&token=' + token);
556 function New_relation()
558 document.getElementById('layer_new_relation').style.visibility = 'hidden';
559 link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
560 link_relation += '&on_delete=' + document.getElementById('on_delete').value + '&on_update=' + document.getElementById('on_update').value;
561 link_relation += Get_url_pos();
563 //alert(link_relation);
564 makeRequest('pmd_relation_new.php', link_relation);
567 //-------------------------- create tables -------------------------------------
569 function Start_table_new()
571 window.location.href = 'tbl_create.php?server=' + server + '&db=' + db + '&token=' + token;
574 function Start_tab_upd(table)
576 window.location.href = 'tbl_structure.php?server=' + server + '&db=' + db + '&token=' + token + '&table=' + table;
578 //--------------------------- hide tables --------------------------------------
580 function Small_tab_all(id_this) // max/min all tables
582 if (id_this.alt == "v") {
583 for (key in j_tabs) {
584 if (document.getElementById('id_hide_tbody_'+key).innerHTML == "v") {
589 id_this.src = "pmd/images/rightarrow1.png";
591 for (key in j_tabs) {
592 if (document.getElementById('id_hide_tbody_'+key).innerHTML != "v") {
597 id_this.src = "pmd/images/downarrow1.png";
602 function Small_tab_invert() // invert max/min all tables
604 for (key in j_tabs) {
610 function Small_tab_refresh()
612 for (key in j_tabs) {
613 if(document.getElementById('id_hide_tbody_'+key).innerHTML != "v") {
620 function Small_tab(t, re_load)
622 var id = document.getElementById('id_tbody_' + t);
623 var id_this = document.getElementById('id_hide_tbody_' + t);
624 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);
650 setTimeout(function(){document.getElementById('id_zag_' + t).className = 'tab_zag';}, 800);
652 //------------------------------------------------------------------------------
654 function Canvas_click(id)
657 var relation_name = 0;
660 var Key0, Key1, Key2, Key3, Key, x1, x2;
663 for (key in contr[K])
664 for (key2 in contr[K][key])
665 for (key3 in contr[K][key][key2]) {
666 if (!document.getElementById("check_vis_"+key2).checked ||
667 !document.getElementById("check_vis_"+contr[K][key][key2][key3][0]).checked) continue; // if hide
668 var x1_left = document.getElementById(key2).offsetLeft + 1;//document.getElementById(key2+"."+key3).offsetLeft;
669 var x1_right = x1_left + document.getElementById(key2).offsetWidth;
670 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
671 var x2_right = x2_left + document.getElementById(contr[K][key][key2][key3][0]).offsetWidth;
672 a[0] = Math.abs(x1_left - x2_left);
673 a[1] = Math.abs(x1_left - x2_right);
674 a[2] = Math.abs(x1_right - x2_left);
675 a[3] = Math.abs(x1_right - x2_right);
676 n = s_left = s_right = 0;
677 for (var i = 1; i < 4; i++) {
684 x2 = x2_right + sm_s;
690 x1 = x1_right + sm_s;
697 x1 = x1_right + sm_s;
698 x2 = x2_right + sm_s;
707 var y1 = document.getElementById(key2).offsetTop + document.getElementById(key2+"."+key3).offsetTop + height_field;
708 var y2 = document.getElementById(contr[K][key][key2][key3][0]).offsetTop +
709 document.getElementById(contr[K][key][key2][key3][0]+"."+contr[K][key][key2][key3][1]).offsetTop + height_field;
710 if (!selected && Glob_X > x1 - 10 && Glob_X < x1 + 10 && Glob_Y > y1 - 7 && Glob_Y < y1 + 7) {
711 Line0(x1 - sm_x, y1 - sm_y, x2 - sm_x, y2 - sm_y, "rgba(255,0,0,1)");
712 selected = 1; // Rect(x1-sm_x,y1-sm_y,10,10,"rgba(0,255,0,1)");
713 relation_name = key; //
714 Key0 = contr[K][key][key2][key3][0];
715 Key1 = contr[K][key][key2][key3][1];
716 Key2 = key2; Key3 = key3;
719 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] ));
724 //alert(Key0+' - '+Key1+' - '+Key2+' - '+Key3);
725 var left = Glob_X - (document.getElementById('layer_upd_relation').offsetWidth>>1);
726 document.getElementById('layer_upd_relation').style.left = left + 'px';
727 var top = Glob_Y - document.getElementById('layer_upd_relation').offsetHeight - 10;
728 document.getElementById('layer_upd_relation').style.top = top + 'px';
729 document.getElementById('layer_upd_relation').style.visibility = 'visible';
730 link_relation = 'T1=' + Key0 + '&F1=' + Key1 + '&T2=' + Key2 + '&F2=' + Key3 + '&K=' + Key;
734 function Upd_relation()
736 document.getElementById('layer_upd_relation').style.visibility = 'hidden';
737 link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
738 link_relation += Get_url_pos();
739 makeRequest('pmd_relation_upd.php', link_relation);
742 function VisibleTab(id, t_n)
745 document.getElementById(t_n).style.visibility = 'visible';
747 document.getElementById(t_n).style.visibility = 'hidden';
752 function Hide_tab_all(id_this) // max/min all tables
754 if (id_this.alt == 'v') {
756 id_this.src = "pmd/images/rightarrow1.png";
759 id_this.src = "pmd/images/downarrow1.png";
761 var E = document.form1;
762 for (i = 0; i < E.elements.length; i++) {
763 if (E.elements[i].type == "checkbox" && E.elements[i].id.substring(0, 10) == 'check_vis_') {
764 if (id_this.alt == 'v') {
765 E.elements[i].checked = true;
766 document.getElementById(E.elements[i].value).style.visibility = 'visible';
768 E.elements[i].checked = false;
769 document.getElementById(E.elements[i].value).style.visibility = 'hidden';
776 function in_array_k(x, m)
788 function No_have_constr(id_this)
792 for (key in contr[K]) // contr name
793 for (key2 in contr[K][key]) // table name
794 for (key3 in contr[K][key][key2]) // field name
795 a[key2] = a[contr[K][key][key2][key3][0]] = 1; // exist constr
798 if (id_this.alt == 'v') {
800 id_this.src = "pmd/images/rightarrow2.png";
803 id_this.src = "pmd/images/downarrow2.png";
805 var E = document.form1;
806 for (i = 0; i < E.elements.length; i++) {
807 if (E.elements[i].type == "checkbox" && E.elements[i].id.substring(0, 10) == 'check_vis_')
809 if (!in_array_k(E.elements[i].value, a))
810 if (id_this.alt == 'v') {
811 E.elements[i].checked = true;
812 document.getElementById(E.elements[i].value).style.visibility = 'visible';
814 E.elements[i].checked = false;
815 document.getElementById(E.elements[i].value).style.visibility = 'hidden';
823 var WinHelp = window.open("pmd_help.php", "wind1", "top=200,left=400,width=300,height=200,resizable=yes,scrollbars=yes,menubar=no");
829 // window.open("pmd_pdf.php?token="+token+"&db="+db,"wind1", "top=200,left=200,width=200,height=100,resizable=yes,scrollbars=yes,menubar=no");
830 Save('pmd_pdf.php?server=' + server + '&token=' + token + '&db=' + db);
833 function General_scroll()
836 if (!document.getElementById('show_relation_olways').checked) {
837 document.getElementById("canvas").style.visibility = 'hidden';
838 clearTimeout(timeoutID);
839 timeoutID = setTimeout(General_scroll_end, 500);
843 clearTimeout(timeoutID);
844 timeoutID = setTimeout
848 document.getElementById('top_menu').style.left = document.body.scrollLeft + 'px';
849 document.getElementById('top_menu').style.top = document.body.scrollTop + 'px';
850 document.getElementById('layer_menu').style.left = document.body.scrollLeft + 'px';
851 document.getElementById('layer_menu').style.top = (document.body.scrollTop + document.getElementById('top_menu').offsetHeight) + 'px';
858 function General_scroll_end()
860 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
861 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
863 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
864 document.getElementById('layer_menu').style.top = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
866 document.getElementById("canvas").style.visibility = 'visible';
870 function Show_left_menu(id_this) // max/min all tables
872 if (id_this.alt == "v") {
873 document.getElementById("layer_menu").style.top = document.getElementById('top_menu').offsetHeight + 'px';
874 document.getElementById("layer_menu").style.visibility = 'visible';
876 id_this.src = "pmd/images/uparrow2_m.png";
881 document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
882 document.getElementById("layer_menu").style.visibility = 'hidden';
884 id_this.src = "pmd/images/downarrow2_m.png";
887 //------------------------------------------------------------------------------
888 function Top_menu_right(id_this)
890 if (id_this.alt == ">") {
891 document.getElementById('top_menu').style.marginLeft = document.getElementById('top_menu').offsetWidth + 'px'; // = 350
893 id_this.src = "pmd/images/2leftarrow_m.png";
895 document.getElementById('top_menu').style.marginLeft = 0;
897 id_this.src = "pmd/images/2rightarrow_m.png";
900 //------------------------------------------------------------------------------
901 function Start_display_field()
906 if (!ON_display_field) {
907 ON_display_field = 1;
908 document.getElementById('hint').innerHTML = PMA_messages['strChangeDisplay'];
909 document.getElementById('hint').style.visibility = "visible";
910 document.getElementById('display_field_button').className = 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA
912 if (isIE) { // correct for IE
913 document.getElementById('display_field_button').className = 'M_butt_Selected_down_IE';
916 document.getElementById('hint').innerHTML = "";
917 document.getElementById('hint').style.visibility = "hidden";
918 document.getElementById('display_field_button').className = 'M_butt';
919 ON_display_field = 0;
922 //------------------------------------------------------------------------------
923 var TargetColors = new Array();
924 function getColorByTarget( target )
926 var color = ''; //"rgba(0,100,150,1)";
928 for (i in TargetColors)
929 if (TargetColors[i][0]==target) {
930 color = TargetColors[i][1];
937 var i = TargetColors.length+1;
942 var color_case = new Array(
950 var a = color_case[d][0];
951 var b = color_case[d][1];
952 var c = color_case[d][2];
953 e = (1 - (j - 1) / 6);
955 var r = Math.round(a * 200 * e);
956 var g = Math.round(b * 200 * e);
957 var b = Math.round(c * 200 * e);
958 var color = "rgba("+r+","+g+","+b+",1)";
960 TargetColors.push( new Array(target, color) );
968 function Click_option(id_this,column_name,table_name)
970 var left = Glob_X - (document.getElementById(id_this).offsetWidth>>1);
971 document.getElementById(id_this).style.left = left + 'px';
972 // var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
973 document.getElementById(id_this).style.top = (screen.height / 4) + 'px';
974 document.getElementById(id_this).style.visibility = "visible";
975 document.getElementById('option_col_name').innerHTML = '<strong>' + PMA_messages['strAddOption'] +'"' +column_name+ '"</strong>';
976 col_name = column_name;
977 tab_name = table_name;
980 function Close_option()
982 document.getElementById('pmd_optionse').style.visibility = "hidden";
985 function Select_all(id_this,owner)
987 var parent= document.form1;
991 for(i = 0; i < parent.elements.length; i++) {
992 if (parent.elements[i].type == "checkbox" && parent.elements[i].id.substring(0,(9 + id_this.length)) == 'select_' + id_this + '._') {
993 if(document.getElementById('select_all_' + id_this).checked == true) {
994 parent.elements[i].checked = true;
995 parent.elements[i].disabled = true;
996 var temp = '`' + id_this.substring(owner.length +1) + '`.*';
999 parent.elements[i].checked = false;
1000 parent.elements[i].disabled = false;
1004 if(document.getElementById('select_all_' + id_this).checked == true) {
1005 select_field.push('`' + id_this.substring(owner.length +1) + '`.*');
1006 tab = id_this.split(".");
1007 from_array.push(tab[1]);
1010 for (i =0; i < select_field.length; i++) {
1011 if (select_field[i] == ('`' + id_this.substring(owner.length +1) + '`.*')) {
1012 select_field.splice(i,1);
1015 for(k =0 ;k < from_array.length;k++){
1016 if(from_array[k] == id_this){
1017 from_array.splice(k,1);
1025 function Table_onover(id_this,val,buil)
1028 document.getElementById("id_zag_" + id_this).className="tab_zag_2";
1030 document.getElementById("id_zag_" + id_this + "_2").className="tab_zag_2";
1034 document.getElementById("id_zag_" + id_this).className="tab_zag";
1036 document.getElementById("id_zag_" + id_this + "_2").className="tab_zag";
1041 /* This function stores selected column information in select_field[]
1042 * In case column is checked it add else it deletes
1045 function store_column(id_this,owner,col) {
1048 if (document.getElementById('select_' + owner + '.' + id_this + '._' + col).checked == true) {
1049 select_field.push('`' + id_this + '`.`' + col +'`');
1050 from_array.push(id_this);
1053 for(i; i < select_field.length ;i++) {
1054 if (select_field[i] == ('`' + id_this + '`.`' + col +'`')) {
1055 select_field.splice(i,1);
1059 for(k =0 ;k < from_array.length;k++){
1060 if(from_array[k] == id_this){
1061 from_array.splice(k,1);
1069 * This function builds object and adds them to history_array
1070 * first it does a few checks on each object, then makes an object(where,rename,groupby,aggregate,orderby)
1071 * then a new history object is made and finally all these history objects are addded to history_array[]
1081 function add_object() {
1082 var rel = document.getElementById('rel_opt');
1084 var init = history_array.length;
1085 if (rel.value != '--') {
1086 if (document.getElementById('Query').value == "") {
1087 document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
1088 document.getElementById('hint').style.visibility = "visible";
1091 var p = document.getElementById('Query');
1092 var where_obj = new where(rel.value,p.value);//make where object
1093 history_array.push(new history(col_name,where_obj,tab_name,h_tabs[downer + '.' + tab_name],"Where"));
1098 if (document.getElementById('new_name').value !="") {
1099 var rename_obj = new rename(document.getElementById('new_name').value);//make Rename object
1100 history_array.push(new history(col_name,rename_obj,tab_name,h_tabs[downer + '.' + tab_name],"Rename"));
1102 document.getElementById('new_name').value = "" ;
1104 if (document.getElementById('operator').value != '---') {
1105 var aggregate_obj = new aggregate(document.getElementById('operator').value) ;
1106 history_array.push(new history(col_name,aggregate_obj,tab_name,h_tabs[downer + '.' + tab_name],"Aggregate"));
1108 document.getElementById('operator').value = '---';
1109 //make aggregate operator
1111 if (document.getElementById('groupby').checked == true ) {
1112 history_array.push(new history(col_name,'GroupBy',tab_name,h_tabs[downer + '.' +tab_name],"GroupBy"));
1114 document.getElementById('groupby').checked = false;
1117 if (document.getElementById('h_rel_opt').value != '--') {
1118 if (document.getElementById('having').value == "") {
1119 document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
1120 document.getElementById('hint').style.visibility = "visible";
1123 var p = document.getElementById('having');
1124 var where_obj = new having(document.getElementById('h_rel_opt').value,p.value,document.getElementById('h_operator').value);//make where object
1125 history_array.push(new history(col_name,where_obj,tab_name,h_tabs[downer + '.' + tab_name],"Having"));
1127 document.getElementById('h_rel_opt').value = '--';
1128 document.getElementById('h_operator').value = '---';
1129 p.value = ""; //make having
1131 if (document.getElementById('orderby').checked == true) {
1132 history_array.push(new history(col_name,'OrderBy',tab_name,h_tabs[downer + '.' + tab_name],"OrderBy"));
1134 document.getElementById('orderby').checked = false;
1137 document.getElementById('hint').innerHTML = sum + "object created" ;
1138 document.getElementById('hint').style.visibility = "visible";
1139 //output sum new objects created
1140 var existingDiv = document.getElementById('ab');
1141 existingDiv.innerHTML = display(init,history_array.length);