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