code refactor

This commit is contained in:
MaysWind 2016-12-11 01:50:25 +08:00
parent e0cddfde33
commit 088fd42e78
20 changed files with 47 additions and 47 deletions

View file

@ -579,5 +579,5 @@
};
$translateProvider.translations(ariaNgConstants.defaultLanguage, defaultLanguageResource);
}])
}]);
}());

View file

@ -21,7 +21,7 @@
var base64Url = $routeParams.url;
var url = base64.urldecode(base64Url);
$rootScope.loadPromise = newUrlDownload(url);
ariaNgLogService.info("[CommandController] new download: " + url);
ariaNgLogService.info('[CommandController] new download: ' + url);
} else {
ariaNgCommonService.error('Parameter is invalid!');
}

View file

@ -17,7 +17,7 @@
stoppedCount: globalStat.numStopped,
downloadSpeed: globalStat.downloadSpeed,
uploadSpeed: globalStat.uploadSpeed
}
};
})($scope.globalStat);
$document[0].title = ariaNgSettingService.getFinalTitle(context);

View file

@ -59,7 +59,7 @@
var refreshDownloadTask = function (silent) {
if (pauseDownloadTaskRefresh) {
return;
}
}
var processError = function (message) {
if (message === aria2RpcErrors.Unauthorized.message) {

View file

@ -6,6 +6,6 @@
var timespan = moment.duration(duration, sourceUnit);
var time = moment.utc(timespan.asMilliseconds());
return time.format(format);
}
};
}]);
}());

View file

@ -22,6 +22,6 @@
} else {
return array;
}
}
};
}]);
}());

View file

@ -5,6 +5,6 @@
return function (time) {
var format = $translate.instant('format.longdate');
return moment(time).format(format);
}
};
}]);
}());

View file

@ -26,6 +26,6 @@
} else {
return array;
}
}
};
}]);
}());

View file

@ -7,6 +7,6 @@
var result = parseInt(value * ratio) / ratio;
return $filter('number')(result, precision);
}
};
}]);
}());

View file

@ -28,6 +28,6 @@
} else {
return array;
}
}
};
}]);
}());

View file

@ -26,6 +26,6 @@
} else {
return '';
}
}
};
});
}());

View file

@ -32,6 +32,6 @@
value = $filter('number')(value, fractionSize);
return value + ' ' + unit;
}
};
}]);
}());

View file

@ -154,14 +154,14 @@
return aria2RpcService.getVersion({
silent: !!silent,
callback: callback
})
});
},
getGlobalStat: function (callback, silent) {
return aria2RpcService.getGlobalStat({
silent: !!silent,
callback: function (response) {
if (!callback) {
ariaNgLogService.warn("[aria2SettingService.getGlobalStat] callback is null");
ariaNgLogService.warn('[aria2SettingService.getGlobalStat] callback is null');
return;
}
@ -174,13 +174,13 @@
return aria2RpcService.saveSession({
silent: !!silent,
callback: callback
})
});
},
shutdown: function (callback, silent) {
return aria2RpcService.shutdown({
silent: !!silent,
callback: callback
})
});
}
};
}]);

View file

