1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

WebUI: Simplify the code for the update of the content table

This commit is contained in:
Gabriele 2015-03-04 20:00:00 +01:00
parent 4db757839c
commit dd112c1e1b

View File

@ -202,31 +202,28 @@ var filesDynTable = new Class({
updateRow: function(tr, row, id) { updateRow: function(tr, row, id) {
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 == 3) { switch (i) {
case 0:
if (row[i] > 0)
tds[i].getChildren('input')[0].set('checked', 'checked');
else
tds[i].getChildren('input')[0].removeProperty('checked');
break;
case 3:
$('pbf_' + id).setValue(row[i].toFloat()); $('pbf_' + id).setValue(row[i].toFloat());
} break;
else { case 4:
if (i == 0) { if (!is_seed && row[i] > 0) {
if (row[i] > 0) tds[i].getChildren('select').set('value', row[i]);
tds[i].getChildren('input')[0].set('checked', 'checked'); $('comboPrio' + id).removeClass("invisible");
else
tds[i].getChildren('input')[0].removeProperty('checked')
} }
else { else {
if (i == 4) { if (!$('comboPrio' + id).hasClass("invisible"))
if (!is_seed && row[i] > 0) { $('comboPrio' + id).addClass("invisible");
tds[i].getChildren('select').set('value', row[i]);
$('comboPrio' + id).removeClass("invisible");
}
else {
if (!$('comboPrio' + id).hasClass("invisible"))
$('comboPrio' + id).addClass("invisible");
}
}
else {
tds[i].set('html', row[i]);
}
} }
break;
default:
tds[i].set('html', row[i]);
} }
} }
return true; return true;
@ -243,28 +240,26 @@ var filesDynTable = new Class({
this.rows.set(id, tr); this.rows.set(id, tr);
for (var i = 0; i < row.length; i++) { for (var i = 0; i < row.length; i++) {
var td = new Element('td'); var td = new Element('td');
if (i == 3) { switch (i) {
case 0:
var tree_img = new Element('img', {
src: 'images/L.gif',
style: 'margin-bottom: -2px'
});
td.adopt(tree_img, createDownloadedCB(id, row[i]));
break;
case 3:
td.adopt(new ProgressBar(row[i].toFloat(), { td.adopt(new ProgressBar(row[i].toFloat(), {
'id': 'pbf_' + id, 'id': 'pbf_' + id,
'width': 80 'width': 80
})); }));
} break;
else { case 4:
if (i == 0) { td.adopt(createPriorityCombo(id, row[i]));
var tree_img = new Element('img', { break;
src: 'images/L.gif', default:
style: 'margin-bottom: -2px' td.set('html', row[i]);
}); break;
td.adopt(tree_img, createDownloadedCB(id, row[i]));
}
else {
if (i == 4) {
td.adopt(createPriorityCombo(id, row[i]));
}
else {
td.set('html', row[i]);
}
}
} }
td.injectInside(tr); td.injectInside(tr);
} }