From 207bfd47e30d812126751440dc5ff8d9cb46fb2b Mon Sep 17 00:00:00 2001 From: Tyron Madlener Date: Thu, 2 Jun 2011 15:22:28 +0200 Subject: [PATCH] - Fix: Hide refresh button only for current tab - Fix: Tablesorter sorts thousands-seperated values correctly --- js/messages.php | 4 ++++ js/server_status.js | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/js/messages.php b/js/messages.php index 7ffab5fe1b..f2485969b0 100644 --- a/js/messages.php +++ b/js/messages.php @@ -64,6 +64,10 @@ $js_messages['strStaticData'] = __('Static data'); $js_messages['strTotal'] = __('Total'); /* l10n: Other, small valued, queries */ $js_messages['strOther'] = __('Other'); +/* l10n: Thousands separator */ +$js_messages['strThousandsSeperator'] = __(','); +/* l10n: Decimal separator */ +$js_messages['strDecimalSeperator'] = __('.'); /* For inline query editing */ $js_messages['strGo'] = __('Go'); diff --git a/js/server_status.js b/js/server_status.js index 293a6cb848..f052ef5188 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -1,3 +1,26 @@ +$(function() { + jQuery.tablesorter.addParser({ + id: "fancyNumber", + is: function(s) { + return /^[0-9]?[0-9,\.]*\s?(k|M|G|T)?$/.test(s); + }, + format: function(s) { + var num = jQuery.tablesorter.formatFloat( s.replace(PMA_messages['strThousandsSeperator'],'').replace(PMA_messages['strDecimalSeperator'],'.') ); + var factor = 1; + switch (s.charAt(s.length-1)) { + case '%': factor = 0.01; break; + // Todo: Please complete this list + case 'k': factor = 1000; break; + case 'M': factor = 1000*1000; break; + case 'G': factor = 1000*1000*1000; break; + case 'T': factor = 1000*1000*1000*1000; break; + } + return num*factor; + }, + type: "numeric" + }); +}); + $(function() { // Filters for status variables var textFilter=null; @@ -110,7 +133,7 @@ $(function() { tabStatus[tab.attr('id')]='realtime'; initChart(settings); $(this).html(PMA_messages['strStaticData']); - $('.statuslinks a:nth-child(1)').hide(); + tab.find('.statuslinks a:nth-child(1)').hide(); } else { clearTimeout(activeTimeouts[tab.attr('id')+"_chart_cnt"]); activeTimeouts[tab.attr('id')+"_chart_cnt"]=null; @@ -118,7 +141,7 @@ $(function() { tab.find('div#'+tab.attr('id')+'_chart_cnt').remove(); tabStatus[tab.attr('id')]='data'; $(this).html(PMA_messages['strRealtimeChart']); - $('.statuslinks a:nth-child(1)').show(); + tab.find('.statuslinks a:nth-child(1)').show(); } return false; }); @@ -182,7 +205,11 @@ $(function() { case 'statustabs_queries': $('#serverstatusqueriesdetails').tablesorter({ sortList: [[3,1]], - widgets: ['zebra'] + widgets: ['zebra'], + headers: { + 1: { sorter: 'fancyNumber' }, + 2: { sorter: 'fancyNumber' } + } }); $('#serverstatusqueriesdetails tr:first th') @@ -193,7 +220,10 @@ $(function() { case 'statustabs_allvars': $('#serverstatusvariables').tablesorter({ sortList: [[0,0]], - widgets: ['zebra'] + widgets: ['zebra'], + headers: { + 1: { sorter: 'fancyNumber' } + } }); $('#serverstatusvariables tr:first th') @@ -250,7 +280,7 @@ $(function() { var settings = { chart: { defaultSeriesType: 'spline', - marginRight: 10, + marginRight: 10 }, credits: { enabled:false