1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-02-05 03:14:44 +00:00

Reformat WebUI code

This commit is contained in:
Chocobo1 2018-12-12 12:23:56 +08:00
parent ba32525b45
commit d0886f8db0
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
8 changed files with 175 additions and 172 deletions

View File

@ -11,6 +11,7 @@
width: 100%; width: 100%;
line-height: 2em; line-height: 2em;
} }
</style> </style>
<div id="installSearchPluginContainer"> <div id="installSearchPluginContainer">
@ -20,7 +21,7 @@
<input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none" /> <input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none" />
<div style="margin-top: 10px; text-align: center;"> <div style="margin-top: 10px; text-align: center;">
<button id="newPluginCancel" onclick="closeSearchWindow('installSearchPlugin');">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button> <button id="newPluginCancel" onclick="closeSearchWindow('installSearchPlugin');">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button>
<button id="newPluginOk" onclick="newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button></div> <button id="newPluginOk" onclick="newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button>
</div> </div>
</div> </div>
</div> </div>
@ -32,7 +33,7 @@
var installSearchPluginKeyboardEvents = new Keyboard({ var installSearchPluginKeyboardEvents = new Keyboard({
defaultEventType: 'keydown', defaultEventType: 'keydown',
events: { events: {
'enter': function (e) { 'enter': function(e) {
// accept enter key as a click // accept enter key as a click
new Event(e).stop(); new Event(e).stop();
@ -59,7 +60,7 @@
data: { data: {
sources: path, sources: path,
}, },
onRequest: function(){ onRequest: function() {
closeSearchWindow('installSearchPlugin'); closeSearchWindow('installSearchPlugin');
} }
}).send(); }).send();

View File

@ -86,7 +86,7 @@
<tr> <tr>
<td> <td>
<input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();" /> <input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();" />
<label for="temppath_checkbox" >QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="temppath_checkbox">QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="temppath_text" /> <input type="text" id="temppath_text" />
@ -95,7 +95,7 @@
<tr> <tr>
<td> <td>
<input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();" /> <input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();" />
<label for="exportdir_checkbox" >QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="exportdir_checkbox">QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="exportdir_text" /> <input type="text" id="exportdir_text" />
@ -104,7 +104,7 @@
<tr> <tr>
<td> <td>
<input type="checkbox" id="exportdirfin_checkbox" onclick="updateExportDirFinEnabled();" /> <input type="checkbox" id="exportdirfin_checkbox" onclick="updateExportDirFinEnabled();" />
<label for="exportdirfin_checkbox" >QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="exportdirfin_checkbox">QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td> </td>
<td> <td>
<input type="text" id="exportdirfin_text" /> <input type="text" id="exportdirfin_text" />

View File

@ -644,20 +644,20 @@ window.addEvent('load', function() {
var addSearchPanel = function() { var addSearchPanel = function() {
new MochaUI.Panel({ new MochaUI.Panel({
id : 'SearchPanel', id: 'SearchPanel',
title : 'Search', title: 'Search',
header : false, header: false,
padding : { padding: {
top : 0, top: 0,
right : 0, right: 0,
bottom : 0, bottom: 0,
left : 0 left: 0
}, },
loadMethod : 'xhr', loadMethod: 'xhr',
contentURL : 'search.html', contentURL: 'search.html',
content: '', content: '',
column : 'searchTabColumn', column: 'searchTabColumn',
height : null height: null
}); });
}; };

View File

@ -406,7 +406,7 @@ var CategoriesFilterContextMenu = new Class({
var SearchPluginsTableContextMenu = new Class({ var SearchPluginsTableContextMenu = new Class({
Extends: ContextMenu, Extends: ContextMenu,
updateMenuItems: function () { updateMenuItems: function() {
var enabledColumnIndex = function(text) { var enabledColumnIndex = function(text) {
var columns = $("searchPluginsTableFixedHeaderRow").getChildren("th"); var columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
for (var i = 0; i < columns.length; ++i) for (var i = 0; i < columns.length; ++i)

View File

@ -1387,164 +1387,164 @@ var TorrentPeersTable = new Class({
}); });
var SearchResultsTable = new Class({ var SearchResultsTable = new Class({
Extends: DynamicTable, Extends: DynamicTable,
initColumns: function () { initColumns: function() {
this.newColumn('fileName', '', 'QBT_TR(Name)QBT_TR[CONTEXT=SearchResultsTable]', 500, true); 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('fileSize', '', 'QBT_TR(Size)QBT_TR[CONTEXT=SearchResultsTable]', 100, true);
this.newColumn('nbSeeders', '', 'QBT_TR(Seeders)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('nbLeechers', '', 'QBT_TR(Leechers)QBT_TR[CONTEXT=SearchResultsTable]', 100, true);
this.newColumn('siteUrl', '', 'QBT_TR(Search engine)QBT_TR[CONTEXT=SearchResultsTable]', 250, true); this.newColumn('siteUrl', '', 'QBT_TR(Search engine)QBT_TR[CONTEXT=SearchResultsTable]', 250, true);
this.initColumnsFunctions(); this.initColumnsFunctions();
}, },
initColumnsFunctions: function () { initColumnsFunctions: function() {
var displayText = function (td, row) { var displayText = function(td, row) {
var value = this.getRowValue(row); var value = this.getRowValue(row);
td.set('html', escapeHtml(value)); 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);
}
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;
}
return true;
};
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;
if ((minSize > maxSize) && (maxSize > 0.00)) {
var tmp = minSize;
minSize = maxSize;
maxSize = tmp;
}
return {
min: minSize,
max: maxSize
}
};
var getSeedsFilters = function() {
var minSeeds = (searchSeedsFilter.min > 0) ? searchSeedsFilter.min : 0;
var maxSeeds = (searchSeedsFilter.max > 0) ? searchSeedsFilter.max : 0;
if ((minSeeds > maxSeeds) && (maxSeeds > 0)) {
var tmp = minSeeds;
minSeeds = maxSeeds;
maxSeeds = tmp;
}
return {
min: minSeeds,
max: maxSeeds
}
}
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;
}
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));
return filteredRows;
},
setupTr: function (tr) {
tr.addClass("searchTableRow");
} }
}); 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);
}
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;
}
return true;
};
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;
if ((minSize > maxSize) && (maxSize > 0.00)) {
var tmp = minSize;
minSize = maxSize;
maxSize = tmp;
}
return {
min: minSize,
max: maxSize
}
};
var getSeedsFilters = function() {
var minSeeds = (searchSeedsFilter.min > 0) ? searchSeedsFilter.min : 0;
var maxSeeds = (searchSeedsFilter.max > 0) ? searchSeedsFilter.max : 0;
if ((minSeeds > maxSeeds) && (maxSeeds > 0)) {
var tmp = minSeeds;
minSeeds = maxSeeds;
maxSeeds = tmp;
}
return {
min: minSeeds,
max: maxSeeds
}
}
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;
}
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));
return filteredRows;
},
setupTr: function(tr) {
tr.addClass("searchTableRow");
}
});
var SearchPluginsTable = new Class({ var SearchPluginsTable = new Class({
Extends: DynamicTable, Extends: DynamicTable,
initColumns: function () { initColumns: function() {
this.newColumn('fullName', '', 'QBT_TR(Name)QBT_TR[CONTEXT=SearchPluginsTable]', 175, true); 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('version', '', 'QBT_TR(Version)QBT_TR[CONTEXT=SearchPluginsTable]', 100, true);
this.newColumn('url', '', 'QBT_TR(Url)QBT_TR[CONTEXT=SearchPluginsTable]', 175, 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.newColumn('enabled', '', 'QBT_TR(Enabled)QBT_TR[CONTEXT=SearchPluginsTable]', 100, true);
this.initColumnsFunctions(); this.initColumnsFunctions();
}, },
initColumnsFunctions: function () { initColumnsFunctions: function() {
var displayText = function (td, row) { var displayText = function(td, row) {
var value = this.getRowValue(row); var value = this.getRowValue(row);
td.set('html', escapeHtml(value)); 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");
} }
});
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");
}
});
/*************************************************************/ /*************************************************************/

View File

@ -56,6 +56,7 @@
line-height: 1.5em; line-height: 1.5em;
float: right; float: right;
} }
</style> </style>
<div id="searchResults"> <div id="searchResults">
@ -201,7 +202,7 @@
var searchKeyboardEvents = new Keyboard({ var searchKeyboardEvents = new Keyboard({
defaultEventType: 'keydown', defaultEventType: 'keydown',
events: { events: {
'enter': function (e) { 'enter': function(e) {
// accept enter key as a click // accept enter key as a click
new Event(e).stop(); new Event(e).stop();
@ -453,7 +454,7 @@
$('searchResultsTableContainer').style.display = "block"; $('searchResultsTableContainer').style.display = "block";
// sort plugins alphabetically // sort plugins alphabetically
var allPlugins = searchPlugins.sort(function(pluginA, pluginB){ var allPlugins = searchPlugins.sort(function(pluginA, pluginB) {
var a = pluginA.fullName.toLowerCase(); var a = pluginA.fullName.toLowerCase();
var b = pluginB.fullName.toLowerCase(); var b = pluginB.fullName.toLowerCase();
if (a < b) return -1; if (a < b) return -1;

View File

@ -38,6 +38,7 @@
#searchPlugins_content { #searchPlugins_content {
height: 100%; height: 100%;
} }
</style> </style>
<div id="searchPluginsContainer"> <div id="searchPluginsContainer">
@ -90,7 +91,7 @@
Enabled: enablePlugin, Enabled: enablePlugin,
Uninstall: uninstallPlugin Uninstall: uninstallPlugin
}, },
offsets : calculateContextMenuOffsets() offsets: calculateContextMenuOffsets()
}); });
searchPluginsTable.setup('searchPluginsTableDiv', 'searchPluginsTableFixedHeaderDiv', searchPluginsTableContextMenu); searchPluginsTable.setup('searchPluginsTableDiv', 'searchPluginsTableFixedHeaderDiv', searchPluginsTableContextMenu);
updateSearchPluginsTable(); updateSearchPluginsTable();

View File

@ -63,7 +63,7 @@
UploadLimit: function(element, ref) { UploadLimit: function(element, ref) {
uploadLimitFN(); uploadLimitFN();
}, },
ShareRatio : function (element, ref) { ShareRatio: function(element, ref) {
shareRatioFN(); shareRatioFN();
}, },