From e08ce9450bc99da18f4d74333a7dcd35aa33618d Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Thu, 18 Aug 2011 14:59:15 +0200 Subject: [PATCH] Faster zebra widget for tablesorter, reduces processing time of status variables table from ~200ms to ~100ms --- js/server_status.js | 23 ++++++++++++++++++++--- js/server_status_monitor.js | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/js/server_status.js b/js/server_status.js index 1d892e20e4..dcf59d852a 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -43,7 +43,24 @@ $(function() { }, type: "numeric" }); - + // faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check + jQuery.tablesorter.addWidget({ + id: "fast-zebra", + format: function (table) { + if (table.config.debug) { + var time = new Date(); + } + $("tr:even", table.tBodies[0]) + .removeClass(table.config.widgetZebra.css[0]) + .addClass(table.config.widgetZebra.css[1]); + $("tr:odd", table.tBodies[0]) + .removeClass(table.config.widgetZebra.css[1]) + .addClass(table.config.widgetZebra.css[0]); + if (table.config.debug) { + $.tablesorter.benchmark("Applying Fast-Zebra widget", time); + } + } + }); // Popup behaviour $('a[rel="popupLink"]').click( function() { @@ -474,7 +491,7 @@ $(function() { case 'statustabs_queries': $('#serverstatusqueriesdetails').tablesorter({ sortList: [[3, 1]], - widgets: ['zebra'], + widgets: ['fast-zebra'], headers: { 1: { sorter: 'fancyNumber' }, 2: { sorter: 'fancyNumber' } @@ -489,7 +506,7 @@ $(function() { case 'statustabs_allvars': $('#serverstatusvariables').tablesorter({ sortList: [[0, 0]], - widgets: ['zebra'], + widgets: ['fast-zebra'], headers: { 1: { sorter: 'fancyNumber' } } diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index 7ac2498810..fa0f28eb77 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -1680,7 +1680,7 @@ $(function() { $('div#logTable table').tablesorter({ sortList: [[cols.length - 1, 1]], - widgets: ['zebra'] + widgets: ['fast-zebra'] }); $('div#logTable table thead th')