Browse Source

- 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)
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
d22e932ef7
  1. 2
      src/webui/scripts/client.js
  2. 34
      src/webui/scripts/dynamicTable.js

2
src/webui/scripts/client.js

@ -135,7 +135,7 @@ window.addEvent('domready', function(){
// New unfinished torrent // New unfinished torrent
torrent_hashes[torrent_hashes.length] = event.hash; torrent_hashes[torrent_hashes.length] = event.hash;
//alert("Inserting row"); //alert("Inserting row");
myTable.insertRow(event.hash, row); myTable.insertRow(event.hash, row, event.state);
} else { } else {
// Update torrent data // Update torrent data
myTable.updateRow(event.hash, row, event.state); myTable.updateRow(event.hash, row, event.state);

34
src/webui/scripts/dynamicTable.js

@ -94,36 +94,36 @@ var dynamicTable = new Class ({
switch(this.filter) { switch(this.filter) {
case 'all': case 'all':
tr.removeClass("invisible"); tr.removeClass("invisible");
return; break;
case 'downloading': case 'downloading':
if(status == "downloading" || status == "stalledDL" || status == "checkingDL" || status == "pausedDL" || status == "queuedDL") { if(status == "downloading" || status == "stalledDL" || status == "checkingDL" || status == "pausedDL" || status == "queuedDL") {
tr.removeClass("invisible"); tr.removeClass("invisible");
} else { } else {
tr.addClass("invisible"); tr.addClass("invisible");
} }
return; break;
case 'completed': case 'completed':
if(status == "seeding" || status == "stalledUP" || status == "checkingUP" || status == "pausedUP" || status == "queuedUP") { if(status == "seeding" || status == "stalledUP" || status == "checkingUP" || status == "pausedUP" || status == "queuedUP") {
tr.removeClass("invisible"); tr.removeClass("invisible");
} else { } else {
tr.addClass("invisible"); tr.addClass("invisible");
} }
return; break;
case 'active': case 'active':
if(status == "downloading" || status == "seeding") { if(status == "downloading" || status == "seeding") {
tr.removeClass("invisible"); tr.removeClass("invisible");
} else { } else {
tr.addClass("invisible"); tr.addClass("invisible");
} }
return; break;
case 'inactive': case 'inactive':
if(status != "downloading" && status != "seeding") { if(status != "downloading" && status != "seeding") {
tr.removeClass("invisible"); tr.removeClass("invisible");
} else { } else {
tr.addClass("invisible"); tr.addClass("invisible");
} }
return;
} }
return !tr.hasClass('invisible');
}, },
insertRow: function(id, row, status){ insertRow: function(id, row, status){
@ -257,19 +257,21 @@ var dynamicTable = new Class ({
} }
var tr = this.rows.get(id); var tr = this.rows.get(id);
// Apply filter // Apply filter
this.applyFilterOnRow(tr, status); if(this.applyFilterOnRow(tr, status)) {
var tds = tr.getElements('td'); var tds = tr.getElements('td');
for(var i=0; i<row.length; i++) { for(var i=0; i<row.length; i++) {
if(i==this.progressIndex) { if(i==1) continue; // Do not refresh name
$('pb_'+id).setValue(row[i].toFloat()); if(i==this.progressIndex) {
} else { $('pb_'+id).setValue(row[i].toFloat());
if(i==0) {
tds[i].getChildren('img')[0].set('src', row[i]);
} else { } else {
tds[i].set('html', row[i]); if(i==0) {
tds[i].getChildren('img')[0].set('src', row[i]);
} else {
tds[i].set('html', row[i]);
}
} }
} };
}; }
return true; return true;
}, },

Loading…
Cancel
Save