Skip to content

Commit

Permalink
add copy magnet link in task list page
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Mar 27, 2019
1 parent c2a3252 commit a9e47bc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/langs/zh_Hans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Select None=全部不选
Select Invert=反向选择
Display Order=显示顺序
Copy Download Url=复制下载链接
Copy Magnet Link=复制磁力链接
Help=帮助
Search=搜索
Default=默认
Expand Down
1 change: 1 addition & 0 deletions src/langs/zh_Hant.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Select None=全部不選
Select Invert=反向選擇
Display Order=顯示順序
Copy Download Url=複製下載連結
Copy Magnet Link=複製磁力連結
Help=說明
Search=搜尋
Default=預設
Expand Down
1 change: 1 addition & 0 deletions src/scripts/config/defaultLanguage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'Select Invert': 'Select Invert',
'Display Order': 'Display Order',
'Copy Download Url': 'Copy Download Url',
'Copy Magnet Link': 'Copy Magnet Link',
'Help': 'Help',
'Search': 'Search',
'Default': 'Default',
Expand Down
30 changes: 24 additions & 6 deletions src/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,23 @@
};

$scope.isSingleUrlTaskSelected = function () {
var selectedTask = $rootScope.taskContext.getSelectedTasks();
var selectedTasks = $rootScope.taskContext.getSelectedTasks();

if (selectedTasks.length !== 1) {
return false;
}

return !!selectedTasks[0].singleUrl;
};

$scope.isSingleBittorrentHasInfoHashTaskSelected = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();

if (selectedTask.length !== 1) {
if (selectedTasks.length !== 1) {
return false;
}

return !!selectedTask[0].singleUrl;
return !!selectedTasks[0].bittorrent && !!selectedTasks[0].infoHash;
};

$scope.isSpecifiedTaskSelected = function () {
Expand Down Expand Up @@ -313,10 +323,18 @@
};

$scope.copySelectedOneTaskDownloadLink = function () {
var selectedTask = $rootScope.taskContext.getSelectedTasks();
var selectedTasks = $rootScope.taskContext.getSelectedTasks();

if (selectedTasks.length === 1) {
clipboard.copyText(selectedTasks[0].singleUrl);
}
};

$scope.copySelectedOneTaskMagnetLink = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();

if (selectedTask.length === 1) {
clipboard.copyText(selectedTask[0].singleUrl);
if (selectedTasks.length === 1) {
clipboard.copyText('magnet:?xt=urn:btih:' + selectedTasks[0].infoHash);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/scripts/services/aria2RpcService.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@

requestParams.push('files');
requestParams.push('bittorrent');
requestParams.push('infoHash');

return requestParams;
},
Expand Down
8 changes: 7 additions & 1 deletion src/views/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,19 @@
<span translate>Select All</span>
</a>
</li>
<li class="divider" ng-if="isSingleUrlTaskSelected()"></li>
<li class="divider" ng-if="isSingleUrlTaskSelected() || isSingleBittorrentHasInfoHashTaskSelected()"></li>
<li ng-if="isSingleUrlTaskSelected()">
<a tabindex="-1" class="pointer-cursor" title="{{'Copy Download Url' | translate}}" ng-click="copySelectedOneTaskDownloadLink()">
<i class="fa fa-copy fa-fw"></i>
<span translate>Copy Download Url</span>
</a>
</li>
<li ng-if="isSingleBittorrentHasInfoHashTaskSelected()">
<a tabindex="-1" class="pointer-cursor" title="{{'Copy Magnet Link' | translate}}" ng-click="copySelectedOneTaskMagnetLink()">
<i class="fa fa-copy fa-fw"></i>
<span translate>Copy Magnet Link</span>
</a>
</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit a9e47bc

Please sign in to comment.