|
|
@ -1139,8 +1139,9 @@ var TorrentsTable = new Class({ |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
applyFilter: function(row, filterName, categoryHash) { |
|
|
|
applyFilter: function(row, filterName, categoryHash, filterTerms) { |
|
|
|
var state = row['full_data'].state; |
|
|
|
var state = row['full_data'].state; |
|
|
|
|
|
|
|
var name = row['full_data'].name.toLowerCase(); |
|
|
|
var inactive = false; |
|
|
|
var inactive = false; |
|
|
|
var r; |
|
|
|
var r; |
|
|
|
|
|
|
|
|
|
|
@ -1182,14 +1183,27 @@ var TorrentsTable = new Class({ |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (categoryHash == CATEGORIES_ALL) |
|
|
|
var categoryHashInt = parseInt(categoryHash); |
|
|
|
return true; |
|
|
|
if (!isNaN(categoryHashInt)) { |
|
|
|
|
|
|
|
switch (categoryHashInt) { |
|
|
|
if (categoryHash == CATEGORIES_UNCATEGORIZED && row['full_data'].category.length === 0) |
|
|
|
case CATEGORIES_ALL: |
|
|
|
return true; |
|
|
|
break; // do nothing
|
|
|
|
|
|
|
|
case CATEGORIES_UNCATEGORIZED: |
|
|
|
|
|
|
|
if (row['full_data'].category.length !== 0) |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
break; // do nothing
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
if (categoryHashInt !== genHash(row['full_data'].category)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (categoryHash != genHash(row['full_data'].category)) |
|
|
|
if (filterTerms) { |
|
|
|
return false; |
|
|
|
for (var i = 0; i < filterTerms.length; ++i) { |
|
|
|
|
|
|
|
if (name.indexOf(filterTerms[i]) === -1) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1199,7 +1213,7 @@ var TorrentsTable = new Class({ |
|
|
|
var rows = this.rows.getValues(); |
|
|
|
var rows = this.rows.getValues(); |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < rows.length; ++i) |
|
|
|
for (var i = 0; i < rows.length; ++i) |
|
|
|
if (this.applyFilter(rows[i], filterName, categoryHash)) ++cnt; |
|
|
|
if (this.applyFilter(rows[i], filterName, categoryHash, null)) ++cnt; |
|
|
|
return cnt; |
|
|
|
return cnt; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -1208,7 +1222,7 @@ var TorrentsTable = new Class({ |
|
|
|
var rows = this.rows.getValues(); |
|
|
|
var rows = this.rows.getValues(); |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < rows.length; ++i) |
|
|
|
for (var i = 0; i < rows.length; ++i) |
|
|
|
if (this.applyFilter(rows[i], filterName, categoryHash)) |
|
|
|
if (this.applyFilter(rows[i], filterName, categoryHash, null)) |
|
|
|
rowsHashes.push(rows[i]['rowId']); |
|
|
|
rowsHashes.push(rows[i]['rowId']); |
|
|
|
|
|
|
|
|
|
|
|
return rowsHashes; |
|
|
|
return rowsHashes; |
|
|
@ -1218,12 +1232,15 @@ var TorrentsTable = new Class({ |
|
|
|
var filteredRows = []; |
|
|
|
var filteredRows = []; |
|
|
|
|
|
|
|
|
|
|
|
var rows = this.rows.getValues(); |
|
|
|
var rows = this.rows.getValues(); |
|
|
|
|
|
|
|
var filterText = $('torrentsFilterInput').value.trim().toLowerCase(); |
|
|
|
|
|
|
|
var filterTerms = (filterText.length > 0) ? filterText.split(" ") : null; |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < rows.length; ++i) |
|
|
|
for (var i = 0; i < rows.length; ++i) { |
|
|
|
if (this.applyFilter(rows[i], selected_filter, selected_category)) { |
|
|
|
if (this.applyFilter(rows[i], selected_filter, selected_category, filterTerms)) { |
|
|
|
filteredRows.push(rows[i]); |
|
|
|
filteredRows.push(rows[i]); |
|
|
|
filteredRows[rows[i].rowId] = rows[i]; |
|
|
|
filteredRows[rows[i].rowId] = rows[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
filteredRows.sort(function(row1, row2) { |
|
|
|
filteredRows.sort(function(row1, row2) { |
|
|
|
var column = this.columns[this.sortedColumn]; |
|
|
|
var column = this.columns[this.sortedColumn]; |
|
|
|