initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

View File

@ -0,0 +1,7 @@
var http_request=false,xmldoc,textdoc;
function makeRequest(a,b){http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest;http_request.overrideMimeType&&http_request.overrideMimeType("text/xml")}else if(window.ActiveXObject)try{http_request=new ActiveXObject("Msxml2.XMLHTTP")}catch(d){try{http_request=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}if(!http_request){alert("Giving up :( Cannot create an XMLHTTP instance");return false}http_request.onreadystatechange=alertContents;http_request.open("POST",a,true);http_request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length",b.length);http_request.setRequestHeader("Connection","close");http_request.send(b);return true}
function alertContents(){if(http_request.readyState==1){document.getElementById("layer_action").style.left=document.body.clientWidth+document.body.scrollLeft-85+"px";document.getElementById("layer_action").style.top=document.body.scrollTop+10+"px";document.getElementById("layer_action").style.visibility="visible";document.getElementById("layer_action").innerHTML="Loading..."}if(http_request.readyState==2)document.getElementById("layer_action").innerHTML="Loaded";if(http_request.readyState==3)document.getElementById("layer_action").innerHTML=
"Loading 99%";if(http_request.readyState==4)if(http_request.status==200){textdoc=http_request.responseText;xmldoc=http_request.responseXML;PrintXML()}else alert("There was a problem with the request.")}
function PrintXML(){var a=xmldoc.getElementsByTagName("root").item(0);if(a==null){myWin=window.open("","Report","width=400, height=250, resizable=1, scrollbars=1, status=1");var b=myWin.document;b.write(textdoc);b.close()}else{a.getAttribute("act")=="save_pos"&&PMA_ajaxShowMessage(a.getAttribute("return"));if(a.getAttribute("act")=="relation_upd"){PMA_ajaxShowMessage(a.getAttribute("return"));if(a.getAttribute("b")=="1"){contr.splice(a.getAttribute("K"),1);Re_load()}}if(a.getAttribute("act")=="relation_new"){PMA_ajaxShowMessage(a.getAttribute("return"));
if(a.getAttribute("b")=="1"){b=contr.length;var d=a.getAttribute("DB1")+"."+a.getAttribute("T1"),e=a.getAttribute("F1"),c=a.getAttribute("DB2")+"."+a.getAttribute("T2");a=a.getAttribute("F2");contr[b]=[];contr[b][""]=[];contr[b][""][c]=[];contr[b][""][c][a]=[];contr[b][""][c][a][0]=d;contr[b][""][c][a][1]=e;Re_load()}}}};

View File

@ -0,0 +1,33 @@
var history_array=[],select_field=[],g_index;function panel(a){a||$(".toggle_container").hide();$("h2.tiger").click(function(){$(this).toggleClass("active").next().slideToggle("slow")})}
function display(a,b){var c,d,e,h;for(d=a;d<b;d++){h=history_array[d];e=history_array[d].get_tab();for(c=0;c<d;c++)if(e>history_array[c].get_tab()){for(e=d;e>c;e--)history_array[e]=history_array[e-1];history_array[c]=h;break}}c="";for(d=0;d<history_array.length;d++){e=history_array[d].get_tab();c+='<h2 class="tiger"><a href="#">'+e+"</a></h2>";for(c+='<div class="toggle_container">\n';history_array[d].get_tab()==e;){c+='<div class="block"> <table width ="250">';c+="<thead><tr><td>";c+=history_array[d].get_and_or()?
'<img src="'+pmaThemeImage+'pmd/or_icon.png" onclick="and_or('+d+')" title="OR"/></td>':'<img src="'+pmaThemeImage+'pmd/and_icon.png" onclick="and_or('+d+')" title="AND"/></td>';c+='<td style="padding-left: 5px;" align="right">'+PMA_getImage("b_sbrowse.png","column name")+'</td><td width="175" style="padding-left: 5px">'+history_array[d].get_column_name();c+=history_array[d].get_type()=="GroupBy"||history_array[d].get_type()=="OrderBy"?'</td><td align="center">'+PMA_getImage("b_info.png",detail(d))+
'<td title="'+detail(d)+'">'+history_array[d].get_type()+"</td></td><td onmouseover=\"this.className='history_table';\" onmouseout=\"this.className='history_table2'\" onclick=history_delete("+d+")>"+PMA_getImage("b_drop.png","Delete")+"</td></tr></thead>":'</td><td align="center">'+PMA_getImage("b_info.png",detail(d))+'</td><td title="'+detail(d)+'">'+history_array[d].get_type()+"</td><td <td onmouseover=\"this.className='history_table';\" onmouseout=\"this.className='history_table2'\" onclick=history_edit("+
d+")>"+PMA_getImage("b_edit.png",PMA_messages.strEdit)+"</td><td onmouseover=\"this.className='history_table';\" onmouseout=\"this.className='history_table2'\" onclick=history_delete("+d+')><img src="themes/original/img/b_drop.png" title="Delete"></td></tr></thead>';d++;if(d>=history_array.length)break;c+="</table></div><br/>"}d--;c+="</div><br/>"}return c}
function and_or(a){history_array[a].get_and_or()?history_array[a].set_and_or(0):history_array[a].set_and_or(1);document.getElementById("ab").innerHTML=display(0,0);panel(1)}
function detail(a){var b=history_array[a].get_type(),c;if(b=="Where")c="Where "+history_array[a].get_column_name()+history_array[a].get_obj().getrelation_operator()+history_array[a].get_obj().getquery();if(b=="Rename")c="Rename "+history_array[a].get_column_name()+" To "+history_array[a].get_obj().getrename_to();if(b=="Aggregate")c="Select "+history_array[a].get_obj().get_operator()+"( "+history_array[a].get_column_name()+" )";if(b=="GroupBy")c="GroupBy "+history_array[a].get_column_name();if(b==
"OrderBy")c="OrderBy "+history_array[a].get_column_name();if(b=="Having"){c="Having ";if(history_array[a].get_obj().get_operator()!="None"){c+=history_array[a].get_obj().get_operator()+"( "+history_array[a].get_column_name()+" )";c+=history_array[a].get_obj().getrelation_operator()+history_array[a].get_obj().getquery()}else c="Having "+history_array[a].get_column_name()+history_array[a].get_obj().getrelation_operator()+history_array[a].get_obj().getquery()}return c}
function history_delete(a){for(var b=0;b<from_array.length;b++)if(from_array[b]==history_array[a].get_tab()){from_array.splice(b,1);break}history_array.splice(a,1);document.getElementById("ab").innerHTML=display(0,0);panel(1)}
function history_edit(a){g_index=a;var b=history_array[a].get_type();if(b=="Where"){document.getElementById("eQuery").value=history_array[a].get_obj().getquery();document.getElementById("erel_opt").value=history_array[a].get_obj().getrelation_operator();document.getElementById("query_where").style.left="530px";document.getElementById("query_where").style.top="130px";document.getElementById("query_where").style.position="absolute";document.getElementById("query_where").style.zIndex="9";document.getElementById("query_where").style.visibility=
"visible"}if(b=="Having"){document.getElementById("hQuery").value=history_array[a].get_obj().getquery();document.getElementById("hrel_opt").value=history_array[a].get_obj().getrelation_operator();document.getElementById("hoperator").value=history_array[a].get_obj().get_operator();document.getElementById("query_having").style.left="530px";document.getElementById("query_having").style.top="130px";document.getElementById("query_having").style.position="absolute";document.getElementById("query_having").style.zIndex=
"9";document.getElementById("query_having").style.visibility="visible"}if(b=="Rename"){document.getElementById("query_rename_to").style.left="530px";document.getElementById("query_rename_to").style.top="130px";document.getElementById("query_rename_to").style.position="absolute";document.getElementById("query_rename_to").style.zIndex="9";document.getElementById("query_rename_to").style.visibility="visible"}if(b=="Aggregate"){document.getElementById("query_Aggregate").style.left="530px";document.getElementById("query_Aggregate").style.top=
"130px";document.getElementById("query_Aggregate").style.position="absolute";document.getElementById("query_Aggregate").style.zIndex="9";document.getElementById("query_Aggregate").style.visibility="visible"}}
function edit(a){if(a=="Rename"){if(document.getElementById("e_rename").value!=""){history_array[g_index].get_obj().setrename_to(document.getElementById("e_rename").value);document.getElementById("e_rename").value=""}document.getElementById("query_rename_to").style.visibility="hidden"}if(a=="Aggregate"){if(document.getElementById("e_operator").value!="---"){history_array[g_index].get_obj().set_operator(document.getElementById("e_operator").value);document.getElementById("e_operator").value="---"}document.getElementById("query_Aggregate").style.visibility=
"hidden"}if(a=="Where"){if(document.getElementById("erel_opt").value!="--"&&document.getElementById("eQuery").value!=""){history_array[g_index].get_obj().setquery(document.getElementById("eQuery").value);history_array[g_index].get_obj().setrelation_operator(document.getElementById("erel_opt").value)}document.getElementById("query_where").style.visibility="hidden"}if(a=="Having"){if(document.getElementById("hrel_opt").value!="--"&&document.getElementById("hQuery").value!=""){history_array[g_index].get_obj().setquery(document.getElementById("hQuery").value);
history_array[g_index].get_obj().setrelation_operator(document.getElementById("hrel_opt").value);history_array[g_index].get_obj().set_operator(document.getElementById("hoperator").value)}document.getElementById("query_having").style.visibility="hidden"}document.getElementById("ab").innerHTML=display(0,0);panel(1)}
function history(a,b,c,d,e){var h,f,l,g,m,n;this.set_column_name=function(j){g=j};this.get_column_name=function(){return g};this.set_and_or=function(j){h=j};this.get_and_or=function(){return h};this.get_relation=function(){return h};this.set_obj=function(j){f=j};this.get_obj=function(){return f};this.set_tab=function(j){l=j};this.get_tab=function(){return l};this.set_obj_no=function(j){m=j};this.get_obj_no=function(){return m};this.set_type=function(j){n=j};this.get_type=function(){return n};this.set_obj_no(d);
this.set_tab(c);this.set_and_or(0);this.set_obj(b);this.set_column_name(a);this.set_type(e)}
var where=function(a,b){var c,d;this.setrelation_operator=function(e){c=e};this.setquery=function(e){d=e};this.getquery=function(){return d};this.getrelation_operator=function(){return c};this.setquery(b);this.setrelation_operator(a)},having=function(a,b,c){var d,e,h;this.set_operator=function(f){h=f};this.setrelation_operator=function(f){d=f};this.setquery=function(f){e=f};this.getquery=function(){return e};this.getrelation_operator=function(){return d};this.get_operator=function(){return h};this.setquery(b);
this.setrelation_operator(a);this.set_operator(c)},rename=function(a){var b;this.setrename_to=function(c){b=c};this.getrename_to=function(){return b};this.setrename_to(a)},aggregate=function(a){var b;this.set_operator=function(c){b=c};this.get_operator=function(){return b};this.set_operator(a)};function unique(a){var b=[],c=0;a:for(;c<a.length;c++){for(var d=0;d<b.length;d++)if(b[d]==a[c])continue a;b[b.length]=a[c]}return b}
function found(a,b){for(var c=0;c<a.length;c++)if(a[c]==b)return 1;return-1}
function build_query(a,b){var c="SELECT ",d;for(i=0;i<select_field.length;i++){d=check_aggregate(select_field[i]);if(d!=""){c+=d;d=check_rename(select_field[i]);c+=d+","}else{d=check_rename(select_field[i]);c+=select_field[i]+d+","}}c=c.substring(0,c.length-1);c+=" FROM "+query_from();if(query_where()!=""){c+="\n WHERE";c+=query_where()}if(query_groupby()!="")c+="\nGROUP BY "+query_groupby();if(query_having()!="")c+="\nHAVING "+query_having();if(query_orderby()!="")c+="\nORDER BY "+query_orderby();
d=document.getElementById("box");document.getElementById("filter").style.display="block";document.getElementById("boxtitle").innerHTML="SELECT";if(b){gradient("box",0);fadein("box")}else d.style.display="block";document.getElementById("textSqlquery").innerHTML=c}
function query_from(){var a,b=[],c=[],d=[],e="",h="",f=[],l=[];l=from_array;var g=0;for(a=0;a<history_array.length;a++)from_array.push(history_array[a].get_tab());b=from_array=unique(from_array);h=a=b.shift();c.push(a);for(a=0;a<2;a++){for(g in contr)for(key in contr[g])for(key2 in contr[g][key]){f=key2.split(".");if(found(c,f[1])>0)for(key3 in contr[g][key][key2]){parts1=contr[g][key][key2][key3][0].split(".");if(found(b,parts1[1])>0){e+="\nLEFT JOIN ";e+="`"+parts1[0]+"`.`"+parts1[1]+"` ON ";e+=
"`"+f[1]+"`.`"+key3+"` = ";e+="`"+parts1[1]+"`.`"+contr[g][key][key2][key3][1]+"` ";d.push(parts1[1])}}}g=0;d=unique(d);c=add_array(d,c);b=remove_array(d,b);d=[];for(g in contr)for(key in contr[g])for(key2 in contr[g][key]){f=key2.split(".");if(found(b,f[1])>0)for(key3 in contr[g][key][key2]){parts1=contr[g][key][key2][key3][0].split(".");if(found(c,parts1[1])>0){e+="\nLEFT JOIN ";e+="`"+f[0]+"`.`"+f[1]+"` ON ";e+="`"+parts1[1]+"`.`"+contr[g][key][key2][key3][1]+"` = ";e+="`"+f[1]+"`.`"+key3+"` ";
d.push(f[1])}}}d=unique(d);c=add_array(d,c);b=remove_array(d,b);d=[]}for(k in b)h+=" , `"+b[k]+"`";e=h+e;from_array=l;return e}function add_array(a,b){for(var c=0;c<a.length;c++)b.push(a[c]);return b}function remove_array(a,b){for(var c=0;c<a.length;c++)for(var d=0;d<b.length;d++)a[c]==b[d]&&b.splice(d,1);return b}
function query_groupby(){var a,b="";for(a=0;a<history_array.length;a++)if(history_array[a].get_type()=="GroupBy")b+=history_array[a].get_column_name()+", ";return b=b.substr(0,b.length-1)}
function query_having(){var a,b="(";for(a=0;a<history_array.length;a++)if(history_array[a].get_type()=="Having")if(history_array[a].get_obj().get_operator()!="None"){b+=history_array[a].get_obj().get_operator()+"("+history_array[a].get_column_name()+" ) "+history_array[a].get_obj().getrelation_operator();b+=" "+history_array[a].get_obj().getquery()+", "}else b+=history_array[a].get_column_name()+" "+history_array[a].get_obj().getrelation_operator()+" "+history_array[a].get_obj().getquery()+", ";return b=
b=="("?"":b.substr(0,b.length-2)+")"}function query_orderby(){var a,b="";for(a=0;a<history_array.length;a++)if(history_array[a].get_type()=="OrderBy")b+=history_array[a].get_column_name()+" , ";return b=b.substr(0,b.length-1)}
function query_where(){var a,b="(",c="(";for(a=0;a<history_array.length;a++)if(history_array[a].get_type()=="Where")if(history_array[a].get_and_or()==0){b+="( "+history_array[a].get_column_name()+" "+history_array[a].get_obj().getrelation_operator()+" "+history_array[a].get_obj().getquery()+")";b+=" AND "}else{c+="( "+history_array[a].get_column_name()+" "+history_array[a].get_obj().getrelation_operator()+" "+history_array[a].get_obj().getquery()+")";c+=" OR "}c=c!="("?c.substring(0,c.length-4)+")":
"";b=b!="("?b.substring(0,b.length-5)+")":"";if(c!="")b=b+" OR "+c+" )";return b}function check_aggregate(a){var b;for(b=0;b<history_array.length;b++)if("`"+history_array[b].get_tab()+"`.`"+history_array[b].get_column_name()+"`"==a&&history_array[b].get_type()=="Aggregate")return history_array[b].get_obj().get_operator()+"("+a+")";return""}
function check_rename(a){var b;for(b=0;b<history_array.length;b++)if("`"+history_array[b].get_tab()+"`.`"+history_array[b].get_column_name()+"`"==a&&history_array[b].get_type()=="Rename")return" AS `"+history_array[b].get_obj().getrename_to()+"`";return""}function gradient(a,b){var c=document.getElementById(a);c.style.opacity=b;c.style.MozOpacity=b;c.style.KhtmlOpacity=b;c.style.filter="alpha(opacity="+b*100+")";c.style.display="block"}
function fadein(a){for(var b=0;b<=1;){setTimeout("gradient('"+a+"',"+b+")",b*1E3+10);b+=0.01}}function closebox(){document.getElementById("box").style.display="none";document.getElementById("filter").style.display="none"};

View File

@ -0,0 +1,5 @@
if(!window.all){document.attachEvent("onreadystatechange",function(){if(document.readyState=="complete"){var d=document.getElementById("canvas"),a=document.createElement(d.outerHTML);d.parentNode.replaceChild(a,d);d=a;d.getContext=function(){if(this.cont)return this.cont;return this.cont=new PMD_2D(this)};d.style.width=d.attributes.width.nodeValue+"px";d.style.height=d.attributes.height.nodeValue+"px"}});var convert_style=function(d){var a=[];a=d.match(/.*\((\d*),(\d*),(\d*),(\d*)\)/);for(d=1;d<=
3;d++)a[d]=(a[d]*1).toString(16).length<2?"0"+(a[d]*1).toString(16):(a[d]*1).toString(16);return["#"+a[1]+a[2]+a[3],1]},PMD_2D=function(d){this.element_=d;this.pmd_arr=[];this.closePath=function(){this.pmd_arr.push({type:"close"})};this.clearRect=function(){this.element_.innerHTML="";this.pmd_arr=[]};this.beginPath=function(){this.pmd_arr=[]};this.moveTo=function(a,c){this.pmd_arr.push({type:"moveTo",x:a,y:c})};this.lineTo=function(a,c){this.pmd_arr.push({type:"lineTo",x:a,y:c})};this.arc=function(a,
c,b,e,f,g){if(!g){g=e;e=f;f=g}this.pmd_arr.push({type:"arc",x:a,y:c,radius:b,xStart:a+Math.cos(e)*b,yStart:c+Math.sin(e)*b,xEnd:a+Math.cos(f)*b,yEnd:c+Math.sin(f)*b})};this.rect=function(a,c,b,e){this.moveTo(a,c);this.lineTo(a+b,c);this.lineTo(a+b,c+e);this.lineTo(a,c+e);this.closePath()};this.fillRect=function(a,c,b,e){this.beginPath();this.moveTo(a,c);this.lineTo(a+b,c);this.lineTo(a+b,c+e);this.lineTo(a,c+e);this.closePath();this.stroke(true)};this.stroke=function(a){var c=[],b=convert_style(a?
this.fillStyle:this.strokeStyle)[0];c.push("<v:shape",' fillcolor="',b,'"',' filled="',Boolean(a),'"',' style="position:absolute;width:10;height:10;"',' coordorigin="0 0" coordsize="10 10"',' stroked="',!a,'"',' strokeweight="',this.lineWidth,'"',' strokecolor="',b,'"',' path="');for(a=0;a<this.pmd_arr.length;a++){b=this.pmd_arr[a];if(b.type=="moveTo"){c.push(" m ");c.push(Math.floor(b.x),",",Math.floor(b.y))}else if(b.type=="lineTo"){c.push(" l ");c.push(Math.floor(b.x),",",Math.floor(b.y))}else if(b.type==
"close")c.push(" x ");else if(b.type=="arc"){c.push(" ar ");c.push(Math.floor(b.x-b.radius),",",Math.floor(b.y-b.radius)," ",Math.floor(b.x+b.radius),",",Math.floor(b.y+b.radius)," ",Math.floor(b.xStart),",",Math.floor(b.yStart)," ",Math.floor(b.xEnd),",",Math.floor(b.yEnd))}}c.push(' ">');c.push("</v:shape>");this.element_.insertAdjacentHTML("beforeEnd",c.join(""));this.pmd_arr=[]}}};

View File

@ -0,0 +1,53 @@
var _change=0,_staying=0,show_relation_lines=true;$(document).ready(function(){$(window).bind("beforeunload",function(){if(_change==1&&_staying==0)return PMA_messages.strLeavingDesigner;else if(_change==1&&_staying==1)_staying=0});$(window).unload(function(){_change=0});window.top.onbeforeunload=function(){if(_change==1&&_staying==0){_staying=1;setTimeout("make_zero();",100);return PMA_messages.strLeavingDesigner}}});function make_zero(){_staying=0}
var dx,dy,dy2,cur_click,sm_x=2,sm_y=2,sm_s=0,sm_add=10,s_left=0,s_right=0,ON_relation=0,ON_grid=0,ON_display_field=0,ON_angular_direct=1,click_field=0,link_relation="",id_hint,canvas_width=0,canvas_height=0,osn_tab_width=0,osn_tab_height=0,height_field=7,Glob_X,Glob_Y,timeoutID,layer_menu_cur_click=0,step=10,old_class,from_array=[],downer;document.onmousedown=MouseDown;document.onmouseup=MouseUp;document.onmousemove=MouseMove;
var isIE=document.all&&!window.opera,isNN=!document.all&&document.getElementById,isN4=document.layers;if(isIE){window.onscroll=General_scroll;document.onselectstart=function(){return false}}
function MouseDown(a){var b,c;if(cur_click!=null){b=isIE?event.clientX+document.body.scrollLeft:a.pageX;c=isIE?event.clientY+document.body.scrollTop:a.pageY;dx=b-parseInt(cur_click.style.left);dy=c-parseInt(cur_click.style.top);document.getElementById("canvas").style.display="none";cur_click.style.zIndex=2}if(layer_menu_cur_click){b=a.pageX;dx=b-parseInt(document.getElementById("layer_menu").style.width)}}
function MouseMove(a){Glob_X=isIE?event.clientX+document.body.scrollLeft:a.pageX;Glob_Y=isIE?event.clientY+document.body.scrollTop:a.pageY;if(cur_click!=null){_change=1;a=Glob_X-dx;var b=Glob_Y-dy;a=a>0?a:0;b=b>0?b:0;if(ON_grid){a=a%step<step/2?a-a%step:a-a%step+step;b=b%step<step/2?b-b%step:b-b%step+step}cur_click.style.left=a+"px";cur_click.style.top=b+"px"}if(ON_relation||ON_display_field){document.getElementById("pmd_hint").style.left=Glob_X+20+"px";document.getElementById("pmd_hint").style.top=
Glob_Y+20+"px"}if(layer_menu_cur_click)document.getElementById("layer_menu").style.width=(Glob_X-dx>=150?Glob_X-dx:150)+"px"}function MouseUp(){if(cur_click!=null){document.getElementById("canvas").style.display="inline-block";Re_load();cur_click.style.zIndex=1;cur_click=null}layer_menu_cur_click=0}
function Canvas_pos(){canvas_width=document.getElementById("canvas").width=osn_tab_width-3;canvas_height=document.getElementById("canvas").height=osn_tab_height-3;if(isIE){document.getElementById("canvas").style.width=(osn_tab_width-3?osn_tab_width-3:0)+"px";document.getElementById("canvas").style.height=(osn_tab_height-3?osn_tab_height-3:0)+"px"}}
function Osn_tab_pos(){osn_tab_width=parseInt(document.getElementById("osn_tab").style.width);osn_tab_height=parseInt(document.getElementById("osn_tab").style.height)}function Main(){document.getElementById("layer_menu").style.top="-1000px";sm_x+=document.getElementById("osn_tab").offsetLeft;sm_y+=document.getElementById("osn_tab").offsetTop;Osn_tab_pos();Canvas_pos();Small_tab_refresh();Re_load();id_hint=document.getElementById("pmd_hint");isIE&&General_scroll()}
function Rezize_osn_tab(){var a=0,b=0;for(key in j_tabs){var c=parseInt(document.getElementById(key).style.left)+document.getElementById(key).offsetWidth,d=parseInt(document.getElementById(key).style.top)+document.getElementById(key).offsetHeight;a=a<c?c:a;b=b<d?d:b}osn_tab_width=a+50;osn_tab_height=b+50;Canvas_pos();document.getElementById("osn_tab").style.width=osn_tab_width+"px";document.getElementById("osn_tab").style.height=osn_tab_height+"px"}
function Re_load(){Rezize_osn_tab();var a,b,c,d=[];Clear();for(K in contr)for(key in contr[K])for(key2 in contr[K][key])for(key3 in contr[K][key][key2])if(document.getElementById("check_vis_"+key2).checked&&document.getElementById("check_vis_"+contr[K][key][key2][key3][0]).checked){var g=document.getElementById(key2).offsetLeft+1,f=g+document.getElementById(key2).offsetWidth,h=document.getElementById(contr[K][key][key2][key3][0]).offsetLeft,n=h+document.getElementById(contr[K][key][key2][key3][0]).offsetWidth;
d[0]=Math.abs(g-h);d[1]=Math.abs(g-n);d[2]=Math.abs(f-h);d[3]=Math.abs(f-n);a=s_left=s_right=0;for(var j=1;j<4;j++)if(d[a]>d[j])a=j;if(a==1){b=g-sm_s;c=n+sm_s;if(b<c)a=0}if(a==2){b=f+sm_s;c=h-sm_s;if(b>c)a=0}if(a==3){b=f+sm_s;c=n+sm_s;s_right=1}if(a==0){b=g-sm_s;c=h-sm_s;s_left=1}g=0;f=document.getElementById("id_hide_tbody_"+key2);if(f.innerHTML=="v")g=document.getElementById(key2+"."+key3).offsetTop;a=document.getElementById(key2).offsetTop+g+height_field;g=0;f=document.getElementById("id_hide_tbody_"+
contr[K][key][key2][key3][0]);if(f.innerHTML=="v")g=document.getElementById(contr[K][key][key2][key3][0]+"."+contr[K][key][key2][key3][1]).offsetTop;g=document.getElementById(contr[K][key][key2][key3][0]).offsetTop+g+height_field;Line0(b-sm_x,a-sm_y,c-sm_x,g-sm_y,getColorByTarget(contr[K][key][key2][key3][0]+"."+contr[K][key][key2][key3][1]))}}
function Line(a,b,c,d,g){var f=document.getElementById("canvas").getContext("2d");f.strokeStyle=g;f.lineWidth=1;f.beginPath();f.moveTo(a,b);f.lineTo(c,d);f.stroke()}function Line0(a,b,c,d,g){if(show_relation_lines){Circle(a,b,3,3,g);Rect(c-1,d-2,4,4,g);ON_angular_direct?Line2(a,b,c,d,g):Line3(a,b,c,d,g)}}
function Line2(a,b,c,d,g){var f=a,h=c;if(s_right){f+=sm_add;h+=sm_add}else if(s_left){f-=sm_add;h-=sm_add}else if(a<c){f+=sm_add;h-=sm_add}else{f-=sm_add;h+=sm_add}Line(a,b,f,b,g);Line(c,d,h,d,g);Line(f,b,h,d,g)}
function Line3(a,b,c,d,g){var f=a,h=c;if(s_right){if(a<c){f+=c-a+sm_add;h+=sm_add}else{h+=a-c+sm_add;f+=sm_add}Line(a,b,f,b,g);Line(c,d,h,d,g);Line(f,b,h,d,g)}else if(s_left){if(a<c){h-=c-a+sm_add;f-=sm_add}else{f-=a-c+sm_add;h-=sm_add}Line(a,b,f,b,g);Line(c,d,h,d,g);Line(f,b,h,d,g)}else{f=(a+c)/2;Line(a,b,f,b,g);Line(f,d,c,d,g);Line(f,b,f,d,g)}}
function Circle(a,b,c,d,g){var f=document.getElementById("canvas").getContext("2d");f.beginPath();f.moveTo(a,b);f.lineWidth=d;f.strokeStyle=g;f.arc(a,b,c,0,2*Math.PI,true);f.stroke()}function Clear(){document.getElementById("canvas").getContext("2d").clearRect(0,0,canvas_width,canvas_height)}function Rect(a,b,c,d,g){var f=document.getElementById("canvas").getContext("2d");f.fillStyle=g;f.fillRect(a,b,c,d)}
function Save(a){for(key in j_tabs){document.getElementById("t_x_"+key+"_").value=parseInt(document.getElementById(key).style.left);document.getElementById("t_y_"+key+"_").value=parseInt(document.getElementById(key).style.top);document.getElementById("t_v_"+key+"_").value=document.getElementById("id_tbody_"+key).style.display=="none"?0:1;document.getElementById("t_h_"+key+"_").value=document.getElementById("check_vis_"+key).checked?1:0}document.form1.action=a;document.form1.submit()}
function Get_url_pos(){var a="";for(key in j_tabs){a+="&t_x["+key+"]="+parseInt(document.getElementById(key).style.left);a+="&t_y["+key+"]="+parseInt(document.getElementById(key).style.top);a+="&t_v["+key+"]="+(document.getElementById("id_tbody_"+key).style.display=="none"?0:1);a+="&t_h["+key+"]="+(document.getElementById("check_vis_"+key).checked?1:0)}return a}
function Save2(){_change=0;var a="IS_AJAX=1&server="+server+"&db="+db+"&token="+token+"&die_save_pos=1";a+=Get_url_pos();makeRequest("pmd_save_pos.php",a)}function Grid(){if(ON_grid){document.getElementById("grid_button").className="M_butt";ON_grid=0}else{ON_grid=1;document.getElementById("grid_button").className="M_butt_Selected_down"}}
function Angular_direct(){if(ON_angular_direct){ON_angular_direct=0;document.getElementById("angular_direct_button").className="M_butt_Selected_down"}else{ON_angular_direct=1;document.getElementById("angular_direct_button").className="M_butt"}Re_load()}
function Start_relation(){if(!ON_display_field)if(ON_relation){document.getElementById("pmd_hint").innerHTML="";document.getElementById("pmd_hint").style.display="none";document.getElementById("rel_button").className="M_butt";ON_relation=click_field=0}else{document.getElementById("foreign_relation").style.display="";ON_relation=1;document.getElementById("pmd_hint").innerHTML=PMA_messages.strSelectReferencedKey;document.getElementById("pmd_hint").style.display="block";document.getElementById("rel_button").className=
"M_butt_Selected_down"}}
function Click_field(a,b,c){if(ON_relation)if(click_field){Start_relation();if(j_tabs[db+"."+a]!="1"||!c)document.getElementById("foreign_relation").style.display="none";c=Glob_X-(document.getElementById("layer_new_relation").offsetWidth>>1);document.getElementById("layer_new_relation").style.left=c+"px";c=Glob_Y-document.getElementById("layer_new_relation").offsetHeight+40;document.getElementById("layer_new_relation").style.top=c+"px";document.getElementById("layer_new_relation").style.display="block";
link_relation+="&T2="+a+"&F2="+b}else{if(!c){alert(PMA_messages.strPleaseSelectPrimaryOrUniqueKey);return}if(j_tabs[db+"."+a]!="1")document.getElementById("foreign_relation").style.display="none";click_field=1;link_relation="T1="+a+"&F1="+b;document.getElementById("pmd_hint").innerHTML=PMA_messages.strSelectForeignKey}if(ON_display_field){if(display_field[a]==b){old_class="tab_field";delete display_field[a]}else{old_class="tab_field_3";if(display_field[a]){document.getElementById("id_tr_"+a+"."+display_field[a]).className=
"tab_field";delete display_field[a]}display_field[a]=b}ON_display_field=0;document.getElementById("pmd_hint").innerHTML="";document.getElementById("pmd_hint").style.display="none";document.getElementById("display_field_button").className="M_butt";makeRequest("pmd_display_field.php","T="+a+"&F="+b+"&server="+server+"&db="+db+"&token="+token)}}
function New_relation(){document.getElementById("layer_new_relation").style.display="none";link_relation+="&server="+server+"&db="+db+"&token="+token+"&die_save_pos=0";link_relation+="&on_delete="+document.getElementById("on_delete").value+"&on_update="+document.getElementById("on_update").value;link_relation+=Get_url_pos();makeRequest("pmd_relation_new.php",link_relation)}function Start_table_new(){window.location.href="tbl_create.php?server="+server+"&db="+db+"&token="+token}
function Start_tab_upd(a){window.location.href="tbl_structure.php?server="+server+"&db="+db+"&token="+token+"&table="+a}function Small_tab_all(a){if(a.alt=="v"){for(key in j_tabs)document.getElementById("id_hide_tbody_"+key).innerHTML=="v"&&Small_tab(key,0);a.alt=">";a.src=pmaThemeImage+"pmd/rightarrow1.png"}else{for(key in j_tabs)document.getElementById("id_hide_tbody_"+key).innerHTML!="v"&&Small_tab(key,0);a.alt="v";a.src=pmaThemeImage+"pmd/downarrow1.png"}Re_load()}
function Small_tab_invert(){for(key in j_tabs)Small_tab(key,0);Re_load()}function Relation_lines_invert(){show_relation_lines=!show_relation_lines;Re_load()}function Small_tab_refresh(){for(key in j_tabs)if(document.getElementById("id_hide_tbody_"+key).innerHTML!="v"){Small_tab(key,0);Small_tab(key,0)}}
function Small_tab(a,b){var c=document.getElementById("id_tbody_"+a),d=document.getElementById("id_hide_tbody_"+a),g=document.getElementById(a);g.style.width=g.offsetWidth+"px";if(d.innerHTML=="v"){c.style.display="none";d.innerHTML=">"}else{c.style.display="";d.innerHTML="v"}b&&Re_load()}
function Select_tab(a){if(document.getElementById("id_zag_"+a).className!="tab_zag_3")document.getElementById("id_zag_"+a).className="tab_zag_2";else document.getElementById("id_zag_"+a).className="tab_zag";var b=document.getElementById(a);window.scrollTo(parseInt(b.style.left)-300,parseInt(b.style.top)-300);setTimeout(function(){document.getElementById("id_zag_"+a).className="tab_zag"},800)}
function Canvas_click(){var a=0,b=0,c=[],d,g,f,h,n,j,l;Clear();for(K in contr)for(key in contr[K])for(key2 in contr[K][key])for(key3 in contr[K][key][key2])if(document.getElementById("check_vis_"+key2).checked&&document.getElementById("check_vis_"+contr[K][key][key2][key3][0]).checked){var m=document.getElementById(key2).offsetLeft+1,p=m+document.getElementById(key2).offsetWidth,o=document.getElementById(contr[K][key][key2][key3][0]).offsetLeft,q=o+document.getElementById(contr[K][key][key2][key3][0]).offsetWidth;
c[0]=Math.abs(m-o);c[1]=Math.abs(m-q);c[2]=Math.abs(p-o);c[3]=Math.abs(p-q);a=s_left=s_right=0;for(var r=1;r<4;r++)if(c[a]>c[r])a=r;if(a==1){j=m-sm_s;l=q+sm_s;if(j<l)a=0}if(a==2){j=p+sm_s;l=o-sm_s;if(j>l)a=0}if(a==3){j=p+sm_s;l=q+sm_s;s_right=1}if(a==0){j=m-sm_s;l=o-sm_s;s_left=1}a=document.getElementById(key2).offsetTop+document.getElementById(key2+"."+key3).offsetTop+height_field;m=document.getElementById(contr[K][key][key2][key3][0]).offsetTop+document.getElementById(contr[K][key][key2][key3][0]+
"."+contr[K][key][key2][key3][1]).offsetTop+height_field;if(!b&&Glob_X>j-10&&Glob_X<j+10&&Glob_Y>a-7&&Glob_Y<a+7){Line0(j-sm_x,a-sm_y,l-sm_x,m-sm_y,"rgba(255,0,0,1)");b=1;d=contr[K][key][key2][key3][0];g=contr[K][key][key2][key3][1];f=key2;h=key3;n=K}else Line0(j-sm_x,a-sm_y,l-sm_x,m-sm_y,getColorByTarget(contr[K][key][key2][key3][0]+"."+contr[K][key][key2][key3][1]))}if(b){b=Glob_X-(document.getElementById("layer_upd_relation").offsetWidth>>1);document.getElementById("layer_upd_relation").style.left=
b+"px";b=Glob_Y-document.getElementById("layer_upd_relation").offsetHeight-10;document.getElementById("layer_upd_relation").style.top=b+"px";document.getElementById("layer_upd_relation").style.display="block";link_relation="T1="+d+"&F1="+g+"&T2="+f+"&F2="+h+"&K="+n}}
function Upd_relation(){document.getElementById("layer_upd_relation").style.display="none";link_relation+="&server="+server+"&db="+db+"&token="+token+"&die_save_pos=0";link_relation+=Get_url_pos();makeRequest("pmd_relation_upd.php",link_relation)}function VisibleTab(a,b){if(a.checked)document.getElementById(b).style.display="block";else document.getElementById(b).style.display="none";Re_load()}
function Hide_tab_all(a){if(a.alt=="v"){a.alt=">";a.src=pmaThemeImage+"pmd/rightarrow1.png"}else{a.alt="v";a.src=pmaThemeImage+"pmd/downarrow1.png"}var b=document.form1;for(i=0;i<b.elements.length;i++)if(b.elements[i].type=="checkbox"&&b.elements[i].id.substring(0,10)=="check_vis_")if(a.alt=="v"){b.elements[i].checked=true;document.getElementById(b.elements[i].value).style.display="block"}else{b.elements[i].checked=false;document.getElementById(b.elements[i].value).style.display="none"}Re_load()}
function in_array_k(a,b){var c=0;for(u in b)if(a==u){c=1;break}return c}
function No_have_constr(a){var b=[];for(K in contr)for(key in contr[K])for(key2 in contr[K][key])for(key3 in contr[K][key][key2])b[key2]=b[contr[K][key][key2][key3][0]]=1;if(a.alt=="v"){a.alt=">";a.src=pmaThemeImage+"pmd/rightarrow2.png"}else{a.alt="v";a.src=pmaThemeImage+"pmd/downarrow2.png"}var c=document.form1;for(i=0;i<c.elements.length;i++)if(c.elements[i].type=="checkbox"&&c.elements[i].id.substring(0,10)=="check_vis_")if(!in_array_k(c.elements[i].value,b))if(a.alt=="v"){c.elements[i].checked=
true;document.getElementById(c.elements[i].value).style.display="block"}else{c.elements[i].checked=false;document.getElementById(c.elements[i].value).style.display="none"}}function PDF_save(){Save("pmd_pdf.php?server="+server+"&token="+token+"&db="+db)}function General_scroll(){clearTimeout(timeoutID);timeoutID=setTimeout(function(){document.getElementById("top_menu").style.left=document.body.scrollLeft+"px";document.getElementById("top_menu").style.top=document.body.scrollTop+"px"},200)}
function Show_left_menu(a){if(a.alt=="v"){var b=$("#top_menu").offset(),c=$("#top_menu").height();document.getElementById("layer_menu").style.top=b.top+c+"px";document.getElementById("layer_menu").style.left=b.left+"px";document.getElementById("layer_menu").style.display="block";a.alt=">";a.src=pmaThemeImage+"pmd/uparrow2_m.png";isIE&&General_scroll()}else{document.getElementById("layer_menu").style.top="-1000px";document.getElementById("layer_menu").style.display="none";a.alt="v";a.src=pmaThemeImage+
"pmd/downarrow2_m.png"}}function Top_menu_right(a){if(a.alt==">"){var b=10;$("#top_menu").children().each(function(){b+=$(this).outerWidth(true)});var c=parseInt(document.getElementById("top_menu").offsetWidth-b,10);document.getElementById("top_menu").style.paddingLeft=c+"px";a.alt="<";a.src=pmaThemeImage+"pmd/2leftarrow_m.png"}else{document.getElementById("top_menu").style.paddingLeft=0;a.alt=">";a.src=pmaThemeImage+"pmd/2rightarrow_m.png"}}
function Start_display_field(){if(!ON_relation)if(ON_display_field){document.getElementById("pmd_hint").innerHTML="";document.getElementById("pmd_hint").style.display="none";document.getElementById("display_field_button").className="M_butt";ON_display_field=0}else{ON_display_field=1;document.getElementById("pmd_hint").innerHTML=PMA_messages.strChangeDisplay;document.getElementById("pmd_hint").style.display="block";document.getElementById("display_field_button").className="M_butt_Selected_down";if(isIE)document.getElementById("display_field_button").className=
"M_butt_Selected_down_IE"}}var TargetColors=[];function getColorByTarget(a){var b="";for(c in TargetColors)if(TargetColors[c][0]==a){b=TargetColors[c][1];break}if(b.length==0){var c=TargetColors.length+1;b=c%6;var d=(c-b)/6;d%=4;d++;var g=[[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,0,1],[0,1,1]],f=g[b][0];c=g[b][1];b=g[b][2];e=1-(d-1)/6;d=Math.round(f*200*e);f=Math.round(c*200*e);c=Math.round(b*200*e);b="rgba("+d+","+f+","+c+",1)";TargetColors.push([a,b])}return b}
function Click_option(a,b,c){var d=Glob_X-(document.getElementById(a).offsetWidth>>1);document.getElementById(a).style.left=d+"px";document.getElementById(a).style.top=screen.height/4+"px";document.getElementById(a).style.display="block";document.getElementById("option_col_name").innerHTML="<strong>"+PMA_messages.strAddOption+'"'+b+'"</strong>';col_name=b;tab_name=c}function Close_option(){document.getElementById("pmd_optionse").style.display="none"}
function Select_all(a,b){var c=document.form1;downer=b;var d;d=[];for(d=0;d<c.elements.length;d++)if(c.elements[d].type=="checkbox"&&c.elements[d].id.substring(0,9+a.length)=="select_"+a+"._")if(document.getElementById("select_all_"+a).checked==true){c.elements[d].checked=true;c.elements[d].disabled=true;a.substring(b.length+1)}else{c.elements[d].checked=false;c.elements[d].disabled=false}if(document.getElementById("select_all_"+a).checked==true){select_field.push("`"+a.substring(b.length+1)+"`.*");
d=a.split(".");from_array.push(d[1])}else{for(d=0;d<select_field.length;d++)select_field[d]=="`"+a.substring(b.length+1)+"`.*"&&select_field.splice(d,1);for(k=0;k<from_array.length;k++)if(from_array[k]==a){from_array.splice(k,1);break}}Re_load()}
function Table_onover(a,b,c){if(b){document.getElementById("id_zag_"+a).className="tab_zag";if(c)document.getElementById("id_zag_"+a+"_2").className="tab_zag"}else{document.getElementById("id_zag_"+a).className="tab_zag_2";if(c)document.getElementById("id_zag_"+a+"_2").className="tab_zag_2"}}
function store_column(a,b,c){if(document.getElementById("select_"+b+"."+a+"._"+c).checked==true){select_field.push("`"+a+"`.`"+c+"`");from_array.push(a)}else{for(b=0;b<select_field.length;b++)if(select_field[b]=="`"+a+"`.`"+c+"`"){select_field.splice(b,1);break}for(c=0;c<from_array.length;c++)if(from_array[c]==a){from_array.splice(c,1);break}}}
function add_object(){var a=document.getElementById("rel_opt"),b=0,c=history_array.length;if(a.value!="--"){if(document.getElementById("Query").value==""){document.getElementById("pmd_hint").innerHTML="value/subQuery is empty";document.getElementById("pmd_hint").style.display="block";return}var d=document.getElementById("Query"),g=new where(a.value,d.value);history_array.push(new history(col_name,g,tab_name,h_tabs[downer+"."+tab_name],"Where"));b+=1;a.value="--";d.value=""}if(document.getElementById("new_name").value!=
""){a=new rename(document.getElementById("new_name").value);history_array.push(new history(col_name,a,tab_name,h_tabs[downer+"."+tab_name],"Rename"));b+=1;document.getElementById("new_name").value=""}if(document.getElementById("operator").value!="---"){a=new aggregate(document.getElementById("operator").value);history_array.push(new history(col_name,a,tab_name,h_tabs[downer+"."+tab_name],"Aggregate"));b+=1;document.getElementById("operator").value="---"}if(document.getElementById("groupby").checked==
true){history_array.push(new history(col_name,"GroupBy",tab_name,h_tabs[downer+"."+tab_name],"GroupBy"));b+=1;document.getElementById("groupby").checked=false}if(document.getElementById("h_rel_opt").value!="--"){if(document.getElementById("having").value==""){document.getElementById("pmd_hint").innerHTML="value/subQuery is empty";document.getElementById("pmd_hint").style.display="block";return}d=document.getElementById("having");g=new having(document.getElementById("h_rel_opt").value,d.value,document.getElementById("h_operator").value);
history_array.push(new history(col_name,g,tab_name,h_tabs[downer+"."+tab_name],"Having"));b+=1;document.getElementById("h_rel_opt").value="--";document.getElementById("h_operator").value="---";d.value=""}if(document.getElementById("orderby").checked==true){history_array.push(new history(col_name,"OrderBy",tab_name,h_tabs[downer+"."+tab_name],"OrderBy"));b+=1;document.getElementById("orderby").checked=false}document.getElementById("pmd_hint").innerHTML=b+"object created";document.getElementById("pmd_hint").style.display=
"block";document.getElementById("ab").innerHTML=display(c,history_array.length);Close_option();panel(0)};