Browse Source

Improve performance of updating 'progress' column

adaptive-webui-19844
buinsky 8 years ago
parent
commit
b6c6b70915
  1. 26
      src/webui/www/public/scripts/dynamicTable.js

26
src/webui/www/public/scripts/dynamicTable.js

@ -32,6 +32,7 @@
**************************************************************/ **************************************************************/
var DynamicTableHeaderContextMenuClass = null; var DynamicTableHeaderContextMenuClass = null;
var ProgressColumnWidth = -1;
var DynamicTable = new Class({ var DynamicTable = new Class({
@ -851,25 +852,34 @@ var TorrentsTable = new Class({
if (td.getChildren('div').length) { if (td.getChildren('div').length) {
var div = td.getChildren('div')[0]; var div = td.getChildren('div')[0];
var newWidth = td.offsetWidth - 5; if (td.resized) {
if (div.lastWidth !== newWidth) { td.resized = false;
div.setWidth(newWidth); div.setWidth(ProgressColumnWidth - 5);
div.lastWidth = newWidth;
} }
if (div.getValue() != progressFormated) if (div.getValue() != progressFormated)
div.setValue(progressFormated); div.setValue(progressFormated);
} }
else else {
if (ProgressColumnWidth < 0)
ProgressColumnWidth = td.offsetWidth;
td.adopt(new ProgressBar(progressFormated.toFloat(), { td.adopt(new ProgressBar(progressFormated.toFloat(), {
'width' : td.offsetWidth - 5 'width' : ProgressColumnWidth - 5
})); }));
td.resized = false;
}
}; };
this.columns['progress'].onResize = function (columnName) { this.columns['progress'].onResize = function (columnName) {
var pos = this.getColumnPos(columnName); var pos = this.getColumnPos(columnName);
var trs = this.tableBody.getElements('tr'); var trs = this.tableBody.getElements('tr');
for (var i = 0; i < trs.length; i++) ProgressColumnWidth = -1;
this.columns[columnName].updateTd(trs[i].getElements('td')[pos], this.rows.get(trs[i].rowId)); for (var i = 0; i < trs.length; i++) {
var td = trs[i].getElements('td')[pos];
if (ProgressColumnWidth < 0)
ProgressColumnWidth = td.offsetWidth;
td.resized = true;
this.columns[columnName].updateTd(td, this.rows.get(trs[i].rowId));
}
}.bind(this); }.bind(this);
// num_seeds // num_seeds

Loading…
Cancel
Save