Skip to content

Commit

Permalink
Add "Open in Torrent Client" Button
Browse files Browse the repository at this point in the history
  • Loading branch information
leoherzog authored Jan 14, 2023
1 parent 8d81259 commit ddb4a7d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
6 changes: 6 additions & 0 deletions bin/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -62552,10 +62552,13 @@ var removeWebseeds = document.getElementById('removeWebseeds');
var pieces = document.getElementById('pieces');
var files = document.getElementById('filesBody');
var getFiles = document.getElementById('getFiles');
var openURLWrapper = document.getElementById('openURLWrapper');
var openURL = document.getElementById('openURL');
var copyURL = document.getElementById('copyURL');
var copyMagnet = document.getElementById('copyMagnet');
var downloadTorrentWrapper = document.getElementById('downloadTorrentWrapper');
var downloadTorrent = document.getElementById('downloadTorrent');
var openURLTooltip = tippy(openURL, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Open this Magnet URL in your Torrent client"});
var copyURLTooltip = tippy(copyURL, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Copy torrent.parts link to clipboard"});
var copyMagnetTooltip = tippy(copyMagnet, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Copy Magnet link to clipboard"});
var downloadTorrentTooltip = tippy(downloadTorrentWrapper, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Download Torrent file"});
Expand Down Expand Up @@ -62585,10 +62588,12 @@ var notyf = new Notyf({

function placeDownloadTooltips(e) {
if (window.innerWidth > 1080) {
openURLTooltip.setProps({"placement": "right"});
copyURLTooltip.setProps({"placement": "right"});
copyMagnetTooltip.setProps({"placement": "right"});
downloadTorrentTooltip.setProps({"placement": "right"});
} else {
openURLTooltip.setProps({"placement": "top"});
copyURLTooltip.setProps({"placement": "top"});
copyMagnetTooltip.setProps({"placement": "top"});
downloadTorrentTooltip.setProps({"placement": "top"});
Expand Down Expand Up @@ -62841,6 +62846,7 @@ function display() {
files.appendChild(createFileRow('', '...and another ' + (parsed.files.length - 100) + ' more files', ''));
}
files.appendChild(createFileRow('folder-tree', '', parsed.length));
openURLWrapper.href = parser.toMagnetURI(parsed);
downloadTorrentTooltip.setContent('Download Torrent file');
downloadTorrent.addEventListener('click', saveTorrent);
downloadTorrent.disabled = false;
Expand Down
2 changes: 1 addition & 1 deletion bin/bundle.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions ext/TorrentPartsFASubset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
projectName: 'C:\Users\Leo\Desktop\TorrentPartsFASubset'
version: 6.1.2
version: 6.2.1
icons:
- magnet:
- light
Expand All @@ -13,11 +13,12 @@ icons:
- solid
- link:
- light
- duotone
- share-nodes:
- solid
- duotone
- file-arrow-down:
- solid
- arrow-up-right-from-square:
- solid
- file:
- regular
- file-word:
Expand Down
6 changes: 3 additions & 3 deletions ext/fa.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ <h1 id="logo">Torrent<span id="originalSourceIcon"><span class="fad fa-magnet fa
</button>

<div id="share">
<a id="openURLWrapper" target="_blank">
<button id="openURL" aria-label="Open this Magnet URL in your Torrent client">
<span class="fas fa-arrow-up-right-from-square fa-2x"></span>
</button>
</a>
<div>
<button id="copyURL" aria-label="Copy this torrent.parts link to the clipboard">
<span class="fas fa-share-alt fa-2x" data-fa-transform="left-1"></span>
<span class="fas fa-link fa-2x"></span>
</button>
</div>
<div>
Expand Down
6 changes: 6 additions & 0 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ var removeWebseeds = document.getElementById('removeWebseeds');
var pieces = document.getElementById('pieces');
var files = document.getElementById('filesBody');
var getFiles = document.getElementById('getFiles');
var openURLWrapper = document.getElementById('openURLWrapper');
var openURL = document.getElementById('openURL');
var copyURL = document.getElementById('copyURL');
var copyMagnet = document.getElementById('copyMagnet');
var downloadTorrentWrapper = document.getElementById('downloadTorrentWrapper');
var downloadTorrent = document.getElementById('downloadTorrent');
var openURLTooltip = tippy(openURL, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Open this Magnet URL in your Torrent client"});
var copyURLTooltip = tippy(copyURL, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Copy torrent.parts link to clipboard"});
var copyMagnetTooltip = tippy(copyMagnet, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Copy Magnet link to clipboard"});
var downloadTorrentTooltip = tippy(downloadTorrentWrapper, {"theme": "torrent-parts", "animation": "shift-away-subtle", "content": "Download Torrent file"});
Expand Down Expand Up @@ -63,10 +66,12 @@ var notyf = new Notyf({

function placeDownloadTooltips(e) {
if (window.innerWidth > 1080) {
openURLTooltip.setProps({"placement": "right"});
copyURLTooltip.setProps({"placement": "right"});
copyMagnetTooltip.setProps({"placement": "right"});
downloadTorrentTooltip.setProps({"placement": "right"});
} else {
openURLTooltip.setProps({"placement": "top"});
copyURLTooltip.setProps({"placement": "top"});
copyMagnetTooltip.setProps({"placement": "top"});
downloadTorrentTooltip.setProps({"placement": "top"});
Expand Down Expand Up @@ -319,6 +324,7 @@ function display() {
files.appendChild(createFileRow('', '...and another ' + (parsed.files.length - 100) + ' more files', ''));
}
files.appendChild(createFileRow('folder-tree', '', parsed.length));
openURLWrapper.href = parser.toMagnetURI(parsed);
downloadTorrentTooltip.setContent('Download Torrent file');
downloadTorrent.addEventListener('click', saveTorrent);
downloadTorrent.disabled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ label[for="torrent"] {
flex-direction: column;
}

#share > div > button {
#share > * > button {
width: 64px;
height: 64px;
border-radius: 50%;
Expand Down

0 comments on commit ddb4a7d

Please sign in to comment.