code refactor
This commit is contained in:
parent
30de305f4d
commit
7df038d2f2
|
@ -5,6 +5,7 @@
|
|||
var tabOrders = ['overview', 'blocks', 'filelist', 'btpeers'];
|
||||
var downloadTaskRefreshPromise = null;
|
||||
var pauseDownloadTaskRefresh = false;
|
||||
var currentRowTriggeredMenu = null;
|
||||
|
||||
var getAvailableOptions = function (status, isBittorrent) {
|
||||
var keys = aria2SettingService.getAvailableTaskOptionKeys(status, isBittorrent);
|
||||
|
@ -308,6 +309,26 @@
|
|||
}, true);
|
||||
};
|
||||
|
||||
$scope.copySelectedRowText = function () {
|
||||
if (!currentRowTriggeredMenu) {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = currentRowTriggeredMenu.find('.setting-key > span').text().trim();
|
||||
var value = "";
|
||||
|
||||
currentRowTriggeredMenu.find('.setting-value > span').each(function (i, element) {
|
||||
if (i > 0) {
|
||||
value += '\n';
|
||||
}
|
||||
|
||||
value += angular.element(element).text().trim();
|
||||
});
|
||||
|
||||
var info = name + ': ' + value;
|
||||
clipboard.copyText(info);
|
||||
};
|
||||
|
||||
if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) {
|
||||
downloadTaskRefreshPromise = $interval(function () {
|
||||
if ($scope.task && ($scope.task.status === 'complete' || $scope.task.status === 'error' || $scope.task.status === 'removed')) {
|
||||
|
@ -326,24 +347,16 @@
|
|||
});
|
||||
|
||||
angular.element('#overview-items .row').contextmenu({
|
||||
target:'#task-overview-contextmenu',
|
||||
onItem: function (context, e) {
|
||||
var name = context.find('.setting-key > span').text().trim();
|
||||
var value = "";
|
||||
|
||||
context.find('.setting-value > span').each(function (i, element) {
|
||||
if (i > 0) {
|
||||
value += '\n';
|
||||
}
|
||||
|
||||
value += angular.element(element).text().trim();
|
||||
});
|
||||
|
||||
var info = name + ': ' + value;
|
||||
clipboard.copyText(info);
|
||||
target: '#task-overview-contextmenu',
|
||||
before: function (e, context) {
|
||||
currentRowTriggeredMenu = context;
|
||||
}
|
||||
});
|
||||
|
||||
angular.element('#task-overview-contextmenu').on('hide.bs.context', function () {
|
||||
currentRowTriggeredMenu = null;
|
||||
});
|
||||
|
||||
$rootScope.loadPromise = refreshDownloadTask(false);
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -342,7 +342,7 @@
|
|||
<div id="task-overview-contextmenu">
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a id="mnu-overview-copy" tabindex="-1" class="mnu-copy pointer-cursor" title="{{'Copy' | translate}}" data-clipboard-text="1">
|
||||
<a id="mnu-overview-copy" tabindex="-1" class="mnu-copy pointer-cursor" title="{{'Copy' | translate}}" ng-click="copySelectedRowText()">
|
||||
<i class="fa fa-copy"></i>
|
||||
<span translate>Copy</span>
|
||||
</a>
|
||||
|
|
Reference in a new issue