Browse Source

Fix minor JavaScript defects

adaptive-webui-19844
Thomas Piccirello 6 years ago
parent
commit
1e6942e967
  1. 6
      src/webui/www/private/preferences_content.html
  2. 4
      src/webui/www/private/scripts/client.js
  3. 28
      src/webui/www/private/scripts/contextmenu.js
  4. 2
      src/webui/www/private/scripts/download.js
  5. 32
      src/webui/www/private/scripts/dynamicTable.js
  6. 1659
      src/webui/www/private/scripts/lib/mocha.js
  7. 2
      src/webui/www/private/scripts/misc.js
  8. 2
      src/webui/www/private/scripts/mocha-init.js
  9. 2
      src/webui/www/private/scripts/prop-files.js
  10. 2
      src/webui/www/private/scripts/prop-general.js
  11. 2
      src/webui/www/private/scripts/prop-trackers.js
  12. 2
      src/webui/www/private/scripts/prop-webseeds.js

6
src/webui/www/private/preferences_content.html

@ -760,7 +760,7 @@ @@ -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 @@ @@ -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 @@ @@ -1044,7 +1044,7 @@
}
}
}).send();
}
};
applyPreferences = function() {
var settings = new Hash();

4
src/webui/www/private/scripts/client.js

@ -301,7 +301,7 @@ window.addEvent('load', function() { @@ -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() { @@ -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',

28
src/webui/www/private/scripts/contextmenu.js

@ -245,18 +245,18 @@ var TorrentsTableContextMenu = new Class({ @@ -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({ @@ -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;

2
src/webui/www/private/scripts/download.js

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

32
src/webui/www/private/scripts/dynamicTable.js

@ -370,7 +370,7 @@ var DynamicTable = new Class({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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

1659
src/webui/www/private/scripts/lib/mocha.js

File diff suppressed because it is too large Load Diff

2
src/webui/www/private/scripts/misc.js

@ -2,7 +2,7 @@ @@ -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]",

2
src/webui/www/private/scripts/mocha-init.js

@ -23,7 +23,7 @@ if (typeof localStorage == 'undefined') { @@ -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;

2
src/webui/www/private/scripts/prop-files.js

@ -290,7 +290,7 @@ var loadTorrentFilesData = function() { @@ -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',

2
src/webui/www/private/scripts/prop-general.js

@ -42,7 +42,7 @@ var loadTorrentData = function() { @@ -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',

2
src/webui/www/private/scripts/prop-trackers.js

@ -71,7 +71,7 @@ var loadTrackersData = function() { @@ -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',

2
src/webui/www/private/scripts/prop-webseeds.js

@ -71,7 +71,7 @@ var loadWebSeedsData = function() { @@ -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',

Loading…
Cancel
Save