refactor code
This commit is contained in:
parent
d231f59de0
commit
9f4a723b28
|
@ -62,37 +62,37 @@
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('default:false')">
|
<a class="pointer-cursor" ng-click="changeDisplayOrder('default:asc')">
|
||||||
<span translate>Default</span>
|
<span translate>Default</span>
|
||||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('default')}"></i>
|
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('default')}"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('name:false')">
|
<a class="pointer-cursor" ng-click="changeDisplayOrder('name:asc')">
|
||||||
<span translate>By File Name</span>
|
<span translate>By File Name</span>
|
||||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('name')}"></i>
|
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('name')}"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('size:false')">
|
<a class="pointer-cursor" ng-click="changeDisplayOrder('size:asc')">
|
||||||
<span translate>By File Size</span>
|
<span translate>By File Size</span>
|
||||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('size')}"></i>
|
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('size')}"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('percent:true')">
|
<a class="pointer-cursor" ng-click="changeDisplayOrder('percent:desc')">
|
||||||
<span translate>By Completed Percent</span>
|
<span translate>By Completed Percent</span>
|
||||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('percent')}"></i>
|
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('percent')}"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('remain:false')">
|
<a class="pointer-cursor" ng-click="changeDisplayOrder('remain:asc')">
|
||||||
<span translate>By Remain Time</span>
|
<span translate>By Remain Time</span>
|
||||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('remain')}"></i>
|
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('remain')}"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('dspeed:true')">
|
<a class="pointer-cursor" ng-click="changeDisplayOrder('dspeed:desc')">
|
||||||
<span translate>By Download Speed</span>
|
<span translate>By Download Speed</span>
|
||||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('dspeed')}"></i>
|
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('dspeed')}"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -37,14 +37,11 @@
|
||||||
ariaNgSettingService.setDisplayOrder(newType.getValue());
|
ariaNgSettingService.setDisplayOrder(newType.getValue());
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.isSetDisplayOrder = function (type, reverse) {
|
$scope.isSetDisplayOrder = function (type) {
|
||||||
var orderType = utils.parseOrderType(ariaNgSettingService.getDisplayOrder());
|
var orderType = utils.parseOrderType(ariaNgSettingService.getDisplayOrder());
|
||||||
|
var targetType = utils.parseOrderType(type);
|
||||||
|
|
||||||
if (angular.isUndefined(reverse)) {
|
return orderType.equals(targetType);
|
||||||
return orderType.type === type;
|
|
||||||
} else {
|
|
||||||
return orderType.type === type && orderType.reverse === reverse;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ariaNgSettingService.getGlobalStatRefreshInterval() > 0) {
|
if (ariaNgSettingService.getGlobalStatRefreshInterval() > 0) {
|
||||||
|
|
|
@ -81,16 +81,13 @@
|
||||||
ariaNgSettingService.setFileListDisplayOrder(newType.getValue());
|
ariaNgSettingService.setFileListDisplayOrder(newType.getValue());
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.isSetFileListDisplayOrder = function (type, reverse) {
|
$scope.isSetFileListDisplayOrder = function (type) {
|
||||||
var orderType = utils.parseOrderType(ariaNgSettingService.getFileListDisplayOrder());
|
var orderType = utils.parseOrderType(ariaNgSettingService.getFileListDisplayOrder());
|
||||||
|
var targetType = utils.parseOrderType(type);
|
||||||
|
|
||||||
if (angular.isUndefined(reverse)) {
|
return orderType.equals(targetType);
|
||||||
return orderType.type === type;
|
|
||||||
} else {
|
|
||||||
return orderType.type === type && orderType.reverse === reverse;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getFileListOrderType = function () {
|
$scope.getFileListOrderType = function () {
|
||||||
return ariaNgSettingService.getFileListDisplayOrder();
|
return ariaNgSettingService.getFileListDisplayOrder();
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,13 +150,31 @@
|
||||||
parseOrderType: function (value) {
|
parseOrderType: function (value) {
|
||||||
var values = value.split(':');
|
var values = value.split(':');
|
||||||
|
|
||||||
return {
|
var obj = {
|
||||||
type: values[0],
|
type: values[0],
|
||||||
reverse: values[1] === 'true',
|
order: values[1],
|
||||||
|
equals: function (obj) {
|
||||||
|
if (angular.isUndefined(obj.order)) {
|
||||||
|
return this.type === obj.type;
|
||||||
|
} else {
|
||||||
|
return this.type === obj.type && this.order === obj.order;
|
||||||
|
}
|
||||||
|
},
|
||||||
getValue: function () {
|
getValue: function () {
|
||||||
return this.type + ":" + this.reverse.toString();
|
return this.type + ":" + this.order;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Object.defineProperty(obj, 'reverse', {
|
||||||
|
get: function () {
|
||||||
|
return this.order === 'desc';
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this.order = (value ? 'desc' : 'asc');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return obj;
|
||||||
},
|
},
|
||||||
estimateCompletedPercentFromBitField: function (bitfield) {
|
estimateCompletedPercentFromBitField: function (bitfield) {
|
||||||
var totalLength = bitfield.length * 0xf;
|
var totalLength = bitfield.length * 0xf;
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
var value = getOption('displayOrder');
|
var value = getOption('displayOrder');
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
value = 'default:false';
|
value = 'default:asc';
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
var value = getOption('fileListDisplayOrder');
|
var value = getOption('fileListDisplayOrder');
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
value = 'default:false';
|
value = 'default:asc';
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -5,31 +5,31 @@
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<a ng-click="changeDisplayOrder('name:false', true)" translate>File Name</a>
|
<a ng-click="changeDisplayOrder('name:asc', true)" translate>File Name</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('name', false), 'fa-sort-desc': isSetDisplayOrder('name', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('name:asc'), 'fa-sort-desc': isSetDisplayOrder('name:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<a ng-click="changeDisplayOrder('size:false', true)" translate>File Size</a>
|
<a ng-click="changeDisplayOrder('size:asc', true)" translate>File Size</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('size', false), 'fa-sort-desc': isSetDisplayOrder('size', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('size:asc'), 'fa-sort-desc': isSetDisplayOrder('size:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<a ng-click="changeDisplayOrder('percent:true', true)" translate>Completed Percent</a>
|
<a ng-click="changeDisplayOrder('percent:desc', true)" translate>Completed Percent</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('percent', false), 'fa-sort-desc': isSetDisplayOrder('percent', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('percent:asc'), 'fa-sort-desc': isSetDisplayOrder('percent:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<a ng-click="changeDisplayOrder('remain:false', true)" translate>Remain Time</a>
|
<a ng-click="changeDisplayOrder('remain:asc', true)" translate>Remain Time</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('remain', false), 'fa-sort-desc': isSetDisplayOrder('remain', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('remain:asc'), 'fa-sort-desc': isSetDisplayOrder('remain:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a ng-click="changeDisplayOrder('dspeed:true', true)" translate>Download Speed</a>
|
<a ng-click="changeDisplayOrder('dspeed:desc', true)" translate>Download Speed</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('dspeed', false), 'fa-sort-desc': isSetDisplayOrder('dspeed', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('dspeed:asc'), 'fa-sort-desc': isSetDisplayOrder('dspeed:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -117,16 +117,16 @@
|
||||||
<div class="task-table-title hidden-xs">
|
<div class="task-table-title hidden-xs">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<a ng-click="changeFileListDisplayOrder('name:false', true)" translate>File Name</a>
|
<a ng-click="changeFileListDisplayOrder('name:asc', true)" translate>File Name</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('name', false), 'fa-sort-desc': isSetFileListDisplayOrder('name', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('name:asc'), 'fa-sort-desc': isSetFileListDisplayOrder('name:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<a ng-click="changeFileListDisplayOrder('percent:true', true)" translate>Completed Percent</a>
|
<a ng-click="changeFileListDisplayOrder('percent:desc', true)" translate>Completed Percent</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('percent', false), 'fa-sort-desc': isSetFileListDisplayOrder('percent', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('percent:asc'), 'fa-sort-desc': isSetFileListDisplayOrder('percent:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<a ng-click="changeFileListDisplayOrder('size:false', true)" translate>File Size</a>
|
<a ng-click="changeFileListDisplayOrder('size:asc', true)" translate>File Size</a>
|
||||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('size', false), 'fa-sort-desc': isSetFileListDisplayOrder('size', true)}"></i>
|
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('size:asc'), 'fa-sort-desc': isSetFileListDisplayOrder('size:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue