code refactor

This commit is contained in:
MaysWind 2018-05-20 23:09:59 +08:00
parent 373ead126a
commit c47505bcbf
6 changed files with 33 additions and 33 deletions

View file

@ -61,7 +61,7 @@
var unitIndex = 0;
for (var i = 0; i < sizeUnits.length; i++) {
if ((size < 1024) || (size % 1024 != 0)) {
if ((size < 1024) || (size % 1024 !== 0)) {
break;
}

View file

@ -485,7 +485,7 @@
options = response.data[1][0];
}
if (!task || !options || !task.files || task.files.length != 1 || task.bittorrent) {
if (!task || !options || !task.files || task.files.length !== 1 || task.bittorrent) {
if (!task) {
ariaNgLogService.warn('[aria2TaskService.restartTask] task is null');
}

View file

@ -47,14 +47,14 @@
<span ng-bind="task.totalLength | readableVolume"></span>
<a ng-href="#!/task/detail/{{task.gid}}" title="{{'Click to view task detail' | translate}}">
<span ng-if="task.files" ng-bind="('format.settings.file-count' | translate: {count: task.selectedFileCount})"></span>
</a><i class="icon-error fa fa-times" ng-if="task && task.status == 'error' && task.errorDescription" title="{{task.errorDescription | translate}}"></i><i class="icon-seeder fa fa-arrow-up" ng-if="task && task.status == 'active' && task.seeder" title="{{'Seeding' | translate}}"></i>
<a ng-if="task && task.status == 'error' && task.errorDescription && !task.bittorrent" ng-click="restart(task)" title="{{'Restart' | translate}}" translate>Restart</a>
</a><i class="icon-error fa fa-times" ng-if="task && task.status === 'error' && task.errorDescription" title="{{task.errorDescription | translate}}"></i><i class="icon-seeder fa fa-arrow-up" ng-if="task && task.status === 'active' && task.seeder" title="{{'Seeding' | translate}}"></i>
<a ng-if="task && task.status === 'error' && task.errorDescription && !task.bittorrent" ng-click="restart(task)" title="{{'Restart' | translate}}" translate>Restart</a>
</div>
</div>
<div class="col-md-2 col-sm-3 col-xs-12">
<div class="progress">
<div class="progress-bar" role="progressbar"
ng-class="{'progress-bar-primary': task.status != 'error', 'progress-bar-warning': task.status == 'error'}"
ng-class="{'progress-bar-primary': task.status !== 'error', 'progress-bar-warning': task.status === 'error'}"
aria-valuenow="{{task.completePercent}}" aria-valuemin="1"
aria-valuemax="100" ng-style="{ width: task.completePercent + '%' }">
<span ng-class="{'progress-lower': task.completePercent < 50}"

View file

@ -2,10 +2,10 @@
<form name="newTaskForm" ng-submit="startDownload()" novalidate>
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li ng-class="{'active': context.currentTab == 'links'}">
<li ng-class="{'active': context.currentTab === 'links'}">
<a class="pointer-cursor" ng-click="changeTab('links')" ng-bind="(context.taskType === 'torrent' ? 'Torrent File' : (context.taskType === 'metalink' ? 'Metalink File' : 'Links') | translate)">Links</a>
</li>
<li ng-class="{'active': context.currentTab == 'options'}">
<li ng-class="{'active': context.currentTab === 'options'}">
<a class="pointer-cursor" ng-click="changeTab('options')" translate>Options</a>
</li>
<li class="divider"></li>
@ -37,7 +37,7 @@
</ul>
<div class="tab-content no-padding">
<div class="tab-pane" ng-class="{'active': context.currentTab == 'links'}">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'links'}">
<div class="new-task-table" ng-if="context.taskType === 'urls'">
<div class="row">
<div class="col-sm-12">
@ -63,7 +63,7 @@
</div>
<input id="file-holder" type="file" style="display: none"/>
</div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'options'}">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'options'}">
<div class="settings-table striped hoverable">
<div class="settings-table-title new-task-filter-title">
<div class="row">

View file

@ -2,7 +2,7 @@
<div class="setting-key setting-key-without-desc col-sm-4">
<span ng-bind="option.nameKey | translate"></span>
<em ng-bind="'(' + option.key + ')'"></em>
<i class="icon-primary fa fa-question-circle" ng-if="(option.descriptionKey | translate) != ''"
<i class="icon-primary fa fa-question-circle" ng-if="(option.descriptionKey | translate) !== ''"
data-toggle="popover" data-trigger="hover" data-placement="auto top" data-container="body" data-content="{{option.descriptionKey | translate}}"></i>
<span class="description" ng-if="option.showCount && option.split && optionValue"
ng-bind="'format.settings.total-count' | translate: {count: getTotalCount()}"></span>
@ -12,13 +12,13 @@
<div ng-class="{'input-group': !!option.suffix}">
<div class="form-group has-feedback" ng-class="[optionStatus.getStatusFeedbackStyle()]">
<input class="form-control" type="text" placeholder="{{::placeholder}}" ng-disabled="!!option.readonly"
ng-if="option.type == 'string' || option.type == 'integer' || option.type == 'float'"
ng-if="option.type === 'string' || option.type === 'integer' || option.type === 'float'"
ng-model="optionValue" ng-change="changeValue(optionValue, true)"/>
<textarea class="form-control" rows="6" placeholder="{{::placeholder}}" ng-disabled="!!option.readonly"
ng-if="option.type == 'text'"
ng-if="option.type === 'text'"
ng-model="optionValue" ng-change="changeValue(optionValue, true)"></textarea>
<select class="form-control" style="width: 100%;" ng-disabled="!!option.readonly" ng-class="{'placeholder': !optionValue}"
ng-if="option.type == 'boolean' || option.type == 'option'"
ng-if="option.type === 'boolean' || option.type === 'option'"
ng-model="optionValue" ng-change="changeValue(optionValue, false)"
ng-options="item.value as (item.name | translate) for item in option.options">
<option value="" disabled="disabled" ng-bind="(placeholder | translate)" style="display: none;"></option>

View file

@ -1,19 +1,19 @@
<section class="content no-padding">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs" ng-if="task">
<li ng-class="{'active': context.currentTab == 'overview'}">
<li ng-class="{'active': context.currentTab === 'overview'}">
<a class="pointer-cursor" ng-click="changeTab('overview')" translate>Overview</a>
</li>
<li ng-class="{'active': context.currentTab == 'blocks'}">
<li ng-class="{'active': context.currentTab === 'blocks'}">
<a class="pointer-cursor" ng-click="changeTab('blocks')" translate>Blocks</a>
</li>
<li ng-class="{'active': context.currentTab == 'filelist'}">
<li ng-class="{'active': context.currentTab === 'filelist'}">
<a class="pointer-cursor" ng-click="changeTab('filelist')" translate>Files</a>
</li>
<li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task && task.status == 'active' && task.bittorrent">
<li ng-class="{'active': context.currentTab === 'btpeers'}" ng-if="task && task.status === 'active' && task.bittorrent">
<a class="pointer-cursor" ng-click="changeTab('btpeers')" translate>Peers</a>
</li>
<li ng-class="{'active': context.currentTab == 'settings'}" ng-if="task && (task.status == 'active' || task.status == 'waiting' || task.status == 'paused')" class="slim">
<li ng-class="{'active': context.currentTab === 'settings'}" ng-if="task && (task.status === 'active' || task.status === 'waiting' || task.status === 'paused')" class="slim">
<a class="pointer-cursor" ng-click="changeTab('settings')">
<i class="fa fa-gear"></i>
</a>
@ -21,7 +21,7 @@
</ul>
<div class="tab-content no-padding">
<div class="tab-pane" ng-class="{'active': context.currentTab == 'overview'}">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'overview'}">
<div id="overview-items" class="settings-table striped hoverable" data-toggle="context" data-target="#task-overview-contextmenu">
<div class="row" ng-show="task">
<div class="setting-key col-sm-4">
@ -53,7 +53,7 @@
ng-tooltip="{{task.errorMessage}}" ng-tooltip-container="body" ng-tooltip-placement="top"></i>
</div>
</div>
<div class="row" ng-show="task && task.status == 'error' && task.errorDescription">
<div class="row" ng-show="task && task.status === 'error' && task.errorDescription">
<div class="setting-key col-sm-4">
<span translate>Error Description</span>
</div>
@ -63,10 +63,10 @@
</div>
<div class="row" ng-show="task">
<div class="setting-key col-sm-4">
<span ng-bind="('Progress' | translate) + (task.status == 'active' && task.bittorrent ? ' (' + ('Health Percentage' | translate) + ')' : '')"></span>
<span ng-bind="('Progress' | translate) + (task.status === 'active' && task.bittorrent ? ' (' + ('Health Percentage' | translate) + ')' : '')"></span>
</div>
<div class="setting-value col-sm-8">
<span ng-bind="(task.completePercent | percent: 2) + '%' + (task.status == 'active' && task.bittorrent ? ' (' + (context.healthPercent | percent: 2) + '%' + ')' : '')"></span>
<span ng-bind="(task.completePercent | percent: 2) + '%' + (task.status === 'active' && task.bittorrent ? ' (' + (context.healthPercent | percent: 2) + '%' + ')' : '')"></span>
</div>
</div>
<div class="row" ng-show="task">
@ -74,7 +74,7 @@
<span translate>Download</span>
</div>
<div class="setting-value col-sm-8">
<span ng-bind="(task.completedLength | readableVolume) + (task.status == 'active' ? ' @ ' + (task.downloadSpeed | readableVolume) + '/s' : '')"></span>
<span ng-bind="(task.completedLength | readableVolume) + (task.status === 'active' ? ' @ ' + (task.downloadSpeed | readableVolume) + '/s' : '')"></span>
</div>
</div>
<div class="row" ng-show="task && task.bittorrent">
@ -82,7 +82,7 @@
<span translate>Upload</span>
</div>
<div class="setting-value col-sm-8">
<span ng-bind="(task.uploadLength | readableVolume) + (task.status == 'active' ? ' @ ' + (task.uploadSpeed | readableVolume) + '/s' : '')"></span>
<span ng-bind="(task.uploadLength | readableVolume) + (task.status === 'active' ? ' @ ' + (task.uploadSpeed | readableVolume) + '/s' : '')"></span>
</div>
</div>
<div class="row" ng-show="task && task.bittorrent">
@ -93,7 +93,7 @@
<span ng-bind="(task.shareRatio | number: 2)"></span>
</div>
</div>
<div class="row" ng-show="task && task.status == 'active' && task.completedLength < task.totalLength">
<div class="row" ng-show="task && task.status === 'active' && task.completedLength < task.totalLength">
<div class="setting-key col-sm-4">
<span translate>Remain Time</span>
</div>
@ -101,7 +101,7 @@
<span ng-bind="0 <= task.remainTime && task.remainTime < 86400? (task.remainTime | dateDuration: 'second': 'HH:mm:ss') : ('More Than One Day' | translate)"></span>
</div>
</div>
<div class="row" ng-show="task && task.status == 'active'">
<div class="row" ng-show="task && task.status === 'active'">
<div class="setting-key col-sm-4">
<span ng-bind="(task.bittorrent ? ('Seeders' | translate) + ' / ' : '') + ('Connections' | translate)">Connections</span>
</div>
@ -157,7 +157,7 @@
</div>
</div>
<div class="settings-table">
<div class="row no-hover no-background" ng-if="context.isEnableSpeedChart && task && task.status == 'active'">
<div class="row no-hover no-background" ng-if="context.isEnableSpeedChart && task && task.status === 'active'">
<div class="col-sm-12">
<div class="task-status-chart-wrapper">
<ng-chart ng-data="context.statusData" height="200"></ng-chart>
@ -166,7 +166,7 @@
</div>
</div>
</div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'blocks'}">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'blocks'}">
<div class="piece-legends">
<div class="piece-legend" title="{{('format.task.pieceinfo' | translate: {completed: task.completedPieces, total: task.numPieces})}}">
<div class="piece piece-completed"></div><span translate>Completed</span>
@ -177,14 +177,14 @@
</div>
<ng-piece-map bit-field="task.bitfield" piece-count="task.numPieces"></ng-piece-map>
</div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'filelist'}">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'filelist'}">
<div class="task-table">
<div class="task-table-title">
<div class="row">
<div class="col-sm-8">
<a ng-click="changeFileListDisplayOrder('name:asc', true)" translate>File Name</a>
<i class="fa" ng-class="{'fa-sort-asc fa-order-asc': isSetFileListDisplayOrder('name:asc'), 'fa-sort-desc fa-order-desc': isSetFileListDisplayOrder('name:desc')}"></i>
<a ng-click="showChooseFilesToolbar()" ng-if="task && task.files && task.files.length > 1 && (task.status == 'waiting' || task.status == 'paused')" translate>(Choose Files)</a>
<a ng-click="showChooseFilesToolbar()" ng-if="task && task.files && task.files.length > 1 && (task.status === 'waiting' || task.status === 'paused')" translate>(Choose Files)</a>
</div>
<div class="col-sm-2">
<a ng-click="changeFileListDisplayOrder('percent:desc', true)" translate>Progress</a>
@ -235,7 +235,7 @@
<div class="row" ng-repeat="file in task.files | fileOrderBy: getFileListOrderType()" data-file-index="{{file.index}}">
<div class="col-sm-8">
<div class="checkbox checkbox-primary">
<input id="{{'file_' + file.index}}" type="checkbox" ng-disabled="!task || !task.files || task.files.length < 2 || (task.status != 'waiting' && task.status != 'paused')"
<input id="{{'file_' + file.index}}" type="checkbox" ng-disabled="!task || !task.files || task.files.length < 2 || (task.status !== 'waiting' && task.status !== 'paused')"
ng-model="file.selected" ng-change="setSelectedFile()"/>
<label for="{{'file_' + file.index}}" class="allow-word-break" ng-bind="file.fileName" title="{{file.fileName}}"></label>
</div>
@ -257,7 +257,7 @@
</div>
</div>
</div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task && task.status == 'active' && task.bittorrent">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'btpeers'}" ng-if="task && task.status === 'active' && task.bittorrent">
<div class="task-table">
<div class="task-table-title">
<div class="row">
@ -330,7 +330,7 @@
</div>
</div>
</div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'settings'}" ng-if="task && (task.status == 'active' || task.status == 'waiting' || task.status == 'paused')">
<div class="tab-pane" ng-class="{'active': context.currentTab === 'settings'}" ng-if="task && (task.status === 'active' || task.status === 'waiting' || task.status === 'paused')">
<div class="settings-table striped hoverable">
<ng-setting ng-repeat="option in context.availableOptions" option="option"
ng-model="context.options[option.key]" default-value="option.defaultValue"