code refactor

This commit is contained in:
MaysWind 2018-02-21 11:09:46 +08:00
parent 30de305f4d
commit 7df038d2f2
2 changed files with 29 additions and 16 deletions

View file

@ -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,22 +347,14 @@
});
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';
target: '#task-overview-contextmenu',
before: function (e, context) {
currentRowTriggeredMenu = context;
}
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);

View file

@ -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>