|
|
|
@ -1387,164 +1387,164 @@ var TorrentPeersTable = new Class({
@@ -1387,164 +1387,164 @@ var TorrentPeersTable = new Class({
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var SearchResultsTable = new Class({ |
|
|
|
|
Extends: DynamicTable, |
|
|
|
|
|
|
|
|
|
initColumns: function () { |
|
|
|
|
this.newColumn('fileName', '', 'QBT_TR(Name)QBT_TR[CONTEXT=SearchResultsTable]', 500, true); |
|
|
|
|
this.newColumn('fileSize', '', 'QBT_TR(Size)QBT_TR[CONTEXT=SearchResultsTable]', 100, true); |
|
|
|
|
this.newColumn('nbSeeders', '', 'QBT_TR(Seeders)QBT_TR[CONTEXT=SearchResultsTable]', 100, true); |
|
|
|
|
this.newColumn('nbLeechers', '', 'QBT_TR(Leechers)QBT_TR[CONTEXT=SearchResultsTable]', 100, true); |
|
|
|
|
this.newColumn('siteUrl', '', 'QBT_TR(Search engine)QBT_TR[CONTEXT=SearchResultsTable]', 250, true); |
|
|
|
|
|
|
|
|
|
this.initColumnsFunctions(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
initColumnsFunctions: function () { |
|
|
|
|
var displayText = function (td, row) { |
|
|
|
|
var value = this.getRowValue(row); |
|
|
|
|
td.set('html', escapeHtml(value)); |
|
|
|
|
} |
|
|
|
|
var displaySize = function(td, row) { |
|
|
|
|
var size = this.getRowValue(row); |
|
|
|
|
td.set('html', friendlyUnit(size, false)); |
|
|
|
|
} |
|
|
|
|
var displayNum = function (td, row) { |
|
|
|
|
var value = escapeHtml(this.getRowValue(row)); |
|
|
|
|
td.set('html', (value === "-1") ? "Unknown" : value); |
|
|
|
|
} |
|
|
|
|
Extends: DynamicTable, |
|
|
|
|
|
|
|
|
|
this.columns['fileName'].updateTd = displayText; |
|
|
|
|
this.columns['fileSize'].updateTd = displaySize; |
|
|
|
|
this.columns['nbSeeders'].updateTd = displayNum; |
|
|
|
|
this.columns['nbLeechers'].updateTd = displayNum; |
|
|
|
|
this.columns['siteUrl'].updateTd = displayText; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getFilteredAndSortedRows: function () { |
|
|
|
|
var containsAll = function(text, searchTerms) { |
|
|
|
|
text = text.toLowerCase(); |
|
|
|
|
for (var i = 0; i < searchTerms.length; ++i) { |
|
|
|
|
if (text.indexOf(searchTerms[i].toLowerCase()) === -1) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
initColumns: function() { |
|
|
|
|
this.newColumn('fileName', '', 'QBT_TR(Name)QBT_TR[CONTEXT=SearchResultsTable]', 500, true); |
|
|
|
|
this.newColumn('fileSize', '', 'QBT_TR(Size)QBT_TR[CONTEXT=SearchResultsTable]', 100, true); |
|
|
|
|
this.newColumn('nbSeeders', '', 'QBT_TR(Seeders)QBT_TR[CONTEXT=SearchResultsTable]', 100, true); |
|
|
|
|
this.newColumn('nbLeechers', '', 'QBT_TR(Leechers)QBT_TR[CONTEXT=SearchResultsTable]', 100, true); |
|
|
|
|
this.newColumn('siteUrl', '', 'QBT_TR(Search engine)QBT_TR[CONTEXT=SearchResultsTable]', 250, true); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
this.initColumnsFunctions(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
var getSizeFilters = function() { |
|
|
|
|
var minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00; |
|
|
|
|
var maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00; |
|
|
|
|
initColumnsFunctions: function() { |
|
|
|
|
var displayText = function(td, row) { |
|
|
|
|
var value = this.getRowValue(row); |
|
|
|
|
td.set('html', escapeHtml(value)); |
|
|
|
|
} |
|
|
|
|
var displaySize = function(td, row) { |
|
|
|
|
var size = this.getRowValue(row); |
|
|
|
|
td.set('html', friendlyUnit(size, false)); |
|
|
|
|
} |
|
|
|
|
var displayNum = function(td, row) { |
|
|
|
|
var value = escapeHtml(this.getRowValue(row)); |
|
|
|
|
td.set('html', (value === "-1") ? "Unknown" : value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((minSize > maxSize) && (maxSize > 0.00)) { |
|
|
|
|
var tmp = minSize; |
|
|
|
|
minSize = maxSize; |
|
|
|
|
maxSize = tmp; |
|
|
|
|
} |
|
|
|
|
this.columns['fileName'].updateTd = displayText; |
|
|
|
|
this.columns['fileSize'].updateTd = displaySize; |
|
|
|
|
this.columns['nbSeeders'].updateTd = displayNum; |
|
|
|
|
this.columns['nbLeechers'].updateTd = displayNum; |
|
|
|
|
this.columns['siteUrl'].updateTd = displayText; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
min: minSize, |
|
|
|
|
max: maxSize |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
getFilteredAndSortedRows: function() { |
|
|
|
|
var containsAll = function(text, searchTerms) { |
|
|
|
|
text = text.toLowerCase(); |
|
|
|
|
for (var i = 0; i < searchTerms.length; ++i) { |
|
|
|
|
if (text.indexOf(searchTerms[i].toLowerCase()) === -1) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var getSeedsFilters = function() { |
|
|
|
|
var minSeeds = (searchSeedsFilter.min > 0) ? searchSeedsFilter.min : 0; |
|
|
|
|
var maxSeeds = (searchSeedsFilter.max > 0) ? searchSeedsFilter.max : 0; |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if ((minSeeds > maxSeeds) && (maxSeeds > 0)) { |
|
|
|
|
var tmp = minSeeds; |
|
|
|
|
minSeeds = maxSeeds; |
|
|
|
|
maxSeeds = tmp; |
|
|
|
|
} |
|
|
|
|
var getSizeFilters = function() { |
|
|
|
|
var minSize = (searchSizeFilter.min > 0.00) ? (searchSizeFilter.min * Math.pow(1024, searchSizeFilter.minUnit)) : 0.00; |
|
|
|
|
var maxSize = (searchSizeFilter.max > 0.00) ? (searchSizeFilter.max * Math.pow(1024, searchSizeFilter.maxUnit)) : 0.00; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
min: minSeeds, |
|
|
|
|
max: maxSeeds |
|
|
|
|
} |
|
|
|
|
if ((minSize > maxSize) && (maxSize > 0.00)) { |
|
|
|
|
var tmp = minSize; |
|
|
|
|
minSize = maxSize; |
|
|
|
|
maxSize = tmp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var filteredRows = []; |
|
|
|
|
var rows = this.rows.getValues(); |
|
|
|
|
var searchTerms = searchPattern.toLowerCase().split(" "); |
|
|
|
|
var filterTerms = searchFilterPattern.toLowerCase().split(" "); |
|
|
|
|
var sizeFilters = getSizeFilters(); |
|
|
|
|
var seedsFilters = getSeedsFilters(); |
|
|
|
|
var searchInTorrentName = $('searchInTorrentName').get('value') === "names"; |
|
|
|
|
|
|
|
|
|
if (searchInTorrentName || filterTerms.length || (searchSizeFilter.min > 0.00) || (searchSizeFilter.max > 0.00)) { |
|
|
|
|
for (var i = 0; i < rows.length; ++i) { |
|
|
|
|
var row = rows[i]; |
|
|
|
|
|
|
|
|
|
if (searchInTorrentName && !containsAll(row.full_data.fileName, searchTerms)) continue; |
|
|
|
|
if (filterTerms.length && !containsAll(row.full_data.fileName, filterTerms)) continue; |
|
|
|
|
if ((sizeFilters.min > 0.00) && (row.full_data.fileSize < sizeFilters.min)) continue; |
|
|
|
|
if ((sizeFilters.max > 0.00) && (row.full_data.fileSize > sizeFilters.max)) continue; |
|
|
|
|
if ((seedsFilters.min > 0) && (row.full_data.nbSeeders < seedsFilters.min)) continue; |
|
|
|
|
if ((seedsFilters.max > 0) && (row.full_data.nbSeeders > seedsFilters.max)) continue; |
|
|
|
|
|
|
|
|
|
filteredRows.push(row); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
filteredRows = rows; |
|
|
|
|
return { |
|
|
|
|
min: minSize, |
|
|
|
|
max: maxSize |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
filteredRows.sort(function (row1, row2) { |
|
|
|
|
var column = this.columns[this.sortedColumn]; |
|
|
|
|
var res = column.compareRows(row1, row2); |
|
|
|
|
if (this.reverseSort == '0') |
|
|
|
|
return res; |
|
|
|
|
else |
|
|
|
|
return -res; |
|
|
|
|
}.bind(this)); |
|
|
|
|
var getSeedsFilters = function() { |
|
|
|
|
var minSeeds = (searchSeedsFilter.min > 0) ? searchSeedsFilter.min : 0; |
|
|
|
|
var maxSeeds = (searchSeedsFilter.max > 0) ? searchSeedsFilter.max : 0; |
|
|
|
|
|
|
|
|
|
return filteredRows; |
|
|
|
|
}, |
|
|
|
|
if ((minSeeds > maxSeeds) && (maxSeeds > 0)) { |
|
|
|
|
var tmp = minSeeds; |
|
|
|
|
minSeeds = maxSeeds; |
|
|
|
|
maxSeeds = tmp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setupTr: function (tr) { |
|
|
|
|
tr.addClass("searchTableRow"); |
|
|
|
|
return { |
|
|
|
|
min: minSeeds, |
|
|
|
|
max: maxSeeds |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var SearchPluginsTable = new Class({ |
|
|
|
|
Extends: DynamicTable, |
|
|
|
|
var filteredRows = []; |
|
|
|
|
var rows = this.rows.getValues(); |
|
|
|
|
var searchTerms = searchPattern.toLowerCase().split(" "); |
|
|
|
|
var filterTerms = searchFilterPattern.toLowerCase().split(" "); |
|
|
|
|
var sizeFilters = getSizeFilters(); |
|
|
|
|
var seedsFilters = getSeedsFilters(); |
|
|
|
|
var searchInTorrentName = $('searchInTorrentName').get('value') === "names"; |
|
|
|
|
|
|
|
|
|
if (searchInTorrentName || filterTerms.length || (searchSizeFilter.min > 0.00) || (searchSizeFilter.max > 0.00)) { |
|
|
|
|
for (var i = 0; i < rows.length; ++i) { |
|
|
|
|
var row = rows[i]; |
|
|
|
|
|
|
|
|
|
if (searchInTorrentName && !containsAll(row.full_data.fileName, searchTerms)) continue; |
|
|
|
|
if (filterTerms.length && !containsAll(row.full_data.fileName, filterTerms)) continue; |
|
|
|
|
if ((sizeFilters.min > 0.00) && (row.full_data.fileSize < sizeFilters.min)) continue; |
|
|
|
|
if ((sizeFilters.max > 0.00) && (row.full_data.fileSize > sizeFilters.max)) continue; |
|
|
|
|
if ((seedsFilters.min > 0) && (row.full_data.nbSeeders < seedsFilters.min)) continue; |
|
|
|
|
if ((seedsFilters.max > 0) && (row.full_data.nbSeeders > seedsFilters.max)) continue; |
|
|
|
|
|
|
|
|
|
filteredRows.push(row); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
filteredRows = rows; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initColumns: function () { |
|
|
|
|
this.newColumn('fullName', '', 'QBT_TR(Name)QBT_TR[CONTEXT=SearchPluginsTable]', 175, true); |
|
|
|
|
this.newColumn('version', '', 'QBT_TR(Version)QBT_TR[CONTEXT=SearchPluginsTable]', 100, true); |
|
|
|
|
this.newColumn('url', '', 'QBT_TR(Url)QBT_TR[CONTEXT=SearchPluginsTable]', 175, true); |
|
|
|
|
this.newColumn('enabled', '', 'QBT_TR(Enabled)QBT_TR[CONTEXT=SearchPluginsTable]', 100, true); |
|
|
|
|
filteredRows.sort(function(row1, row2) { |
|
|
|
|
var column = this.columns[this.sortedColumn]; |
|
|
|
|
var res = column.compareRows(row1, row2); |
|
|
|
|
if (this.reverseSort == '0') |
|
|
|
|
return res; |
|
|
|
|
else |
|
|
|
|
return -res; |
|
|
|
|
}.bind(this)); |
|
|
|
|
|
|
|
|
|
this.initColumnsFunctions(); |
|
|
|
|
}, |
|
|
|
|
return filteredRows; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
initColumnsFunctions: function () { |
|
|
|
|
var displayText = function (td, row) { |
|
|
|
|
var value = this.getRowValue(row); |
|
|
|
|
td.set('html', escapeHtml(value)); |
|
|
|
|
} |
|
|
|
|
setupTr: function(tr) { |
|
|
|
|
tr.addClass("searchTableRow"); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.columns['fullName'].updateTd = displayText; |
|
|
|
|
this.columns['version'].updateTd = displayText; |
|
|
|
|
this.columns['url'].updateTd = displayText; |
|
|
|
|
this.columns['enabled'].updateTd = function(td, row) { |
|
|
|
|
var value = this.getRowValue(row); |
|
|
|
|
if (value) { |
|
|
|
|
td.set('html', "Yes"); |
|
|
|
|
td.getParent("tr").addClass("green"); |
|
|
|
|
td.getParent("tr").removeClass("red"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
td.set('html', "No"); |
|
|
|
|
td.getParent("tr").addClass("red"); |
|
|
|
|
td.getParent("tr").removeClass("green"); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
var SearchPluginsTable = new Class({ |
|
|
|
|
Extends: DynamicTable, |
|
|
|
|
|
|
|
|
|
setupTr: function (tr) { |
|
|
|
|
tr.addClass("searchPluginsTableRow"); |
|
|
|
|
initColumns: function() { |
|
|
|
|
this.newColumn('fullName', '', 'QBT_TR(Name)QBT_TR[CONTEXT=SearchPluginsTable]', 175, true); |
|
|
|
|
this.newColumn('version', '', 'QBT_TR(Version)QBT_TR[CONTEXT=SearchPluginsTable]', 100, true); |
|
|
|
|
this.newColumn('url', '', 'QBT_TR(Url)QBT_TR[CONTEXT=SearchPluginsTable]', 175, true); |
|
|
|
|
this.newColumn('enabled', '', 'QBT_TR(Enabled)QBT_TR[CONTEXT=SearchPluginsTable]', 100, true); |
|
|
|
|
|
|
|
|
|
this.initColumnsFunctions(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
initColumnsFunctions: function() { |
|
|
|
|
var displayText = function(td, row) { |
|
|
|
|
var value = this.getRowValue(row); |
|
|
|
|
td.set('html', escapeHtml(value)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.columns['fullName'].updateTd = displayText; |
|
|
|
|
this.columns['version'].updateTd = displayText; |
|
|
|
|
this.columns['url'].updateTd = displayText; |
|
|
|
|
this.columns['enabled'].updateTd = function(td, row) { |
|
|
|
|
var value = this.getRowValue(row); |
|
|
|
|
if (value) { |
|
|
|
|
td.set('html', "Yes"); |
|
|
|
|
td.getParent("tr").addClass("green"); |
|
|
|
|
td.getParent("tr").removeClass("red"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
td.set('html', "No"); |
|
|
|
|
td.getParent("tr").addClass("red"); |
|
|
|
|
td.getParent("tr").removeClass("green"); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setupTr: function(tr) { |
|
|
|
|
tr.addClass("searchPluginsTableRow"); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/*************************************************************/ |
|
|
|
|