From d22e932ef72dca3fd6b349434147083451ac2e31 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 26 Nov 2009 11:01:21 +0000 Subject: [PATCH] - Optimize Web UI to use less CPU * Do not refresh filtered torrents since they are not visible * Do not refresh torrent name in list since it connot change - Fixed unitialized torrent status when it was added to the list (it did not cause any issue but it was not optimal) --- src/webui/scripts/client.js | 2 +- src/webui/scripts/dynamicTable.js | 34 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/webui/scripts/client.js b/src/webui/scripts/client.js index 682944820..cc164033a 100644 --- a/src/webui/scripts/client.js +++ b/src/webui/scripts/client.js @@ -135,7 +135,7 @@ window.addEvent('domready', function(){ // New unfinished torrent torrent_hashes[torrent_hashes.length] = event.hash; //alert("Inserting row"); - myTable.insertRow(event.hash, row); + myTable.insertRow(event.hash, row, event.state); } else { // Update torrent data myTable.updateRow(event.hash, row, event.state); diff --git a/src/webui/scripts/dynamicTable.js b/src/webui/scripts/dynamicTable.js index 6e9156780..3c1afd27c 100644 --- a/src/webui/scripts/dynamicTable.js +++ b/src/webui/scripts/dynamicTable.js @@ -94,36 +94,36 @@ var dynamicTable = new Class ({ switch(this.filter) { case 'all': tr.removeClass("invisible"); - return; + break; case 'downloading': if(status == "downloading" || status == "stalledDL" || status == "checkingDL" || status == "pausedDL" || status == "queuedDL") { tr.removeClass("invisible"); } else { tr.addClass("invisible"); } - return; + break; case 'completed': if(status == "seeding" || status == "stalledUP" || status == "checkingUP" || status == "pausedUP" || status == "queuedUP") { tr.removeClass("invisible"); } else { tr.addClass("invisible"); } - return; + break; case 'active': if(status == "downloading" || status == "seeding") { tr.removeClass("invisible"); } else { tr.addClass("invisible"); } - return; + break; case 'inactive': if(status != "downloading" && status != "seeding") { tr.removeClass("invisible"); } else { tr.addClass("invisible"); } - return; } + return !tr.hasClass('invisible'); }, insertRow: function(id, row, status){ @@ -257,19 +257,21 @@ var dynamicTable = new Class ({ } var tr = this.rows.get(id); // Apply filter - this.applyFilterOnRow(tr, status); - var tds = tr.getElements('td'); - for(var i=0; i