mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-04 22:52:33 -06:00
Provide v1 and v2 infohashes in UI (#15097)
This commit is contained in:
committed by
GitHub
parent
f6eb29d800
commit
37f227ae74
@@ -1201,10 +1201,14 @@ function setupCopyEventHandler() {
|
||||
switch (trigger.id) {
|
||||
case "copyName":
|
||||
return copyNameFN();
|
||||
case "copyInfohash1":
|
||||
return copyInfohashFN(1);
|
||||
case "copyInfohash2":
|
||||
return copyInfohashFN(2);
|
||||
case "copyMagnetLink":
|
||||
return copyMagnetLinkFN();
|
||||
case "copyHash":
|
||||
return copyHashFN();
|
||||
case "copyID":
|
||||
return copyIdFN();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1383,7 +1383,7 @@ window.qBittorrent.DynamicTable = (function() {
|
||||
tr.addClass("torrentsTableContextMenuTarget");
|
||||
},
|
||||
|
||||
getCurrentTorrentHash: function() {
|
||||
getCurrentTorrentID: function() {
|
||||
return this.getSelectedRowId();
|
||||
},
|
||||
|
||||
|
||||
@@ -84,8 +84,9 @@ let resumeTorrentsByTrackerFN = function() {};
|
||||
let pauseTorrentsByTrackerFN = function() {};
|
||||
let deleteTorrentsByTrackerFN = function() {};
|
||||
let copyNameFN = function() {};
|
||||
let copyInfohashFN = function(policy) {};
|
||||
let copyMagnetLinkFN = function() {};
|
||||
let copyHashFN = function() {};
|
||||
let copyIdFN = function() {};
|
||||
let setQueuePositionFN = function() {};
|
||||
|
||||
const initializeWindows = function() {
|
||||
@@ -905,7 +906,7 @@ const initializeWindows = function() {
|
||||
copyNameFN = function() {
|
||||
const selectedRows = torrentsTable.selectedRowsIds();
|
||||
const names = [];
|
||||
if (selectedRows.length) {
|
||||
if (selectedRows.length > 0) {
|
||||
const rows = torrentsTable.getFilteredAndSortedRows();
|
||||
for (let i = 0; i < selectedRows.length; ++i) {
|
||||
const hash = selectedRows[i];
|
||||
@@ -915,10 +916,35 @@ const initializeWindows = function() {
|
||||
return names.join("\n");
|
||||
};
|
||||
|
||||
copyInfohashFN = function(policy) {
|
||||
const selectedRows = torrentsTable.selectedRowsIds();
|
||||
const infohashes = [];
|
||||
if (selectedRows.length > 0) {
|
||||
const rows = torrentsTable.getFilteredAndSortedRows();
|
||||
switch (policy) {
|
||||
case 1:
|
||||
for (const id of selectedRows) {
|
||||
const infohash = rows[id].full_data.infohash_v1;
|
||||
if (infohash !== "")
|
||||
infohashes.push(infohash);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (const id of selectedRows) {
|
||||
const infohash = rows[id].full_data.infohash_v2;
|
||||
if (infohash !== "")
|
||||
infohashes.push(infohash);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return infohashes.join("\n");
|
||||
};
|
||||
|
||||
copyMagnetLinkFN = function() {
|
||||
const selectedRows = torrentsTable.selectedRowsIds();
|
||||
const magnets = [];
|
||||
if (selectedRows.length) {
|
||||
if (selectedRows.length > 0) {
|
||||
const rows = torrentsTable.getFilteredAndSortedRows();
|
||||
for (let i = 0; i < selectedRows.length; ++i) {
|
||||
const hash = selectedRows[i];
|
||||
@@ -928,7 +954,7 @@ const initializeWindows = function() {
|
||||
return magnets.join("\n");
|
||||
};
|
||||
|
||||
copyHashFN = function() {
|
||||
copyIdFN = function() {
|
||||
return torrentsTable.selectedRowsIds().join("\n");
|
||||
};
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ window.qBittorrent.PropFiles = (function() {
|
||||
// Tab changed, don't do anything
|
||||
return;
|
||||
}
|
||||
const new_hash = torrentsTable.getCurrentTorrentHash();
|
||||
const new_hash = torrentsTable.getCurrentTorrentID();
|
||||
if (new_hash === "") {
|
||||
torrentFilesTable.clear();
|
||||
clearTimeout(loadTorrentFilesDataTimer);
|
||||
@@ -527,7 +527,7 @@ window.qBittorrent.PropFiles = (function() {
|
||||
menu: 'torrentFilesMenu',
|
||||
actions: {
|
||||
Rename: function(element, ref) {
|
||||
const hash = torrentsTable.getCurrentTorrentHash();
|
||||
const hash = torrentsTable.getCurrentTorrentID();
|
||||
if (!hash) return;
|
||||
const rowId = torrentFilesTable.selectedRowsIds()[0];
|
||||
if (rowId === undefined) return;
|
||||
|
||||
@@ -61,7 +61,8 @@ window.qBittorrent.PropGeneral = (function() {
|
||||
$('addition_date').set('html', '');
|
||||
$('completion_date').set('html', '');
|
||||
$('creation_date').set('html', '');
|
||||
$('torrent_hash').set('html', '');
|
||||
$('torrent_hash_v1').set('html', '');
|
||||
$('torrent_hash_v2').set('html', '');
|
||||
$('save_path').set('html', '');
|
||||
$('comment').set('html', '');
|
||||
};
|
||||
@@ -73,16 +74,14 @@ window.qBittorrent.PropGeneral = (function() {
|
||||
// Tab changed, don't do anything
|
||||
return;
|
||||
}
|
||||
const current_hash = torrentsTable.getCurrentTorrentHash();
|
||||
if (current_hash === "") {
|
||||
const current_id = torrentsTable.getCurrentTorrentID();
|
||||
if (current_id === "") {
|
||||
clearData();
|
||||
clearTimeout(loadTorrentDataTimer);
|
||||
loadTorrentDataTimer = loadTorrentData.delay(5000);
|
||||
return;
|
||||
}
|
||||
// Display hash
|
||||
$('torrent_hash').set('html', current_hash);
|
||||
const url = new URI('api/v2/torrents/properties?hash=' + current_hash);
|
||||
const url = new URI('api/v2/torrents/properties?hash=' + current_id);
|
||||
new Request.JSON({
|
||||
url: url,
|
||||
noCache: true,
|
||||
@@ -191,6 +190,18 @@ window.qBittorrent.PropGeneral = (function() {
|
||||
temp = "QBT_TR(Unknown)QBT_TR[CONTEXT=HttpServer]";
|
||||
$('creation_date').set('html', temp);
|
||||
|
||||
if (data.infohash_v1 === "")
|
||||
temp = "QBT_TR(N/A)QBT_TR[CONTEXT=PropertiesWidget]";
|
||||
else
|
||||
temp = data.infohash_v1;
|
||||
$('torrent_hash_v1').set('html', temp);
|
||||
|
||||
if (data.infohash_v2 === "")
|
||||
temp = "QBT_TR(N/A)QBT_TR[CONTEXT=PropertiesWidget]";
|
||||
else
|
||||
temp = data.infohash_v2;
|
||||
$('torrent_hash_v2').set('html', temp);
|
||||
|
||||
$('save_path').set('html', data.save_path);
|
||||
|
||||
$('comment').set('html', window.qBittorrent.Misc.parseHtmlLinks(window.qBittorrent.Misc.escapeHtml(data.comment)));
|
||||
|
||||
@@ -51,7 +51,7 @@ window.qBittorrent.PropPeers = (function() {
|
||||
torrentPeersTable.clear();
|
||||
return;
|
||||
}
|
||||
const current_hash = torrentsTable.getCurrentTorrentHash();
|
||||
const current_hash = torrentsTable.getCurrentTorrentID();
|
||||
if (current_hash === "") {
|
||||
syncTorrentPeersLastResponseId = 0;
|
||||
torrentPeersTable.clear();
|
||||
@@ -118,7 +118,7 @@ window.qBittorrent.PropPeers = (function() {
|
||||
menu: 'torrentPeersMenu',
|
||||
actions: {
|
||||
addPeer: function(element, ref) {
|
||||
const hash = torrentsTable.getCurrentTorrentHash();
|
||||
const hash = torrentsTable.getCurrentTorrentID();
|
||||
if (!hash)
|
||||
return;
|
||||
|
||||
@@ -147,7 +147,7 @@ window.qBittorrent.PropPeers = (function() {
|
||||
noCache: true,
|
||||
method: 'post',
|
||||
data: {
|
||||
hash: torrentsTable.getCurrentTorrentHash(),
|
||||
hash: torrentsTable.getCurrentTorrentID(),
|
||||
peers: selectedPeers.join('|')
|
||||
}
|
||||
}).send();
|
||||
|
||||
@@ -50,7 +50,7 @@ window.qBittorrent.PropTrackers = (function() {
|
||||
// Tab changed, don't do anything
|
||||
return;
|
||||
}
|
||||
const new_hash = torrentsTable.getCurrentTorrentHash();
|
||||
const new_hash = torrentsTable.getCurrentTorrentID();
|
||||
if (new_hash === "") {
|
||||
torrentTrackersTable.clear();
|
||||
clearTimeout(loadTrackersDataTimer);
|
||||
|
||||
@@ -100,7 +100,7 @@ window.qBittorrent.PropWebseeds = (function() {
|
||||
// Tab changed, don't do anything
|
||||
return;
|
||||
}
|
||||
const new_hash = torrentsTable.getCurrentTorrentHash();
|
||||
const new_hash = torrentsTable.getCurrentTorrentID();
|
||||
if (new_hash === "") {
|
||||
wsTable.removeAllRows();
|
||||
clearTimeout(loadWebSeedsDataTimer);
|
||||
|
||||
Reference in New Issue
Block a user