@ -4,7 +4,7 @@
angular.module('ariaNg').factory('aria2TaskService', ['$q', '$translate', 'bittorrentPeeridService', 'aria2Errors', 'aria2RpcService', 'ariaNgCommonService', 'ariaNgLogService', function ($q, $translate, bittorrentPeeridService, aria2Errors, aria2RpcService, ariaNgCommonService, ariaNgLogService) {
var getFileName = function (file) {
if (!file) {
ariaNgLogService.warn("[aria2TaskService.getFileName] file is null");
ariaNgLogService.warn('[aria2TaskService.getFileName] file is null');
return '';
}
@ -123,7 +123,7 @@
var processDownloadTask = function (task) {
if (!task) {
ariaNgLogService.warn("[aria2TaskService.processDownloadTask] task is null");
ariaNgLogService.warn('[aria2TaskService.processDownloadTask] task is null');
return task;
}
@ -176,7 +176,7 @@
var processBtPeers = function (peers, task, includeLocalPeer) {
if (!peers) {
ariaNgLogService.warn("[aria2TaskService.processBtPeers] peers is null");
ariaNgLogService.warn('[aria2TaskService.processBtPeers] peers is null');
return peers;
}
@ -240,7 +240,7 @@
} else {
callback(context);
}
}
};
};
var createLocalPeerFromTask = function (task) {
@ -275,7 +275,7 @@
silent: !!silent,
callback: function (response) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getTaskList] callback is null");
ariaNgLogService.warn('[aria2TaskService.getTaskList] callback is null');
return;
}
@ -289,7 +289,7 @@
silent: !!silent,
callback: function (response) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getTaskStatus] callback is null");
ariaNgLogService.warn('[aria2TaskService.getTaskStatus] callback is null');
return;
}
@ -338,7 +338,7 @@
silent: !!silent,
callback: function (response) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getBtTaskPeers] callback is null");
ariaNgLogService.warn('[aria2TaskService.getBtTaskPeers] callback is null');
return;
}
@ -364,7 +364,7 @@
silent: !!silent,
callback: function (response) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getTaskStatusAndBtPeers] callback is null");
ariaNgLogService.warn('[aria2TaskService.getTaskStatusAndBtPeers] callback is null');
return;
}
@ -445,12 +445,12 @@
silent: !!silent,
callback: function (response) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.restartTask] callback is null");
ariaNgLogService.warn('[aria2TaskService.restartTask] callback is null');
return;
}
if (!response.success) {
ariaNgLogService.warn("[aria2TaskService.restartTask] response is not success");
ariaNgLogService.warn('[aria2TaskService.restartTask] response is not success');
deferred.reject(response);
callback(response);
return;
@ -466,23 +466,23 @@
if (!task || !options || !task.files || task.files.length != 1 || task.bittorrent) {
if (!task) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task is null");
ariaNgLogService.warn('[aria2TaskService.restartTask] task is null');
}
if (!options) {
ariaNgLogService.warn("[aria2TaskService.restartTask] options is null");
ariaNgLogService.warn('[aria2TaskService.restartTask] options is null');
}
if (!task.files) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task file is null");
ariaNgLogService.warn('[aria2TaskService.restartTask] task file is null');
}
if (task.files.length != 1) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task file length is not equal 1");
ariaNgLogService.warn('[aria2TaskService.restartTask] task file length is not equal 1');
}
if (task.bittorrent) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task is bittorrent");
ariaNgLogService.warn('[aria2TaskService.restartTask] task is bittorrent');
}
deferred.reject(gid);
@ -509,7 +509,7 @@
silent: !!silent,
callback: function (response) {
if (!response.success) {
ariaNgLogService.warn("[aria2TaskService.restartTask] addUri response is not success");
ariaNgLogService.warn('[aria2TaskService.restartTask] addUri response is not success');
deferred.reject(response);
callback(response);
return;
@ -583,7 +583,7 @@
how: 'POS_SET',
silent: !!silent,
callback: callback
})
});
},
clearStoppedTasks: function (callback, silent) {
return aria2RpcService.purgeDownloadResult({
@ -593,7 +593,7 @@
},
onFirstSuccess: function (callback) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onFirstSuccess] callback is null");
ariaNgLogService.warn('[aria2TaskService.onFirstSuccess] callback is null');
return;
}
@ -603,7 +603,7 @@
},
onTaskCompleted: function (callback) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onTaskCompleted] callback is null");
ariaNgLogService.warn('[aria2TaskService.onTaskCompleted] callback is null');
return;
}
@ -613,7 +613,7 @@
},
onBtTaskCompleted: function (callback) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onBtTaskCompleted] callback is null");
ariaNgLogService.warn('[aria2TaskService.onBtTaskCompleted] callback is null');
return;
}
@ -623,7 +623,7 @@
},
onTaskErrorOccur: function (callback) {
if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onTaskErrorOccur] callback is null");
ariaNgLogService.warn('[aria2TaskService.onTaskErrorOccur] callback is null');
return;
}
@ -633,7 +633,7 @@
},
processDownloadTasks: function (tasks) {
if (!angular.isArray(tasks)) {
ariaNgLogService.warn("[aria2TaskService.processDownloadTasks] tasks is not array");
ariaNgLogService.warn('[aria2TaskService.processDownloadTasks] tasks is not array');
return;
}
@ -649,7 +649,7 @@
},
estimateHealthPercentFromPeers: function (task, peers) {
if (!task || task.numPieces < 1 || peers.length < 1) {
ariaNgLogService.warn("[aria2TaskService.estimateHealthPercentFromPeers] tasks is null or numPieces < 1 or peers < 1");
ariaNgLogService.warn('[aria2TaskService.estimateHealthPercentFromPeers] tasks is null or numPieces < 1 or peers < 1');
return task.completePercent;
}

View file

@ -20,7 +20,7 @@
}, 100);
},
showError: function (text) {
ariaNgLogService.info("[ariaNgCommonService.showError] " + text);
ariaNgLogService.info('[ariaNgCommonService.showError] ' + text);
this.showDialog('Error', text, 'error');
},
showOperationSucceeded: function (text) {
@ -174,7 +174,7 @@
}
},
getValue: function () {
return this.type + ":" + this.order;
return this.type + ':' + this.order;
}
};
@ -227,7 +227,7 @@
name: name,
value: value,
optionValue: time
})
});
}
return options;

View file

@ -87,6 +87,6 @@
reader.readAsDataURL(file);
}).trigger('click');
}
}
};
}]);
}());

View file

@ -9,7 +9,7 @@
return {
key: line.substring(0, equalSignPos),
value: line.substring(equalSignPos + 1, line.length)
}
};
} else {
return {
value: line

View file

@ -154,6 +154,6 @@
getGlobalStatsData: function () {
return this.getStatsData(globalStorageKey);
}
}
};
}]);
}());

View file

@ -82,6 +82,6 @@
clearNotificationInPage: function () {
Notification.clearAll();
}
}
};
}]);
}());

View file

@ -25,7 +25,7 @@
return ariaNgDefaultOptions.language;
}
browserLang = browserLang.replace(/\-/g, "_");
browserLang = browserLang.replace(/\-/g, '_');
if (!ariaNgLanguages[browserLang]) {
return ariaNgDefaultOptions.language;