$(function(){$(".jsfeature").show();jQuery.tablesorter.addParser({id:"fancyNumber",is:function(d){return/^[0-9]?[0-9,\.]*\s?(k|M|G|T|%)?$/.test(d)},format:function(d){var i=jQuery.tablesorter.formatFloat(d.replace(PMA_messages.strThousandsSeperator,"").replace(PMA_messages.strDecimalSeperator,".")),f=1;switch(d.charAt(d.length-1)){case "%":f=-2;break;case "k":f=3;break;case "M":f=6;break;case "G":f=9;break;case "T":f=12}return i*Math.pow(10,f)},type:"numeric"});jQuery.tablesorter.addParser({id:"withinSpanNumber",
is:function(d){return/<span class="original"/.test(d)},format:function(d,i,f){return(d=f.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/span>/))&&d.length>=3?d[2]:0},type:"numeric"});jQuery.tablesorter.addWidget({id:"fast-zebra",format:function(d){if(d.config.debug)var i=new Date;$("tr:even",d.tBodies[0]).removeClass(d.config.widgetZebra.css[0]).addClass(d.config.widgetZebra.css[1]);$("tr:odd",d.tBodies[0]).removeClass(d.config.widgetZebra.css[1]).addClass(d.config.widgetZebra.css[0]);
d.config.debug&&$.tablesorter.benchmark("Applying Fast-Zebra widget",i)}});$('a[rel="popupLink"]').click(function(){var d=$(this);$("."+d.attr("href").substr(1)).show().offset({top:d.offset().top+d.height()+5,left:d.offset().left}).addClass("openedPopup");return false});$(document).click(function(d){$(".openedPopup").each(function(){var i=$(this),f=$(this).offset();if(d.pageX<f.left||d.pageY<f.top||d.pageX>f.left+i.outerWidth()||d.pageY>f.top+i.outerHeight())i.hide().removeClass("openedPopup")})})});
$(function(){function d(a,b){D(a,b);s[a.attr("id")]=setTimeout(function(){d(a,b)},$(".refreshRate :selected",a).val()*1E3)}function i(a,b){var c=null,e=null,h=null,l=null;$.ajax({async:false,url:"server_status.php",type:"post",data:{token:window.parent.token,ajax_request:true,chart_data:true,type:b},dataType:"json",success:function(x){c=x}});if(b=="proc"){e=[c.x,c.y_conn-n[a.attr("id")]];h=[c.x,c.y_proc];n[a.attr("id")]=c.y_conn}else if(b=="queries"){e=[c.x,c.y-n[a.attr("id")]];n[a.attr("id")]=c.y}else if(b==
"traffic"){c.y_sent/=1024;c.y_received/=1024;e=[c.x,c.y_sent-n[a.attr("id")]];h=[c.x,c.y_received-t[a.attr("id")]];n[a.attr("id")]=c.y_sent;t[a.attr("id")]=c.y_received}return l=[e,h]}function f(a){var b={grid:{drawBorder:false,shadow:false,background:"rgba(0,0,0,0)"},axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer,tickOptions:{formatString:"%H:%M:%S",showGridline:false}},yaxis:{autoscale:true,label:PMA_messages.strTotalCount,labelRenderer:$.jqplot.CanvasAxisLabelRenderer}},seriesDefaults:{rendererOptions:{smooth:true}},
legend:{show:true,location:"s",xoffset:12,yoffset:12}},c,e=[];if(a=="proc"){c=PMA_messages.strChartConnectionsTitle;e[0]=PMA_messages.strChartConnections;e[1]=PMA_messages.strChartProcesses;b.series=[{label:e[0]},{label:e[1]}]}else if(a=="queries"){c=PMA_messages.strChartIssuedQueriesTitle;e[0]=PMA_messages.strChartIssuedQueries;b.series=[{label:e[0]}]}else if(a=="traffic"){c=PMA_messages.strChartServerTraffic;e[0]=PMA_messages.strChartKBSent;e[1]=PMA_messages.strChartKBReceived;b.series=[{label:e[0]},
{label:e[1]}]}b.title=c;return b}function D(a,b){var c=i(a,b);if(b=="proc"||b=="traffic"){k[a.attr("id")][0].push(c[0]);k[a.attr("id")][1].push(c[1]);g[a.attr("id")].series[0].data=k[a.attr("id")][0];g[a.attr("id")].series[1].data=k[a.attr("id")][1]}else if(b=="queries"){k[a.attr("id")][0].push(c[0]);g[a.attr("id")].series[0].data=k[a.attr("id")][0]}g[a.attr("id")].resetAxesScale();c=(new Date).getTime();var e=$(".dataPointsNumber :selected",a).val(),h=$(".refreshRate :selected",a).val()*1E3;h=c-
h*e;var l=(c-h)/e/1E3;l=e>20?(c-h)/20/1E3:l;g[a.attr("id")].axes.xaxis.max=c;g[a.attr("id")].axes.xaxis.min=h;g[a.attr("id")].axes.xaxis.tickInterval=l+" seconds";g[a.attr("id")].replot()}function o(a,b,c){if(c!=null){if(j[a.attr("id")]!="static"){clearTimeout(chart_activeTimeouts[a.attr("id")+"_chart_cnt"]);chart_activeTimeouts[a.attr("id")+"_chart_cnt"]=null;delete g[a.attr("id")];a.find(".buttonlinks select").get(0).selectedIndex=2}if(!c.chart)c.chart={};c.chart.renderTo=a.attr("id")+"_chart_cnt";
$("#"+a.attr("id")+"_chart_cnt").length==0&&a.find(".tabInnerContent").hide().after('<div class="liveChart" id="'+a.attr("id")+'_chart_cnt"></div>');$(b).html(PMA_messages.strStaticData);a.find(".buttonlinks a.tabRefresh").hide();a.find(".buttonlinks .refreshList").show()}else{clearTimeout(chart_activeTimeouts[a.attr("id")+"_chart_cnt"]);chart_activeTimeouts[a.attr("id")+"_chart_cnt"]=null;a.find(".tabInnerContent").show();a.find("div#"+a.attr("id")+"_chart_cnt").remove();j[a.attr("id")]="static";
delete g[a.attr("id")];a.find(".buttonlinks a.tabRefresh").show();a.find(".buttonlinks select").get(0).selectedIndex=2;a.find(".buttonlinks .refreshList").hide()}clearTimeout(s[a.attr("id")]);n[a.attr("id")]=0;t[a.attr("id")]=0;k[a.attr("id")]=[];k[a.attr("id")][0]=[];k[a.attr("id")][1]=[]}function u(a,b){if(!($(a).data("init-done")&&!b)){$(a).data("init-done",true);switch(a.attr("id")){case "statustabs_traffic":b!=null&&a.find(".tabInnerContent").html(b);PMA_convertFootnotesToTooltips();break;case "statustabs_queries":if(b!=
null){y.destroy();a.find(".tabInnerContent").html(b)}var c=[];$.each(jQuery.parseJSON($("#serverstatusquerieschart span").html()),function(e,h){c.push([e,parseInt(h)])});y=PMA_createProfilingChartJqplot("serverstatusquerieschart",c);z(a.attr("id"));break;case "statustabs_allvars":if(b!=null){a.find(".tabInnerContent").html(b);q()}z(a.attr("id"))}}}function z(a){var b,c;switch(a){case "statustabs_queries":b=$("#serverstatusqueriesdetails");c={sortList:[[3,1]],widgets:["fast-zebra"],headers:{1:{sorter:"fancyNumber"},
2:{sorter:"fancyNumber"}}};break;case "statustabs_allvars":b=$("#serverstatusvariables");c={sortList:[[0,0]],widgets:["fast-zebra"],headers:{1:{sorter:"withinSpanNumber"}}}}b.tablesorter(c);b.find("tr:first th").append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">')}function q(){var a=0,b=A;if(p.length>0)b=p;b.length>1&&$("#linkSuggestions span").each(function(){if($(this).attr("class").indexOf("status_"+b)!=-1){a++;$(this).css("display","")}else $(this).css("display","none")});a>0?
$("#linkSuggestions").css("display",""):$("#linkSuggestions").css("display","none");r=false;$("#serverstatusvariables th.name").each(function(){if((v==null||v.exec($(this).text()))&&(!B||$(this).next().find("span.attention").length>0)&&(p.length==0||$(this).parent().hasClass("s_"+p))){r=!r;$(this).parent().css("display","");if(r){$(this).parent().addClass("odd");$(this).parent().removeClass("even")}else{$(this).parent().addClass("even");$(this).parent().removeClass("odd")}}else $(this).parent().css("display",
"none")})}var v=null,B=false,p="",r=false,A="",y=null,C=false,j={},g={},s={};PMA_createqTip($("table.sortable thead th"),PMA_messages.strSortHint);$.ajaxSetup({cache:false});$("#serverStatusTabs").tabs({cookie:{name:"pma_serverStatusTabs",expires:1},show:function(a,b){menuResize();$(b.tab.hash).data("init-done")||u($(b.tab.hash),null);if(b.tab.hash=="#statustabs_traffic"&&g.statustabs_traffic!=null)d($("#statustabs_traffic"),"traffic");else b.tab.hash=="#statustabs_queries"&&g.statustabs_queries!=
null&&d($("#statustabs_queries"),"queries");if(b.tab.hash=="#statustabs_charting"&&!C){$("div#statustabs_charting").append('<img class="ajaxIcon" id="loadingMonitorIcon" src="'+pmaThemeImage+'ajax_clock_small.gif" alt="">');setTimeout(function(){loadJavascript(["js/jquery/timepicker.js","js/jquery/jquery.json-2.2.js","js/jquery/jquery.sprintf.js","js/jquery/jquery.sortableTable.js","js/codemirror/lib/codemirror.js","js/codemirror/mode/mysql/mysql.js","js/server_status_monitor.js"])},50);C=true}b.tab.hash==
"#statustabs_advisor"&&$("table#rulesFired").length==0&&setTimeout(function(){$('a[href="#startAnalyzer"]').trigger("click")},25)}});$(".ui-widget-content:not(.ui-tabs):not(.ui-helper-clearfix)").addClass("ui-helper-clearfix");$("div.ui-tabs-panel").each(function(){var a=$(this);j[a.attr("id")]="static";setTimeout(function(){u(a,null)},0.5)});$(".buttonlinks .refreshRate").change(function(){var a=$(this).parents("div.ui-tabs-panel");clearTimeout(s[a.attr("id")]);var b=j[a.attr("id")];if(b=="livequeries")d(a,
"queries");else if(b=="livetraffic")d(a,"traffic");else b=="liveconnections"&&d(a,"proc");a=g[$(this).parents("div.ui-tabs-panel").attr("id")];clearTimeout(chart_activeTimeouts[a.options.chart.renderTo]);a.options.realtime.postRequest&&a.options.realtime.postRequest.abort();a.options.realtime.refreshRate=1E3*parseInt(this.value);a.xAxis[0].setExtremes((new Date).getTime()-server_time_diff-a.options.realtime.numMaxPoints*a.options.realtime.refreshRate,(new Date).getTime()-server_time_diff,true);chart_activeTimeouts[a.options.chart.renderTo]=
setTimeout(a.options.realtime.timeoutCallBack,a.options.realtime.refreshRate)});$(".buttonlinks a.tabRefresh").click(function(){var a=$(this).parents("div.ui-tabs-panel"),b=this;$(this).find("img").show();$.get($(this).attr("href"),{ajax_request:1},function(c){$(b).find("img").hide();u(a,c)});j[a.attr("id")]="data";return false});var n={},t={},k={};$(".buttonlinks a.livetrafficLink").click(function(){var a=$(this).parents("div.ui-tabs-panel"),b=j[a.attr("id")];if(b=="static"||b=="liveconnections"){o(a,
this,f("traffic"));i(a,"traffic");g[a.attr("id")]=$.jqplot(a.attr("id")+"_chart_cnt",[[[0,0]],[[0,0]]],f("traffic"));d(a,"traffic");b=="liveconnections"&&a.find(".buttonlinks a.liveconnectionsLink").html(PMA_messages.strLiveConnChart);j[a.attr("id")]="livetraffic"}else{$(this).html(PMA_messages.strLiveTrafficChart);o(a,this,null)}return false});$(".buttonlinks a.liveconnectionsLink").click(function(){var a=$(this).parents("div.ui-tabs-panel"),b=j[a.attr("id")];if(b=="static"||b=="livetraffic"){o(a,
this,f("proc"));i(a,"proc");g[a.attr("id")]=$.jqplot(a.attr("id")+"_chart_cnt",[[[0,0]],[[0,0]]],f("proc"));d(a,"proc");b=="livetraffic"&&a.find(".buttonlinks a.livetrafficLink").html(PMA_messages.strLiveTrafficChart);j[a.attr("id")]="liveconnections"}else{$(this).html(PMA_messages.strLiveConnChart);o(a,this,null)}return false});$(".buttonlinks a.livequeriesLink").click(function(){var a=$(this).parents("div.ui-tabs-panel");if(j[a.attr("id")]=="static"){o(a,this,f("queries"));i(a,"queries");g[a.attr("id")]=
$.jqplot(a.attr("id")+"_chart_cnt",[[0,0]],f("queries"));d(a,"queries");j[a.attr("id")]="livequeries"}else{$(this).html(PMA_messages.strLiveQueryChart);o(a,this,null)}return false});$("#filterAlert").change(function(){B=this.checked;q()});$("#filterText").keyup(function(){var a=$(this).val().replace(/_/g," ");v=a.length==0?null:RegExp("(^| )"+a,"i");A=a;q()});$("#filterCategory").change(function(){p=$(this).val();q()});$("input#dontFormat").change(function(){$("#serverstatusvariables").hide();$("#serverstatusvariables td.value span.original").toggle(this.checked);
$("#serverstatusvariables td.value span.formatted").toggle(!this.checked);$("#serverstatusvariables").show()});$('a[href="#openAdvisorInstructions"]').click(function(){var a={};a[PMA_messages.strClose]=function(){$(this).dialog("close")};$("#advisorInstructionsDialog").attr("title",PMA_messages.strAdvisorSystem);$("#advisorInstructionsDialog").dialog({width:700,buttons:a})});$('a[href="#startAnalyzer"]').click(function(){var a=$("#statustabs_advisor .tabInnerContent");a.html('<img class="ajaxIcon" src="'+
pmaThemeImage+'ajax_clock_small.gif" alt="">');$.get("server_status.php?"+url_query,{ajax_request:true,advisor:true},function(b){var c,e,h=true;b=$.parseJSON(b);a.html("");if(b.parse.errors.length>0){a.append("<b>Rules file not well formed, following errors were found:</b><br />- ");a.append(b.parse.errors.join("<br/>- "));a.append("<p></p>")}if(b.run.errors.length>0){a.append("<b>Errors occured while executing rule expressions:</b><br />- ");a.append(b.run.errors.join("<br/>- "));a.append("<p></p>")}if(b.run.fired.length>
0){a.append("<p><b>"+PMA_messages.strPerformanceIssues+"</b></p>");a.append('<table class="data" id="rulesFired" border="0"><thead><tr><th>'+PMA_messages.strIssuse+"</th><th>"+PMA_messages.strRecommendation+"</th></tr></thead><tbody></tbody></table>");c=a.find("table#rulesFired");var l;$.each(b.run.fired,function(x,w){l=$.trim($("<div>").html(w.recommendation).text());c.append(e=$('<tr class="linkElem noclick '+(h?"even":"odd")+'"><td>'+w.issue+"</td><td>"+l+" </td></tr>"));h=!h;e.data("rule",w);
e.click(function(){var m=$(this).data("rule");$("div#emptyDialog").dialog({title:PMA_messages.strRuleDetails});$("div#emptyDialog").html("<p><b>"+PMA_messages.strIssuse+":</b><br />"+m.issue+"</p><p><b>"+PMA_messages.strRecommendation+":</b><br />"+m.recommendation+"</p><p><b>"+PMA_messages.strJustification+":</b><br />"+m.justification+"</p><p><b>"+PMA_messages.strFormula+":</b><br />"+m.formula+"</p><p><b>"+PMA_messages.strTest+":</b><br />"+m.test+"</p>");m={};m[PMA_messages.strClose]=function(){$(this).dialog("close")};
$("div#emptyDialog").dialog({width:600,buttons:m})})})}});return false})});function serverResponseError(){var d={};d[PMA_messages.strReloadPage]=function(){window.location.reload()};$("#emptyDialog").dialog({title:PMA_messages.strRefreshFailed});$("#emptyDialog").html(PMA_getImage("s_attention.png")+PMA_messages.strInvalidResponseExplanation);$("#emptyDialog").dialog({buttons:d})};
