Fix minor JavaScript defects

This commit is contained in:
Thomas Piccirello 2018-09-26 23:10:51 -04:00
parent 08df3277df
commit 1e6942e967
12 changed files with 871 additions and 872 deletions

View File

@ -760,7 +760,7 @@
};
time_padding = function(val) {
ret = val.toString();
var ret = val.toString();
if (ret.length == 1)
ret = '0' + ret;
return ret;
@ -768,7 +768,7 @@
loadPreferences = function() {
var url = 'api/v2/app/preferences';
var request = new Request.JSON({
new Request.JSON({
url: url,
method: 'get',
noCache: true,
@ -1044,7 +1044,7 @@
}
}
}).send();
}
};
applyPreferences = function() {
var settings = new Hash();

View File

@ -301,7 +301,7 @@ window.addEvent('load', function() {
var syncMainData = function() {
var url = new URI('api/v2/sync/maindata');
url.setData('rid', syncMainDataLastResponseId);
var request = new Request.JSON({
new Request.JSON({
url: url,
noCache: true,
method: 'get',
@ -727,7 +727,7 @@ var loadTorrentPeersData = function() {
var url = new URI('api/v2/sync/torrentPeers');
url.setData('rid', syncTorrentPeersLastResponseId);
url.setData('hash', current_hash);
var request = new Request.JSON({
new Request.JSON({
url: url,
noCache: true,
method: 'get',

View File

@ -245,18 +245,18 @@ var TorrentsTableContextMenu = new Class({
Extends: ContextMenu,
updateMenuItems: function() {
all_are_seq_dl = true;
there_are_seq_dl = false;
all_are_f_l_piece_prio = true;
there_are_f_l_piece_prio = false;
all_are_downloaded = true;
all_are_paused = true;
there_are_paused = false;
all_are_force_start = true;
there_are_force_start = false;
all_are_super_seeding = true;
all_are_auto_tmm = true;
there_are_auto_tmm = false;
var all_are_seq_dl = true;
var there_are_seq_dl = false;
var all_are_f_l_piece_prio = true;
var there_are_f_l_piece_prio = false;
var all_are_downloaded = true;
var all_are_paused = true;
var there_are_paused = false;
var all_are_force_start = true;
var there_are_force_start = false;
var all_are_super_seeding = true;
var all_are_auto_tmm = true;
var there_are_auto_tmm = false;
var h = torrentsTable.selectedRowsIds();
h.each(function(item, index) {
@ -293,12 +293,12 @@ var TorrentsTableContextMenu = new Class({
all_are_auto_tmm = false;
});
show_seq_dl = true;
var show_seq_dl = true;
if (!all_are_seq_dl && there_are_seq_dl)
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)
show_f_l_piece_prio = false;

View File

@ -22,7 +22,7 @@
*/
getSavePath = function() {
var req = new Request({
new Request({
url: 'api/v2/app/defaultSavePath',
method: 'get',
noCache: true,

View File

@ -370,7 +370,7 @@ var DynamicTable = new Class({
columnsOrder.push(v);
}.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))
columnsOrder.push(this.columns[i].name);
@ -379,8 +379,8 @@ var DynamicTable = new Class({
},
saveColumnsOrder: function() {
val = '';
for (i = 0; i < this.columns.length; ++i) {
var val = '';
for (var i = 0; i < this.columns.length; ++i) {
if (i > 0)
val += ',';
val += this.columns[i].name;
@ -397,7 +397,7 @@ var DynamicTable = new Class({
var ths = header.getElements('th');
for (var i = 0; i < ths.length; ++i) {
th = ths[i];
var th = ths[i];
th._this = this;
th.setAttribute('title', this.columns[i].caption);
th.innerHTML = this.columns[i].caption;
@ -579,14 +579,14 @@ var DynamicTable = new Class({
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[rows[i].rowId] = rows[i];
}
filteredRows.sort(function(row1, row2) {
var column = this.columns[this.sortedColumn];
res = column.compareRows(row1, row2);
var res = column.compareRows(row1, row2);
if (this.reverseSort == '0')
return res;
else
@ -596,7 +596,7 @@ var DynamicTable = new Class({
},
getTrByRowId: function(rowId) {
trs = this.tableBody.getElements('tr');
var trs = this.tableBody.getElements('tr');
for (var i = 0; i < trs.length; ++i)
if (trs[i].rowId == rowId)
return trs[i];
@ -619,7 +619,7 @@ var DynamicTable = new Class({
for (var rowPos = 0; rowPos < rows.length; ++rowPos) {
var rowId = rows[rowPos]['rowId'];
tr_found = false;
var tr_found = false;
for (var j = rowPos; j < trs.length; ++j)
if (trs[j]['rowId'] == rowId) {
tr_found = true;
@ -706,9 +706,9 @@ var DynamicTable = new Class({
updateRow: function(tr, fullUpdate) {
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) {
if (data.hasOwnProperty(this.columns[i].dataProperties[0]))
this.columns[i].updateTd(tds[i], row);
@ -1027,7 +1027,7 @@ var TorrentsTable = new Class({
// eta
this.columns['eta'].updateTd = function(td, row) {
var eta = this.getRowValue(row);
td.set('html', friendlyDuration(eta, true));
td.set('html', friendlyDuration(eta));
};
// ratio
@ -1098,7 +1098,7 @@ var TorrentsTable = new Class({
if (val < 1)
td.set('html', '∞');
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
@ -1167,7 +1167,7 @@ var TorrentsTable = new Class({
var cnt = 0;
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;
return cnt;
},
@ -1176,7 +1176,7 @@ var TorrentsTable = new Class({
var rowsHashes = [];
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))
rowsHashes.push(rows[i]['rowId']);
@ -1188,7 +1188,7 @@ var TorrentsTable = new Class({
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)) {
filteredRows.push(rows[i]);
filteredRows[rows[i].rowId] = rows[i];
@ -1196,7 +1196,7 @@ var TorrentsTable = new Class({
filteredRows.sort(function(row1, row2) {
var column = this.columns[this.sortedColumn];
res = column.compareRows(row1, row2);
var res = column.compareRows(row1, row2);
if (this.reverseSort == '0')
return res;
else

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
* JS counterpart of the function in src/misc.cpp
*/
function friendlyUnit(value, isSpeed) {
units = [
var units = [
"QBT_TR(B)QBT_TR[CONTEXT=misc]",
"QBT_TR(KiB)QBT_TR[CONTEXT=misc]",
"QBT_TR(MiB)QBT_TR[CONTEXT=misc]",

View File

@ -23,7 +23,7 @@ if (typeof localStorage == 'undefined') {
}
function getLocalStorageItem(name, defaultVal) {
val = localStorage.getItem(name);
var val = localStorage.getItem(name);
if (val === null || val === undefined)
val = defaultVal;
return val;

View File

@ -290,7 +290,7 @@ var loadTorrentFilesData = function() {
current_hash = new_hash;
}
var url = new URI('api/v2/torrents/files?hash=' + current_hash);
var request = new Request.JSON({
new Request.JSON({
url: url,
noCache: true,
method: 'get',

View File

@ -42,7 +42,7 @@ var loadTorrentData = function() {
// Display hash
$('torrent_hash').set('html', current_hash);
var url = new URI('api/v2/torrents/properties?hash=' + current_hash);
var request = new Request.JSON({
new Request.JSON({
url: url,
noCache: true,
method: 'get',

View File

@ -71,7 +71,7 @@ var loadTrackersData = function() {
current_hash = new_hash;
}
var url = new URI('api/v2/torrents/trackers?hash=' + current_hash);
var request = new Request.JSON({
new Request.JSON({
url: url,
noCache: true,
method: 'get',

View File

@ -71,7 +71,7 @@ var loadWebSeedsData = function() {
current_hash = new_hash;
}
var url = new URI('api/v2/torrents/webseeds?hash=' + current_hash);
var request = new Request.JSON({
new Request.JSON({
url: url,
noCache: true,
method: 'get',