$(function(){function F(){if(window.localStorage){if(window.localStorage.monitorCharts)e.charts=$.parseJSON(window.localStorage.monitorCharts);if(window.localStorage.monitorSettings)l=$.parseJSON(window.localStorage.monitorSettings);$('a[href="#clearMonitorConfig"]').toggle(e.charts!=null);if(e.charts!=null&&G!=window.localStorage.monitorVersion){$("div#emptyDialog").attr("title",PMA_messages.strIncompatibleMonitorConfig);$("div#emptyDialog").html(PMA_messages.strIncompatibleMonitorConfigDescription);
var a={};a[PMA_messages.strClose]=function(){$(this).dialog("close")};$("div#emptyDialog").dialog({width:400,buttons:a})}}if(e.charts==null)e.charts=defaultChartGrid;if(l==null)l=P;$('select[name="gridChartRefresh"]').attr("value",l.gridRefresh/1E3);$('select[name="chartColumns"]').attr("value",l.columns);e.gridMaxPoints=l.gridMaxPoints=="auto"?Math.round((l.chartSize.width-40)/12):l.gridMaxPoints;e.xmin=(new Date).getTime()-server_time_diff-e.gridMaxPoints*l.gridRefresh;e.xmax=(new Date).getTime()-
server_time_diff+l.gridRefresh;$("table#chartGrid").html("<tr><td></td><td></td></tr><tr><td></td><td></td></tr>");H={width:$("table#chartGrid td:nth-child(2)").offset().left-$("table#chartGrid td:nth-child(1)").offset().left,height:$("table#chartGrid tr:nth-child(2) td:nth-child(2)").offset().top-$("table#chartGrid tr:nth-child(1) td:nth-child(1)").offset().top};$("table#chartGrid").html("");var b=[];$.each(e.charts,function(c){b.push(c)});b.sort();for(a=0;a<b.length;a++)I(e.charts[b[a]],true);a=
$("table#chartGrid .monitorChart").length;var d=(l.columns-a%l.columns)%l.columns;for(a=0;a<d;a++)$("table#chartGrid tr:last").append("<td></td>");$("table#chartGrid tr td").css("width",y().width+"px");B();C()}function Q(){e.charts&&$.each(e.charts,function(d,c){try{c.chart.destroy()}catch(f){}});try{e.refreshRequest.abort()}catch(a){}try{clearTimeout(e.refreshTimeout)}catch(b){}$("table#chartGrid").html("");e.charts=null;e.chartAI=0;l=null}function D(){var a=null;if(e.charts){a={};$.each(e.charts,
function(b,d){for(var c=0;c<d.nodes.length;c++){a[d.nodes[c].dataPoint]=[];for(var f=0;f<d.chart.series[c].data.length;f++)a[d.nodes[c].dataPoint].push([d.chart.series[c].data[f].x,d.chart.series[c].data[f].y])}})}Q();F();a&&$.each(e.charts,function(b,d){for(var c=0;c<d.nodes.length;c++)a[d.nodes[c].dataPoint]&&d.chart.series[c].setData(a[d.nodes[c].dataPoint])})}function y(){var a=$("div#logTable").innerWidth()/l.columns-(l.columns-1)*H.width;return{width:a,height:0.75*a}}function I(a,b){series=
[];for(var d=0;d<a.nodes.length;d++)series.push(a.nodes[d]);settings={chart:{renderTo:"gridchart"+e.chartAI,width:y().width,height:y().height,marginRight:5,zoomType:"x",events:{selection:function(c){function f(i){var k=Date.parse($('#logAnalyseDialog input[name="dateStart"]').prop("value"))||g,h=Date.parse($('#logAnalyseDialog input[name="dateEnd"]').prop("value"))||j;R({src:i,start:k,end:h,removeVariables:$("input#removeVariables").prop("checked"),limitTypes:$("input#limitTypes").prop("checked")})}
if(q||$("#logAnalyseDialog").length==0)return false;c=c.xAxis[0];var g=c.min,j=c.max;$('#logAnalyseDialog input[name="dateStart"]').attr("value",Highcharts.dateFormat("%Y-%m-%d %H:%M:%S",new Date(g)));$('#logAnalyseDialog input[name="dateEnd"]').attr("value",Highcharts.dateFormat("%Y-%m-%d %H:%M:%S",new Date(j)));c={};c[PMA_messages.strFromSlowLog]=function(){f("slow");$(this).dialog("close")};c[PMA_messages.strFromGeneralLog]=function(){f("general");$(this).dialog("close")};$("#logAnalyseDialog").dialog({width:"auto",
height:"auto",buttons:c});return false}}},xAxis:{min:e.xmin,max:e.xmax},yAxis:{title:{text:""}},tooltip:{formatter:function(){var c="<b>"+Highcharts.dateFormat("%H:%M:%S",this.x)+"</b>";$.each(this.points,function(f,g){c+='<br/><span style="color:'+g.series.color+'">'+g.series.name+":</span> "+(parseInt(g.y)==g.y?g.y:Highcharts.numberFormat(this.y,2))+" "+(g.series.options.unit||"")});return c},shared:true},legend:{enabled:false},series:series,buttons:S,title:{text:a.title}};a.settings&&$.extend(true,
settings,a.settings);if($("#"+settings.chart.renderTo).length==0){d=$("table#chartGrid .monitorChart").length;if(d==0||!(d%l.columns))$("table#chartGrid").append("<tr></tr>");$("table#chartGrid tr:last").append('<td><div class="ui-state-default monitorChart" id="'+settings.chart.renderTo+'"></div></td>')}a.chart=PMA_createChart(settings);a.numPoints=0;if(b!=true){e.charts["c"+e.chartAI]=a;B()}$("table#chartGrid div svg").find("*[zIndex=20], *[zIndex=21], *[zIndex=19]").toggle(q);e.chartAI++}function T(a){var b=
a.options.chart.renderTo;if(b){var d=null,c=null;$.each(e.charts,function(g,j){if(j.chart.options.chart.renderTo==b){d=j;c=g;return false}});if(d!=null){a='<p><b>Chart title: </b> <br/> <input type="text" size="35" name="chartTitle" value="'+d.title+'" />';a+="</p><p><b>Series:</b> </p><ol>";for(var f=0;f<d.nodes.length;f++)a+="<li><i>"+d.nodes[f].dataPoints[0].name+': </i><br/><input type="text" name="chartSerie-'+f+'" value="'+d.nodes[f].name+'" /></li>';dlgBtns={};dlgBtns.Save=function(){e.charts[c].title=
$('div#emptyDialog input[name="chartTitle"]').attr("value");e.charts[c].chart.setTitle({text:e.charts[c].title});$('div#emptyDialog input[name*="chartSerie"]').each(function(){var g=$(this).attr("name").split("-")[1];e.charts[c].nodes[g].name=$(this).attr("value");e.charts[c].chart.series[g].name=$(this).attr("value")});$(this).dialog("close");u()};dlgBtns.Cancel=function(){$(this).dialog("close")};$("div#emptyDialog").attr("title","Edit chart");$("div#emptyDialog").html(a+"</ol>");$("div#emptyDialog").dialog({width:"auto",
height:"auto",buttons:dlgBtns})}}}function U(a){var b=a.options.chart.renderTo;if(b){$.each(e.charts,function(d,c){if(c.chart.options.chart.renderTo==b){delete e.charts[d];return false}});B();setTimeout(function(){a.destroy();$("div#"+b).remove()},10);u()}}function C(){e.refreshRequest=$.post("server_status.php?"+url_query,{ajax_request:true,chart_data:1,type:"chartgrid",requiredData:$.toJSON(e.dataList)},function(a){var b;try{b=$.parseJSON(a)}catch(d){return serverResponseError()}var c,f=0,g;$.each(e.charts,
function(j,i){var k=i.chartID;if(b[k]){for(var h=0;h<i.nodes.length;h++){if(f==0&&h==0){g=r==null?b.x-e.xmax:parseInt(b.x-r.x);e.xmin+=g;e.xmax+=g}i.chart.xAxis[0].setExtremes(e.xmin,e.xmax,false);if(i.nodes[h].transformFn)c=V(i.nodes[h].transformFn,b[k][h],r==null||r[k]==null?null:r[k][h]);else{c=parseFloat(b[k][h][0].value);if(i.nodes[h].display=="differential"){if(r==null||r[k]==null)continue;c-=r[k][h][0].value}if(i.nodes[h].valueDivisor)c/=i.nodes[h].valueDivisor}c!=undefined&&i.chart.series[h].addPoint({x:b.x,
y:c},false,i.numPoints>=e.gridMaxPoints)}f++;e.charts[j].numPoints++;e.redrawCharts&&i.chart.redraw()}});r=b;e.refreshTimeout=setTimeout(C,l.gridRefresh)})}function V(a,b,d){switch(a){case "cpu-linux":if(d==null)break;b=b[0];d=d[0];a=b.busy+b.idle-(d.busy+d.idle);return 100*(a-(b.idle-d.idle))/a;case "qce":if(d==null)break;a=b[0].value-d[0].value;if(b[1].value-d[1].value==0)return 0;return a/(b[1].value-d[1].value+a)*100;case "qcu":if(b[1].value==0)return 0;return 100-b[0].value/b[1].value*100}}function B(){e.dataList=
{};var a=0;$.each(e.charts,function(b,d){e.dataList[a]=[];for(var c=0;c<d.nodes.length;c++)e.dataList[a][c]=d.nodes[c].dataPoints;e.charts[b].chartID=a;a++})}function R(a){function b(f){var g=false,j,i=$("div#logTable input#filterQueryText").val();j=i.length==0?null:RegExp(i,"i");var k=0,h=0,s=0,n,J=$("div#logTable input#noWHEREData").attr("checked"),W=/([^=]+)=(\d+|((\'|"|).*?[^\\])\4((\s+)|$))/gi,X=/([a-z0-9_]+)\(.+?\)/gi,z={},K={},A=false,v,Y=e.logDataCols[e.logDataCols.length-2],Z=e.logDataCols[e.logDataCols.length-
1],E=a.src=="slow",p={};$("div#logTable table tbody tr td:nth-child("+(e.logDataCols.length-1)+")").each(function(){if(f&&$(this).html().match(/^SELECT/i))if(J){n=$(this).text().replace(W,"$1=...$6").trim();n=n.replace(X," $1(...)");if(z[n]){z[n]+=parseInt($(this).next().text());h+=parseInt($(this).next().text());A=true}else{z[n]=parseInt($(this).next().text());K[n]=s;$(this).text(n)}if(E){var m=n,w=$(this).parent().html().match(/<td>(.*?)<\/td>/gi);p[m]||(p[m]=[0,0,0,0]);p[m][0]+=L(w[2].replace(/(<td>|<\/td>)/gi,
""));p[m][1]+=L(w[3].replace(/(<td>|<\/td>)/gi,""));p[m][2]+=parseInt(w[4].replace(/(<td>|<\/td>)/gi,""));p[m][3]+=parseInt(w[5].replace(/(<td>|<\/td>)/gi,""))}}else{v=$(this).parent().data("query");$(this).text(v[Y]);$(this).next().text(v[Z]);if(E){$(this).parent().children("td:nth-child(3)").text(v.query_time);$(this).parent().children("td:nth-child(4)").text(v.lock_time);$(this).parent().children("td:nth-child(5)").text(v.rows_sent);$(this).parent().children("td:nth-child(6)").text(v.rows_examined)}}if(!A&&
j!=null&&!j.exec($(this).text()))A=true;if(A)$(this).parent().css("display","none");else{h+=parseInt($(this).next().text());k++;g=!g;$(this).parent().css("display","");if(g){$(this).parent().addClass("odd");$(this).parent().removeClass("even")}else{$(this).parent().addClass("even");$(this).parent().removeClass("odd")}}A=false;s++});if(f){if(J){var M,x,aa=$("div#logTable table tbody");$.each(K,function(m,w){if(!(z[m]<=1)){x=aa.children("tr:nth-child("+(w+1)+")");M=x.children(":nth-child("+e.logDataCols.length+
")");M.text(z[m]);if(E){x.children("td:nth-child(3)").text(N(p[m][0]));x.children("td:nth-child(4)").text(N(p[m][1]));x.children("td:nth-child(5)").text(p[m][2]);x.children("td:nth-child(6)").text(p[m][3])}}})}$("div#logTable table").trigger("update");setTimeout(function(){$("div#logTable table").trigger("sorton",[[[e.logDataCols.length-1,1]]])},0)}$("div#logTable table tfoot tr").html('<th colspan="'+(e.logDataCols.length-1)+'">'+PMA_messages.strSumRows+" "+k+'<span style="float:right">'+PMA_messages.strTotal+
'</span></th><th align="right">'+h+"</th>")}var d=null;if(!a.removeVariables)a.removeVariables=false;if(!a.limitTypes)a.limitTypes=false;$("#emptyDialog").html(PMA_messages.strAnalysingLogs+' <img class="ajaxIcon" src="'+pmaThemeImage+'ajax_clock_small.gif" alt="">');var c={};c[PMA_messages.strCancelRequest]=function(){d!=null&&d.abort();$(this).dialog("close")};$("#emptyDialog").dialog({width:"auto",height:"auto",buttons:c});d=$.get("server_status.php?"+url_query,{ajax_request:true,log_data:1,type:a.src,
time_start:Math.round(a.start/1E3),time_end:Math.round(a.end/1E3),removeVariables:a.removeVariables,limitTypes:a.limitTypes},function(f){var g;try{g=$.parseJSON(f)}catch(j){return serverResponseError()}if(g.rows.length!=0){e.logDataCols=ba(g);$("#emptyDialog").attr("title",PMA_messages.strLoadingLogs);$("#emptyDialog").html("<p>"+PMA_messages.strLogDataLoaded+"</p>");$.each(g.sum,function(i,k){i=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase();if(i=="Total")i="<b>"+i+"</b>";$("#emptyDialog").append(i+
": "+k+"<br/>")});if(g.numRows>12){$("div#logTable").prepend('<fieldset id="logDataFilter">\t<legend>'+PMA_messages.strFiltersForLogTable+'</legend>\t<div class="formelement">\t\t<label for="filterQueryText">'+PMA_messages.strFilterByWordRegexp+'</label>\t\t<input name="filterQueryText" type="text" id="filterQueryText" style="vertical-align: baseline;" />\t</div>'+(g.numRows>250?' <div class="formelement"><button name="startFilterQueryText" id="startFilterQueryText">'+PMA_messages.strFilter+"</button></div>":
"")+'\t<div class="formelement">       <input type="checkbox" id="noWHEREData" name="noWHEREData" value="1" />        <label for="noWHEREData"> '+PMA_messages.strIgnoreWhereAndGroup+"</label>   </div</fieldset>");$("div#logTable input#noWHEREData").change(function(){b(true)});g.numRows>250?$("div#logTable button#startFilterQueryText").click(b):$("div#logTable input#filterQueryText").keyup(b)}f={};f[PMA_messages.strJumpToTable]=function(){$(this).dialog("close");$(document).scrollTop($("div#logTable").offset().top)}}else{$("#emptyDialog").html("<p>"+
PMA_messages.strNoDataFound+"</p>");f={};f[PMA_messages.strClose]=function(){$(this).dialog("close")}}$("#emptyDialog").dialog("option","buttons",f)})}function L(a){a=a.split(":");return parseInt(a[0]*3600)+parseInt(a[1]*60)+parseInt(a[2])}function N(a){hours=Math.floor(a/3600);a-=hours*3600;minutes=Math.floor(a/60);a-=minutes*60;if(hours<10)hours="0"+hours;if(minutes<10)minutes="0"+minutes;if(a<10)a="0"+a;return hours+":"+minutes+":"+a}function ba(a){var b=a.rows,d=[],c=$('<table border="0" class="sortable"></table>'),
f,g,j;$("#logTable").html(c);for(var i=function(s,n){switch(s){case "user_host":return n.replace(/(\[.*?\])+/g,"")}return n},k=0;k<b.length;k++){if(k==0){$.each(b[0],function(s){d.push(s)});c.append('<thead><tr><th class="nowrap">'+d.join('</th><th class="nowrap">')+"</th></tr></thead>");c.append(f=$("<tbody></tbody>"))}f.append(g=$('<tr class="noclick"></tr>'));for(var h=0;h<d.length;h++){if(h==d.length-2&&b[k][d[h]].match(/^SELECT/i)){g.append(j=$('<td class="linkElem">'+i(d[h],b[k][d[h]])+"</td>"));
j.click(ca)}else g.append("<td>"+i(d[h],b[k][d[h]])+"</td>");g.data("query",b[k])}}c.append('<tfoot><tr><th colspan="'+(d.length-1)+'">'+PMA_messages.strSumRows+" "+a.numRows+'<span style="float:right">'+PMA_messages.strTotal+'</span></th><th align="right">'+a.sum.TOTAL+"</th></tr></tfoot>");if($("#logTable th:last").html()=="#"){$("#logTable th:last").append("&nbsp;"+PMA_getImage("b_docs.png","",{"class":"qroupedQueryInfoIcon"}));a=PMA_messages.strCountColumnExplanation;if(groupInserts)a+="<p>"+
PMA_messages.strMoreCountColumnExplanation+"</p>";$("img.qroupedQueryInfoIcon").qtip({content:a,position:{corner:{target:"bottomMiddle",tooltip:"topRight"}},hide:{delay:1E3}})}$("div#logTable table").tablesorter({sortList:[[d.length-1,1]],widgets:["fast-zebra"]});$("div#logTable table thead th").append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');return d}function ca(){var a=$(this).parent().data("query"),b=a.argument||a.sql_text;b=PMA_SQLPrettyPrint(b);codemirror_editor.setValue(b);
setTimeout(function(){codemirror_editor.refresh()},50);b={};b[PMA_messages.strAnalyzeQuery]=function(){da(a)};b[PMA_messages.strClose]=function(){$("div#queryAnalyzerDialog div.placeHolder").html("");codemirror_editor.setValue("");$(this).dialog("close")};$("div#queryAnalyzerDialog").dialog({width:"auto",height:"auto",resizable:false,buttons:b})}function da(a){a=a.db||"";$("div#queryAnalyzerDialog div.placeHolder").html(PMA_messages.strAnalyzing+' <img class="ajaxIcon" src="'+pmaThemeImage+'ajax_clock_small.gif" alt="">');
$.post("server_status.php?"+url_query,{ajax_request:true,query_analyzer:true,query:codemirror_editor.getValue(),database:a},function(b){b=$.parseJSON(b);var d=0;if(b.error)$("div#queryAnalyzerDialog div.placeHolder").html('<div class="error">'+b.error+"</div>");else{$("div#queryAnalyzerDialog div.placeHolder").html('<table width="100%" border="0"><tr><td class="explain"></td><td class="chart"></td></tr></table>');var c="<b>"+PMA_messages.strExplainOutput+"</b> "+explain_docu;if(b.explain.length>1){c+=
" (";for(var f=0;f<b.explain.length;f++){if(f>0)c+=", ";c+='<a href="#showExplain-'+f+'">'+f+"</a>"}c+=")"}c+="<p></p>";for(f=0;f<b.explain.length;f++){c+='<div class="explain-'+f+'"'+(f>0?'style="display:none;"':"")+">";$.each(b.explain[f],function(k,h){h=h==null?"null":h;if(k=="type"&&h.toLowerCase()=="all")h='<span class="attention">'+h+"</span>";if(k=="Extra")h=h.replace(/(using (temporary|filesort))/gi,'<span class="attention">$1</span>');c+=k+": "+h+"<br />"});c+="</div>"}c+="<p><b>"+PMA_messages.strAffectedRows+
"</b> "+b.affectedRows;$("div#queryAnalyzerDialog div.placeHolder td.explain").append(c);$('div#queryAnalyzerDialog div.placeHolder a[href*="#showExplain"]').click(function(){var k=$(this).attr("href").split("-")[1];$(this).parent().find('div[class*="explain"]').hide();$(this).parent().find('div[class*="explain-'+k+'"]').show()});if(b.profiling){var g=[],j='<table class="queryNums"><thead><tr><th>'+PMA_messages.strStatus+"</th><th>"+PMA_messages.strTime+"</th></tr></thead><tbody>",i;for(f=0;f<b.profiling.length;f++){i=
parseFloat(b.profiling[f].duration);g.push([b.profiling[f].state,i]);d+=i;j+="<tr><td>"+b.profiling[f].state+" </td><td> "+PMA_prettyProfilingNum(i,2)+"</td></tr>"}j+="<tr><td><b>"+PMA_messages.strTotalTime+"</b></td><td>"+PMA_prettyProfilingNum(d,2)+"</td></tr>";j+="</tbody></table>";$("div#queryAnalyzerDialog div.placeHolder td.chart").append("<b>"+PMA_messages.strProfilingResults+" "+profiling_docu+'</b> (<a href="#showNums">'+PMA_messages.strTable+'</a>, <a href="#showChart">'+PMA_messages.strChart+
"</a>)<br/>"+j+' <div id="queryProfiling"></div>');$('div#queryAnalyzerDialog div.placeHolder a[href="#showNums"]').click(function(){$("div#queryAnalyzerDialog div#queryProfiling").hide();$("div#queryAnalyzerDialog table.queryNums").show();return false});$('div#queryAnalyzerDialog div.placeHolder a[href="#showChart"]').click(function(){$("div#queryAnalyzerDialog div#queryProfiling").show();$("div#queryAnalyzerDialog table.queryNums").hide();return false});profilingChart=PMA_createProfilingChart(g,
{chart:{renderTo:"queryProfiling"},plotOptions:{pie:{size:"50%"}}});$("div#queryProfiling").resizable()}}})}function u(){var a={};$.each(e.charts,function(b,d){a[b]={};a[b].nodes=d.nodes;a[b].settings=d.settings;a[b].title=d.title});if(window.localStorage){window.localStorage.monitorCharts=$.toJSON(a);window.localStorage.monitorSettings=$.toJSON(l);window.localStorage.monitorVersion=G}$('a[href="#clearMonitorConfig"]').show()}$("div#statustabs_charting div.tabLinks").show();$("div#statustabs_charting img#loadingMonitorIcon").remove();
if(!codemirror_editor){var O=$("#sqlquery");if(O.length>0&&typeof CodeMirror!="undefined")codemirror_editor=CodeMirror.fromTextArea(O[0],{lineNumbers:true,matchBrackets:true,indentUnit:4,mode:"text/x-mysql"})}$("div#logAnalyseDialog .datetimefield").each(function(){PMA_addDatepicker($(this))});var r=null,o=null,H,G="1.0",e={charts:null,refreshTimeout:null,refreshRequest:null,chartAI:0,redrawCharts:false,dataList:[],gridMaxPoints:20,xmin:-1,xmax:-1},l=null,P={columns:3,chartSize:{width:295,height:250},
gridMaxPoints:"auto",gridRefresh:5E3},q=false,t={qce:{title:PMA_messages.strQueryCacheEfficiency,nodes:[{name:PMA_messages.strQueryCacheEfficiency,dataPoints:[{type:"statusvar",name:"Qcache_hits"},{type:"statusvar",name:"Com_select"}],unit:"%",transformFn:"qce"}]},qcu:{title:PMA_messages.strQueryCacheUsage,nodes:[{name:PMA_messages.strQueryCacheUsed,dataPoints:[{type:"statusvar",name:"Qcache_free_memory"},{type:"servervar",name:"query_cache_size"}],unit:"%",transformFn:"qcu"}]}};switch(server_os){case "WINNT":$.extend(t,
{cpu:{title:PMA_messages.strSystemCPUUsage,nodes:[{name:PMA_messages.strAverageLoad,dataPoints:[{type:"cpu",name:"loadavg"}],unit:"%"}]},memory:{title:PMA_messages.strSystemMemory,nodes:[{name:PMA_messages.strTotalMemory,dataPoints:[{type:"memory",name:"MemTotal"}],valueDivisor:1024,unit:PMA_messages.strMiB},{dataType:"memory",name:PMA_messages.strUsedMemory,dataPoints:[{type:"memory",name:"MemUsed"}],valueDivisor:1024,unit:PMA_messages.strMiB}]},swap:{title:PMA_messages.strSystemSwap,nodes:[{name:PMA_messages.strTotalSwap,
dataPoints:[{type:"memory",name:"SwapTotal"}],valueDivisor:1024,unit:PMA_messages.strMiB},{name:PMA_messages.strUsedSwap,dataPoints:[{type:"memory",name:"SwapUsed"}],valueDivisor:1024,unit:PMA_messages.strMiB}]}});break;case "Linux":$.extend(t,{cpu:{title:PMA_messages.strSystemCPUUsage,nodes:[{name:PMA_messages.strAverageLoad,dataPoints:[{type:"cpu",name:"irrelevant"}],unit:"%",transformFn:"cpu-linux"}]},memory:{title:PMA_messages.strSystemMemory,nodes:[{name:PMA_messages.strUsedMemory,dataPoints:[{type:"memory",
name:"MemUsed"}],valueDivisor:1024,unit:PMA_messages.strMiB},{name:PMA_messages.strCachedMemory,dataPoints:[{type:"memory",name:"Cached"}],valueDivisor:1024,unit:PMA_messages.strMiB},{name:PMA_messages.strBufferedMemory,dataPoints:[{type:"memory",name:"Buffers"}],valueDivisor:1024,unit:PMA_messages.strMiB},{name:PMA_messages.strFreeMemory,dataPoints:[{type:"memory",name:"MemFree"}],valueDivisor:1024,unit:PMA_messages.strMiB}],settings:{chart:{type:"area",animation:false},plotOptions:{area:{stacking:"percent"}}}},
swap:{title:PMA_messages.strSystemSwap,nodes:[{name:PMA_messages.strUsedSwap,dataPoints:[{type:"memory",name:"SwapUsed"}],valueDivisor:1024,unit:PMA_messages.strMiB},{name:PMA_messages.strCachedSwap,dataPoints:[{type:"memory",name:"SwapCached"}],valueDivisor:1024,unit:PMA_messages.strMiB},{name:PMA_messages.strFreeSwap,dataPoints:[{type:"memory",name:"SwapFree"}],valueDivisor:1024,unit:PMA_messages.strMiB}],settings:{chart:{type:"area",animation:false},plotOptions:{area:{stacking:"percent"}}}}})}defaultChartGrid=
{c0:{title:PMA_messages.strQuestions,nodes:[{name:PMA_messages.strQuestions,dataPoints:[{type:"statusvar",name:"Questions"}],display:"differential"}]},c1:{title:PMA_messages.strChartConnectionsTitle,nodes:[{name:PMA_messages.strConnections,dataPoints:[{type:"statusvar",name:"Connections"}],display:"differential"},{name:PMA_messages.strProcesses,dataPoints:[{type:"proc",name:"processes"}]}]},c2:{title:PMA_messages.strTraffic,nodes:[{name:PMA_messages.strBytesSent,dataPoints:[{type:"statusvar",name:"Bytes_sent"}],
display:"differential",valueDivisor:1024,unit:PMA_messages.strKiB},{name:PMA_messages.strBytesReceived,dataPoints:[{type:"statusvar",name:"Bytes_received"}],display:"differential",valueDivisor:1024,unit:PMA_messages.strKiB}]}};if(server_db_isLocal){defaultChartGrid.c3=t.cpu;defaultChartGrid.c4=t.memory;defaultChartGrid.c5=t.swap}var S={cogButton:{symbol:"url("+pmaThemeImage+"s_cog.png)",x:-36,symbolFill:"#B5C9DF",hoverSymbolFill:"#779ABF",_titleKey:"settings",menuName:"gridsettings",menuItems:[{textKey:"editChart",
onclick:function(){T(this)}},{textKey:"removeChart",onclick:function(){U(this)}}]}};Highcharts.setOptions({lang:{settings:PMA_messages.strSettings,removeChart:PMA_messages.strRemoveChart,editChart:PMA_messages.strEditChart}});$('a[href="#rearrangeCharts"], a[href="#endChartEditMode"]').click(function(){q=!q;if($(this).attr("href")=="#endChartEditMode")q=false;$("table#chartGrid div svg").find("*[zIndex=20], *[zIndex=21], *[zIndex=19]").toggle(q);$('a[href="#endChartEditMode"]').toggle(q);if(q){$("#statustabs_charting .popupContent").hide().removeClass("openedPopup");
$("#chartGrid").sortableTable({ignoreRect:{top:8,left:y().width-63,width:54,height:24},events:{drop:function(a,b,d){var c,f,g,j=$(a).children().first().attr("id");if($(b).children().length>0)g=$(b).children().first().attr("id");$.each(e.charts,function(h,s){if(s.chart.options.chart.renderTo==j)c=h;if(g&&s.chart.options.chart.renderTo==g)f=h});if(f){if(c){dragChart=e.charts[c];e.charts[c]=e.charts[f];e.charts[f]=dragChart}else{var i=[];parseInt(f.substr(1));a=d.col+d.row*l.columns;b={};d=0;$.each(e.charts,
function(h){h!=f&&i.push(h)});i.sort();for(var k=0;k<i.length;k++){if(i[k]==a){b["c"+d++]=e.charts[f];a=-1}b["c"+d++]=e.charts[i[k]]}if(a!=-1)b["c"+d++]=e.charts[f];e.charts=b}u()}}}})}else{$("#chartGrid").sortableTable("destroy");u()}return false});$('div#statustabs_charting div.popupContent select[name="chartColumns"]').change(function(){l.columns=parseInt(this.value);var a=y();$("table#chartGrid tr td").css("width",a.width+"px");for(var b,d=$("table#chartGrid tr:first"),c=0;d.length!=0;){b=1;d.find("td").each(function(){if(b>
l.columns){d.next().length==0&&d.after("<tr></tr>");d.next().prepend($(this))}b++});if(d.next().length>0)for(var f=l.columns-d.find("td").length,g=0;g<f;g++){d.append(d.next().find("td:first"));d.nextAll().each(function(){$(this).next().length!=0&&$(this).append($(this).next().find("td:first"))})}d=d.next();c++}$.each(e.charts,function(j,i){i.chart.setSize(a.width,a.height,false)});if(l.gridMaxPoints=="auto")e.gridMaxPoints=Math.round((a.width-40)/12);e.xmin=(new Date).getTime()-server_time_diff-
e.gridMaxPoints*l.gridRefresh;e.xmax=(new Date).getTime()-server_time_diff+l.gridRefresh;q&&$("#chartGrid").sortableTable("refresh");u()});$('div#statustabs_charting div.popupContent select[name="gridChartRefresh"]').change(function(){l.gridRefresh=parseInt(this.value)*1E3;clearTimeout(e.refreshTimeout);e.refreshRequest&&e.refreshRequest.abort();e.xmin=(new Date).getTime()-server_time_diff-e.gridMaxPoints*l.gridRefresh;e.xmax=(new Date).getTime()-server_time_diff+l.gridRefresh;$.each(e.charts,function(a,
b){b.chart.xAxis[0].setExtremes(e.xmin,e.xmax,false)});e.refreshTimeout=setTimeout(C,l.gridRefresh);u()});$('a[href="#addNewChart"]').click(function(){var a={};a[PMA_messages.strAddChart]=function(){if($('input[name="chartType"]:checked').val()=="preset")o=t[$('div#addChartDialog select[name="presetCharts"]').prop("value")];else if(!o||!o.nodes||o.nodes.length==0){alert(PMA_messages.strAddOneSeriesWarning);return}o.title=$('input[name="chartTitle"]').attr("value");I($.extend(true,{},o));o=null;u();
$(this).dialog("close")};a[PMA_messages.strClose]=function(){o=null;$("span#clearSeriesLink").hide();$("#seriesPreview").html("");$(this).dialog("close")};var b=$('div#addChartDialog select[name="presetCharts"]');if(b.html().length==0){$.each(t,function(d,c){b.append('<option value="'+d+'">'+c.title+"</option>")});b.change(function(){$("input#chartPreset").trigger("click");$('input[name="chartTitle"]').attr("value",t[$(this).prop("value")].title)})}$("div#addChartDialog").dialog({width:"auto",height:"auto",
buttons:a});$("div#addChartDialog #seriesPreview").html("<i>"+PMA_messages.strNone+"</i>");return false});$('a[href="#exportMonitorConfig"]').click(function(){var a={};$.each(e.charts,function(c,f){a[c]={};a[c].nodes=f.nodes;a[c].settings=f.settings;a[c].title=f.title});var b={monitorCharts:a,monitorSettings:l},d;$("body").append(d=$('<form method="post" action="file_echo.php?'+url_query+'&filename=1" style="display:none;"></form>'));d.append('<input type="hidden" name="monitorconfig" value="'+encodeURI($.toJSON(b))+
'">');d.submit();d.remove()});$('a[href="#importMonitorConfig"]').click(function(){$("div#emptyDialog").attr("title","Import monitor configuration");$("div#emptyDialog").html('Please select the file you want to import:<br/><form action="file_echo.php?'+url_query+'&import=1" method="post" enctype="multipart/form-data"><input type="file" name="file"> <input type="hidden" name="import" value="1"> </form>');var a={};a[PMA_messages.strImport]=function(){var b;$("body").append(b=$('<iframe id="monitorConfigUpload" style="display:none;"></iframe>'));
var d=b[0].contentWindow.document;d.open();d.close();mew=d;b.load(function(){var c;try{var f=$("body",$("iframe#monitorConfigUpload")[0].contentWindow.document).html();c=$.secureEvalJSON(f.substring(f.indexOf("{"),f.lastIndexOf("}")+1))}catch(g){alert(PMA_messages.strFailedParsingConfig);$("div#emptyDialog").dialog("close");return}if(!c||!c.monitorCharts||!c.monitorCharts)alert(PMA_messages.strFailedParsingConfig);else try{window.localStorage.monitorCharts=$.toJSON(c.monitorCharts);window.localStorage.monitorSettings=
$.toJSON(c.monitorSettings);D()}catch(j){alert(PMA_messages.strFailedBuildingGrid);window.localStorage.removeItem("monitorCharts");window.localStorage.removeItem("monitorSettings");D()}$("div#emptyDialog").dialog("close")});$("body",d).append(b=$("div#emptyDialog").find("form"));b.submit();$("div#emptyDialog").append('<img class="ajaxIcon" src="'+pmaThemeImage+'ajax_clock_small.gif" alt="">')};a[PMA_messages.strCancel]=function(){$(this).dialog("close")};$("div#emptyDialog").dialog({width:"auto",
height:"auto",buttons:a})});$('a[href="#clearMonitorConfig"]').click(function(){window.localStorage.removeItem("monitorCharts");window.localStorage.removeItem("monitorSettings");window.localStorage.removeItem("monitorVersion");$(this).hide();D()});$('a[href="#pauseCharts"]').click(function(){e.redrawCharts=!e.redrawCharts;if(e.redrawCharts){$(this).html(PMA_getImage("pause.png")+" "+PMA_messages.strPauseMonitor);if(!e.charts){F();$('a[href="#settingsPopup"]').show()}}else $(this).html(PMA_getImage("play.png")+
" "+PMA_messages.strResumeMonitor);return false});$('a[href="#monitorInstructionsDialog"]').click(function(){var a=$("div#monitorInstructionsDialog");a.dialog({width:595,height:"auto"}).find("img.ajaxIcon").show();var b=function(d){vars={ajax_request:true,logging_vars:true};d&&$.extend(vars,d);$.get("server_status.php?"+url_query,vars,function(c){c=$.parseJSON(c);var f=PMA_getImage("s_success.png"),g="",j="";if(c.general_log=="ON")g=c.slow_query_log=="ON"?PMA_messages.strBothLogOn:PMA_messages.strGenLogOn;
if(g.length==0&&c.slow_query_log=="ON")g=PMA_messages.strSlowLogOn;if(g.length==0){f=PMA_getImage("s_error.png");g=PMA_messages.strBothLogOff}j="<b>"+PMA_messages.strCurrentSettings+'</b><br><div class="smallIndent">';j+=f+g+"<br />";j+=c.log_output!="TABLE"?PMA_getImage("s_error.png")+" "+PMA_messages.strLogOutNotTable+"<br />":PMA_getImage("s_success.png")+" "+PMA_messages.strLogOutIsTable+"<br />";if(c.slow_query_log=="ON"){if(c.long_query_time>2)j+=PMA_getImage("s_attention.png")+" "+$.sprintf(PMA_messages.strSmallerLongQueryTimeAdvice,
c.long_query_time)+"<br />";if(c.long_query_time<2)j+=PMA_getImage("s_success.png")+" "+$.sprintf(PMA_messages.strLongQueryTimeSet,c.long_query_time)+"<br />"}j+="</div>";if(is_superuser){j+="<p></p><b>"+PMA_messages.strChangeSettings+"</b>";j+='<div class="smallIndent">';j+=PMA_messages.strSettingsAppliedGlobal+"<br/>";f="TABLE";if(c.log_output=="TABLE")f="FILE";j+='- <a class="set" href="#log_output-'+f+'">'+$.sprintf(PMA_messages.strSetLogOutput,f)+" </a><br />";j+=c.general_log!="ON"?'- <a class="set" href="#general_log-ON">'+
$.sprintf(PMA_messages.strEnableVar,"general_log")+" </a><br />":'- <a class="set" href="#general_log-OFF">'+$.sprintf(PMA_messages.strDisableVar,"general_log")+" </a><br />";j+=c.slow_query_log!="ON"?'- <a class="set" href="#slow_query_log-ON">'+$.sprintf(PMA_messages.strEnableVar,"slow_query_log")+" </a><br />":'- <a class="set" href="#slow_query_log-OFF">'+$.sprintf(PMA_messages.strDisableVar,"slow_query_log")+" </a><br />";f=5;if(c.long_query_time>2)f=1;j+='- <a class="set" href="#long_query_time-'+
f+'">'+$.sprintf(PMA_messages.setSetLongQueryTime,f)+" </a><br />"}else j+=PMA_messages.strNoSuperUser+"<br/>";j+="</div>";a.find("div.monitorUse").toggle(c.log_output=="TABLE"&&(c.slow_query_log=="ON"||c.general_log=="ON"));a.find("div.ajaxContent").html(j);a.find("img.ajaxIcon").hide();a.find("a.set").click(function(){var i=$(this).attr("href").split("-");b({varName:i[0].substr(1),varValue:i[1]});a.find("img.ajaxIcon").show()})})};b();return false});$('input[name="chartType"]').change(function(){$("#chartVariableSettings").toggle(this.checked&&
this.value=="variable");var a=$('input[name="chartTitle"]').attr("value");if(a==PMA_messages.strChartTitle||a==$('label[for="'+$('input[name="chartTitle"]').data("lastRadio")+'"]').text())$('input[name="chartTitle"]').data("lastRadio",$(this).attr("id")).attr("value",$('label[for="'+$(this).attr("id")+'"]').text())});$('input[name="useDivisor"]').change(function(){$("span.divisorInput").toggle(this.checked)});$('input[name="useUnit"]').change(function(){$("span.unitInput").toggle(this.checked)});
$('select[name="varChartList"]').change(function(){this.selectedIndex!=0&&$("#variableInput").attr("value",this.value)});$('a[href="#kibDivisor"]').click(function(){$('input[name="valueDivisor"]').attr("value",1024);$('input[name="valueUnit"]').attr("value",PMA_messages.strKiB);$("span.unitInput").toggle(true);$('input[name="useUnit"]').prop("checked",true);return false});$('a[href="#mibDivisor"]').click(function(){$('input[name="valueDivisor"]').attr("value",1048576);$('input[name="valueUnit"]').attr("value",
PMA_messages.strMiB);$("span.unitInput").toggle(true);$('input[name="useUnit"]').prop("checked",true);return false});$('a[href="#submitClearSeries"]').click(function(){$("#seriesPreview").html("<i>"+PMA_messages.strNone+"</i>");o=null;$("span#clearSeriesLink").hide()});$('a[href="#submitAddSeries"]').click(function(){if($("input#variableInput").attr("value").length==0)return false;if(o==null){$("#seriesPreview").html("");o={title:$('input[name="chartTitle"]').attr("value"),nodes:[]}}var a={dataPoints:[{type:"statusvar",
name:$("input#variableInput").attr("value")}],name:$("input#variableInput").attr("value"),display:$('input[name="differentialValue"]').attr("checked")?"differential":""};if(a.dataPoint=="Processes")a.dataType="proc";if($('input[name="useDivisor"]').attr("checked"))a.valueDivisor=parseInt($('input[name="valueDivisor"]').attr("value"));if($('input[name="useUnit"]').attr("checked"))a.unit=$('input[name="valueUnit"]').attr("value");var b=a.display=="differential"?", "+PMA_messages.strDifferential:"";
b+=a.valueDivisor?", "+$.sprintf(PMA_messages.strDividedBy,a.valueDivisor):"";b+=a.unit?", "+PMA_messages.strUnit+": "+a.unit:"";$("#seriesPreview").append("- "+a.name+b+"<br>");o.nodes.push(a);$("input#variableInput").attr("value","");$('input[name="differentialValue"]').attr("checked",true);$('input[name="useDivisor"]').attr("checked",false);$('input[name="useUnit"]').attr("checked",false);$('input[name="useDivisor"]').trigger("change");$('input[name="useUnit"]').trigger("change");$('select[name="varChartList"]').get(0).selectedIndex=
0;$("span#clearSeriesLink").show();return false});$("input#variableInput").autocomplete({source:variableNames})});$(function(){$('a[href="#pauseCharts"]').trigger("click")});
