mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-12 07:48:04 +00:00
Fix minor JavaScript defects
This commit is contained in:
parent
08df3277df
commit
1e6942e967
@ -760,7 +760,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
time_padding = function(val) {
|
time_padding = function(val) {
|
||||||
ret = val.toString();
|
var ret = val.toString();
|
||||||
if (ret.length == 1)
|
if (ret.length == 1)
|
||||||
ret = '0' + ret;
|
ret = '0' + ret;
|
||||||
return ret;
|
return ret;
|
||||||
@ -768,7 +768,7 @@
|
|||||||
|
|
||||||
loadPreferences = function() {
|
loadPreferences = function() {
|
||||||
var url = 'api/v2/app/preferences';
|
var url = 'api/v2/app/preferences';
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
noCache: true,
|
noCache: true,
|
||||||
@ -1044,7 +1044,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
};
|
||||||
|
|
||||||
applyPreferences = function() {
|
applyPreferences = function() {
|
||||||
var settings = new Hash();
|
var settings = new Hash();
|
||||||
|
@ -301,7 +301,7 @@ window.addEvent('load', function() {
|
|||||||
var syncMainData = function() {
|
var syncMainData = function() {
|
||||||
var url = new URI('api/v2/sync/maindata');
|
var url = new URI('api/v2/sync/maindata');
|
||||||
url.setData('rid', syncMainDataLastResponseId);
|
url.setData('rid', syncMainDataLastResponseId);
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
noCache: true,
|
noCache: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -727,7 +727,7 @@ var loadTorrentPeersData = function() {
|
|||||||
var url = new URI('api/v2/sync/torrentPeers');
|
var url = new URI('api/v2/sync/torrentPeers');
|
||||||
url.setData('rid', syncTorrentPeersLastResponseId);
|
url.setData('rid', syncTorrentPeersLastResponseId);
|
||||||
url.setData('hash', current_hash);
|
url.setData('hash', current_hash);
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
noCache: true,
|
noCache: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -245,18 +245,18 @@ var TorrentsTableContextMenu = new Class({
|
|||||||
Extends: ContextMenu,
|
Extends: ContextMenu,
|
||||||
|
|
||||||
updateMenuItems: function() {
|
updateMenuItems: function() {
|
||||||
all_are_seq_dl = true;
|
var all_are_seq_dl = true;
|
||||||
there_are_seq_dl = false;
|
var there_are_seq_dl = false;
|
||||||
all_are_f_l_piece_prio = true;
|
var all_are_f_l_piece_prio = true;
|
||||||
there_are_f_l_piece_prio = false;
|
var there_are_f_l_piece_prio = false;
|
||||||
all_are_downloaded = true;
|
var all_are_downloaded = true;
|
||||||
all_are_paused = true;
|
var all_are_paused = true;
|
||||||
there_are_paused = false;
|
var there_are_paused = false;
|
||||||
all_are_force_start = true;
|
var all_are_force_start = true;
|
||||||
there_are_force_start = false;
|
var there_are_force_start = false;
|
||||||
all_are_super_seeding = true;
|
var all_are_super_seeding = true;
|
||||||
all_are_auto_tmm = true;
|
var all_are_auto_tmm = true;
|
||||||
there_are_auto_tmm = false;
|
var there_are_auto_tmm = false;
|
||||||
|
|
||||||
var h = torrentsTable.selectedRowsIds();
|
var h = torrentsTable.selectedRowsIds();
|
||||||
h.each(function(item, index) {
|
h.each(function(item, index) {
|
||||||
@ -293,12 +293,12 @@ var TorrentsTableContextMenu = new Class({
|
|||||||
all_are_auto_tmm = false;
|
all_are_auto_tmm = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
show_seq_dl = true;
|
var show_seq_dl = true;
|
||||||
|
|
||||||
if (!all_are_seq_dl && there_are_seq_dl)
|
if (!all_are_seq_dl && there_are_seq_dl)
|
||||||
show_seq_dl = false;
|
show_seq_dl = false;
|
||||||
|
|
||||||
show_f_l_piece_prio = true;
|
var show_f_l_piece_prio = true;
|
||||||
|
|
||||||
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
|
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
|
||||||
show_f_l_piece_prio = false;
|
show_f_l_piece_prio = false;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getSavePath = function() {
|
getSavePath = function() {
|
||||||
var req = new Request({
|
new Request({
|
||||||
url: 'api/v2/app/defaultSavePath',
|
url: 'api/v2/app/defaultSavePath',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
noCache: true,
|
noCache: true,
|
||||||
|
@ -370,7 +370,7 @@ var DynamicTable = new Class({
|
|||||||
columnsOrder.push(v);
|
columnsOrder.push(v);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
for (i = 0; i < this.columns.length; ++i)
|
for (var i = 0; i < this.columns.length; ++i)
|
||||||
if (!columnsOrder.contains(this.columns[i].name))
|
if (!columnsOrder.contains(this.columns[i].name))
|
||||||
columnsOrder.push(this.columns[i].name);
|
columnsOrder.push(this.columns[i].name);
|
||||||
|
|
||||||
@ -379,8 +379,8 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
saveColumnsOrder: function() {
|
saveColumnsOrder: function() {
|
||||||
val = '';
|
var val = '';
|
||||||
for (i = 0; i < this.columns.length; ++i) {
|
for (var i = 0; i < this.columns.length; ++i) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
val += ',';
|
val += ',';
|
||||||
val += this.columns[i].name;
|
val += this.columns[i].name;
|
||||||
@ -397,7 +397,7 @@ var DynamicTable = new Class({
|
|||||||
var ths = header.getElements('th');
|
var ths = header.getElements('th');
|
||||||
|
|
||||||
for (var i = 0; i < ths.length; ++i) {
|
for (var i = 0; i < ths.length; ++i) {
|
||||||
th = ths[i];
|
var th = ths[i];
|
||||||
th._this = this;
|
th._this = this;
|
||||||
th.setAttribute('title', this.columns[i].caption);
|
th.setAttribute('title', this.columns[i].caption);
|
||||||
th.innerHTML = this.columns[i].caption;
|
th.innerHTML = this.columns[i].caption;
|
||||||
@ -579,14 +579,14 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
var rows = this.rows.getValues();
|
var rows = this.rows.getValues();
|
||||||
|
|
||||||
for (i = 0; i < rows.length; ++i) {
|
for (var i = 0; i < rows.length; ++i) {
|
||||||
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];
|
||||||
res = column.compareRows(row1, row2);
|
var res = column.compareRows(row1, row2);
|
||||||
if (this.reverseSort == '0')
|
if (this.reverseSort == '0')
|
||||||
return res;
|
return res;
|
||||||
else
|
else
|
||||||
@ -596,7 +596,7 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTrByRowId: function(rowId) {
|
getTrByRowId: function(rowId) {
|
||||||
trs = this.tableBody.getElements('tr');
|
var trs = this.tableBody.getElements('tr');
|
||||||
for (var i = 0; i < trs.length; ++i)
|
for (var i = 0; i < trs.length; ++i)
|
||||||
if (trs[i].rowId == rowId)
|
if (trs[i].rowId == rowId)
|
||||||
return trs[i];
|
return trs[i];
|
||||||
@ -619,7 +619,7 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
for (var rowPos = 0; rowPos < rows.length; ++rowPos) {
|
for (var rowPos = 0; rowPos < rows.length; ++rowPos) {
|
||||||
var rowId = rows[rowPos]['rowId'];
|
var rowId = rows[rowPos]['rowId'];
|
||||||
tr_found = false;
|
var tr_found = false;
|
||||||
for (var j = rowPos; j < trs.length; ++j)
|
for (var j = rowPos; j < trs.length; ++j)
|
||||||
if (trs[j]['rowId'] == rowId) {
|
if (trs[j]['rowId'] == rowId) {
|
||||||
tr_found = true;
|
tr_found = true;
|
||||||
@ -706,9 +706,9 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
updateRow: function(tr, fullUpdate) {
|
updateRow: function(tr, fullUpdate) {
|
||||||
var row = this.rows.get(tr.rowId);
|
var row = this.rows.get(tr.rowId);
|
||||||
data = row[fullUpdate ? 'full_data' : 'data'];
|
var data = row[fullUpdate ? 'full_data' : 'data'];
|
||||||
|
|
||||||
tds = tr.getElements('td');
|
var tds = tr.getElements('td');
|
||||||
for (var i = 0; i < this.columns.length; ++i) {
|
for (var i = 0; i < this.columns.length; ++i) {
|
||||||
if (data.hasOwnProperty(this.columns[i].dataProperties[0]))
|
if (data.hasOwnProperty(this.columns[i].dataProperties[0]))
|
||||||
this.columns[i].updateTd(tds[i], row);
|
this.columns[i].updateTd(tds[i], row);
|
||||||
@ -1027,7 +1027,7 @@ var TorrentsTable = new Class({
|
|||||||
// eta
|
// eta
|
||||||
this.columns['eta'].updateTd = function(td, row) {
|
this.columns['eta'].updateTd = function(td, row) {
|
||||||
var eta = this.getRowValue(row);
|
var eta = this.getRowValue(row);
|
||||||
td.set('html', friendlyDuration(eta, true));
|
td.set('html', friendlyDuration(eta));
|
||||||
};
|
};
|
||||||
|
|
||||||
// ratio
|
// ratio
|
||||||
@ -1098,7 +1098,7 @@ var TorrentsTable = new Class({
|
|||||||
if (val < 1)
|
if (val < 1)
|
||||||
td.set('html', '∞');
|
td.set('html', '∞');
|
||||||
else
|
else
|
||||||
td.set('html', 'QBT_TR(%1 ago)QBT_TR[CONTEXT=TransferListDelegate]'.replace('%1', friendlyDuration((new Date()) / 1000 - val, true)));
|
td.set('html', 'QBT_TR(%1 ago)QBT_TR[CONTEXT=TransferListDelegate]'.replace('%1', friendlyDuration((new Date()) / 1000 - val)));
|
||||||
};
|
};
|
||||||
|
|
||||||
// time active
|
// time active
|
||||||
@ -1167,7 +1167,7 @@ var TorrentsTable = new Class({
|
|||||||
var cnt = 0;
|
var cnt = 0;
|
||||||
var rows = this.rows.getValues();
|
var rows = this.rows.getValues();
|
||||||
|
|
||||||
for (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)) ++cnt;
|
||||||
return cnt;
|
return cnt;
|
||||||
},
|
},
|
||||||
@ -1176,7 +1176,7 @@ var TorrentsTable = new Class({
|
|||||||
var rowsHashes = [];
|
var rowsHashes = [];
|
||||||
var rows = this.rows.getValues();
|
var rows = this.rows.getValues();
|
||||||
|
|
||||||
for (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))
|
||||||
rowsHashes.push(rows[i]['rowId']);
|
rowsHashes.push(rows[i]['rowId']);
|
||||||
|
|
||||||
@ -1188,7 +1188,7 @@ var TorrentsTable = new Class({
|
|||||||
|
|
||||||
var rows = this.rows.getValues();
|
var rows = this.rows.getValues();
|
||||||
|
|
||||||
for (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)) {
|
||||||
filteredRows.push(rows[i]);
|
filteredRows.push(rows[i]);
|
||||||
filteredRows[rows[i].rowId] = rows[i];
|
filteredRows[rows[i].rowId] = rows[i];
|
||||||
@ -1196,7 +1196,7 @@ var TorrentsTable = new Class({
|
|||||||
|
|
||||||
filteredRows.sort(function(row1, row2) {
|
filteredRows.sort(function(row1, row2) {
|
||||||
var column = this.columns[this.sortedColumn];
|
var column = this.columns[this.sortedColumn];
|
||||||
res = column.compareRows(row1, row2);
|
var res = column.compareRows(row1, row2);
|
||||||
if (this.reverseSort == '0')
|
if (this.reverseSort == '0')
|
||||||
return res;
|
return res;
|
||||||
else
|
else
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
|||||||
* JS counterpart of the function in src/misc.cpp
|
* JS counterpart of the function in src/misc.cpp
|
||||||
*/
|
*/
|
||||||
function friendlyUnit(value, isSpeed) {
|
function friendlyUnit(value, isSpeed) {
|
||||||
units = [
|
var units = [
|
||||||
"QBT_TR(B)QBT_TR[CONTEXT=misc]",
|
"QBT_TR(B)QBT_TR[CONTEXT=misc]",
|
||||||
"QBT_TR(KiB)QBT_TR[CONTEXT=misc]",
|
"QBT_TR(KiB)QBT_TR[CONTEXT=misc]",
|
||||||
"QBT_TR(MiB)QBT_TR[CONTEXT=misc]",
|
"QBT_TR(MiB)QBT_TR[CONTEXT=misc]",
|
||||||
|
@ -23,7 +23,7 @@ if (typeof localStorage == 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLocalStorageItem(name, defaultVal) {
|
function getLocalStorageItem(name, defaultVal) {
|
||||||
val = localStorage.getItem(name);
|
var val = localStorage.getItem(name);
|
||||||
if (val === null || val === undefined)
|
if (val === null || val === undefined)
|
||||||
val = defaultVal;
|
val = defaultVal;
|
||||||
return val;
|
return val;
|
||||||
|
@ -290,7 +290,7 @@ var loadTorrentFilesData = function() {
|
|||||||
current_hash = new_hash;
|
current_hash = new_hash;
|
||||||
}
|
}
|
||||||
var url = new URI('api/v2/torrents/files?hash=' + current_hash);
|
var url = new URI('api/v2/torrents/files?hash=' + current_hash);
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
noCache: true,
|
noCache: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -42,7 +42,7 @@ var loadTorrentData = function() {
|
|||||||
// Display hash
|
// Display hash
|
||||||
$('torrent_hash').set('html', current_hash);
|
$('torrent_hash').set('html', current_hash);
|
||||||
var url = new URI('api/v2/torrents/properties?hash=' + current_hash);
|
var url = new URI('api/v2/torrents/properties?hash=' + current_hash);
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
noCache: true,
|
noCache: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -71,7 +71,7 @@ var loadTrackersData = function() {
|
|||||||
current_hash = new_hash;
|
current_hash = new_hash;
|
||||||
}
|
}
|
||||||
var url = new URI('api/v2/torrents/trackers?hash=' + current_hash);
|
var url = new URI('api/v2/torrents/trackers?hash=' + current_hash);
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
noCache: true,
|
noCache: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -71,7 +71,7 @@ var loadWebSeedsData = function() {
|
|||||||
current_hash = new_hash;
|
current_hash = new_hash;
|
||||||
}
|
}
|
||||||
var url = new URI('api/v2/torrents/webseeds?hash=' + current_hash);
|
var url = new URI('api/v2/torrents/webseeds?hash=' + current_hash);
|
||||||
var request = new Request.JSON({
|
new Request.JSON({
|
||||||
url: url,
|
url: url,
|
||||||
noCache: true,
|
noCache: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
Loading…
Reference in New Issue
Block a user