From b95a6d5e2cd8c680e372489c41ac59298c883fac Mon Sep 17 00:00:00 2001 From: xiahaoshawn Date: Mon, 23 May 2016 18:29:17 +0800 Subject: [PATCH] change javascript code style --- .../components/details/retrieve-projects.directive.js | 4 ++-- .../details/switch-pane-projects.directive.js | 2 +- .../js/components/log/advanced-search.directive.js | 4 ++-- .../resources/js/components/log/list-log.directive.js | 6 +++--- .../project-member/add-project-member.directive.js | 5 +++-- .../project-member/list-project-member.directive.js | 3 ++- .../components/project-member/project-member.config.js | 4 ++-- .../js/components/project/add-project.directive.js | 2 +- .../components/project/publicity-button.directive.js | 2 +- .../components/repository/list-repository.directive.js | 2 +- .../js/components/repository/list-tag.directive.js | 2 +- .../components/repository/popup-details.directive.js | 10 +++++----- .../js/components/sign-in/sign-in.directive.js | 3 ++- .../js/components/user/toggle-admin.directive.js | 2 +- .../components/validator/confirm-password.validator.js | 2 +- static/ng/resources/js/harbor.config.js | 10 ++++++++-- static/ng/resources/js/harbor.data.js | 4 ++-- .../ng/resources/js/layout/details/details.config.js | 4 ++-- .../layout/navigation/navigation-details.directive.js | 2 +- .../layout/navigation/navigation-header.directive.js | 4 ++-- .../resources/js/layout/project/project.controller.js | 2 +- static/ng/resources/js/services/i18n/services.i18n.js | 8 +++++--- .../js/services/user/services.reset-password.js | 5 +++-- .../ng/resources/js/services/user/services.sign-in.js | 5 +++-- 24 files changed, 55 insertions(+), 42 deletions(-) diff --git a/static/ng/resources/js/components/details/retrieve-projects.directive.js b/static/ng/resources/js/components/details/retrieve-projects.directive.js index 8d41385a6..d72034169 100644 --- a/static/ng/resources/js/components/details/retrieve-projects.directive.js +++ b/static/ng/resources/js/components/details/retrieve-projects.directive.js @@ -58,7 +58,7 @@ if($routeParams.project_id){ angular.forEach(vm.projects, function(value, index) { - if(value['ProjectId'] == $routeParams.project_id) { + if(value['ProjectId'] === $routeParams.project_id) { vm.selectedProject = value; } }); @@ -117,7 +117,7 @@ controller: RetrieveProjectsController, bindToController: true, controllerAs: 'vm' - } + }; return directive; diff --git a/static/ng/resources/js/components/details/switch-pane-projects.directive.js b/static/ng/resources/js/components/details/switch-pane-projects.directive.js index 1a10dd70e..7c1ba33f6 100644 --- a/static/ng/resources/js/components/details/switch-pane-projects.directive.js +++ b/static/ng/resources/js/components/details/switch-pane-projects.directive.js @@ -42,7 +42,7 @@ controller: SwitchPaneProjectsController, controllerAs: 'vm', bindToController: true - } + }; return directive; diff --git a/static/ng/resources/js/components/log/advanced-search.directive.js b/static/ng/resources/js/components/log/advanced-search.directive.js index a8d4dc0d5..facb0649b 100644 --- a/static/ng/resources/js/components/log/advanced-search.directive.js +++ b/static/ng/resources/js/components/log/advanced-search.directive.js @@ -24,7 +24,7 @@ vm.op = []; vm.op.push('all'); function checkOperation(e) { - if(e.checked == 'all') { + if(e.checked === 'all') { vm.opCreate = vm.opAll; vm.opPull = vm.opAll; vm.opPush = vm.opAll; @@ -48,7 +48,7 @@ if(vm.opDelete) { vm.op.push('delete'); } - if(vm.opOthers && vm.others != "") { + if(vm.opOthers && vm.others !== "") { vm.op.push(vm.others); } } diff --git a/static/ng/resources/js/components/log/list-log.directive.js b/static/ng/resources/js/components/log/list-log.directive.js index c92ddc11c..ad7f4e323 100644 --- a/static/ng/resources/js/components/log/list-log.directive.js +++ b/static/ng/resources/js/components/log/list-log.directive.js @@ -33,7 +33,7 @@ retrieve(vm.queryParams); function search(e) { - if(e.op[0] == 'all') { + if(e.op[0] === 'all') { vm.queryParams.keywords = ''; }else { vm.queryParams.keywords = e.op.join('/') ; @@ -68,7 +68,7 @@ } function toUTCSeconds(date, hour, min, sec) { - if(date == "") { + if(date === "") { return 0; } @@ -96,7 +96,7 @@ controller: ListLogController, controllerAs: 'vm', bindToController: true - } + }; return directive; } diff --git a/static/ng/resources/js/components/project-member/add-project-member.directive.js b/static/ng/resources/js/components/project-member/add-project-member.directive.js index 6aeaa9f13..9e4446110 100644 --- a/static/ng/resources/js/components/project-member/add-project-member.directive.js +++ b/static/ng/resources/js/components/project-member/add-project-member.directive.js @@ -55,7 +55,7 @@ vm.hasError = true; vm.errorMessage = 'username_already_exist'; } - if(status == 404) { + if(status === 404) { vm.hasError = true; vm.errorMessage = 'username_does_not_exist'; } @@ -76,7 +76,8 @@ 'controller': AddProjectMemberController, 'controllerAs': 'vm', 'bindToController': true - } + }; + return directive; } diff --git a/static/ng/resources/js/components/project-member/list-project-member.directive.js b/static/ng/resources/js/components/project-member/list-project-member.directive.js index c07c666c1..1e16d5ba0 100644 --- a/static/ng/resources/js/components/project-member/list-project-member.directive.js +++ b/static/ng/resources/js/components/project-member/list-project-member.directive.js @@ -60,7 +60,8 @@ controller: ListProjectMemberController, controllerAs: 'vm', bindToController: true - } + }; + return directive; } diff --git a/static/ng/resources/js/components/project-member/project-member.config.js b/static/ng/resources/js/components/project-member/project-member.config.js index f9d705be1..937dbccb7 100644 --- a/static/ng/resources/js/components/project-member/project-member.config.js +++ b/static/ng/resources/js/components/project-member/project-member.config.js @@ -24,8 +24,8 @@ for(var i = 0; i < r.length; i++) { var role = r[i]; - if(query.key == 'roleName' && role.roleName == query.value - || query.key == 'roleId' && role.id == query.value) { + if(query.key === 'roleName' && role.roleName === query.value + || query.key === 'roleId' && role.id === query.value) { return role; } } diff --git a/static/ng/resources/js/components/project/add-project.directive.js b/static/ng/resources/js/components/project/add-project.directive.js index bbc2bab1e..eb51e0730 100644 --- a/static/ng/resources/js/components/project/add-project.directive.js +++ b/static/ng/resources/js/components/project/add-project.directive.js @@ -44,7 +44,7 @@ vm.hasError = true; vm.errorMessage = 'project_already_exist'; } - if(status == 500) { + if(status === 500) { vm.hasError = true; vm.errorMessage = 'project_name_is_invalid'; } diff --git a/static/ng/resources/js/components/project/publicity-button.directive.js b/static/ng/resources/js/components/project/publicity-button.directive.js index 31132ceeb..dfd94c034 100644 --- a/static/ng/resources/js/components/project/publicity-button.directive.js +++ b/static/ng/resources/js/components/project/publicity-button.directive.js @@ -12,7 +12,7 @@ var vm = this; vm.toggle = toggle; - if(vm.isPublic == 1) { + if(vm.isPublic === 1) { vm.isPublic = true; }else{ vm.isPublic = false; diff --git a/static/ng/resources/js/components/repository/list-repository.directive.js b/static/ng/resources/js/components/repository/list-repository.directive.js index e3362117c..a8416c57f 100644 --- a/static/ng/resources/js/components/repository/list-repository.directive.js +++ b/static/ng/resources/js/components/repository/list-repository.directive.js @@ -98,7 +98,7 @@ controller: ListRepositoryController, controllerAs: 'vm', bindToController: true - } + }; return directive; diff --git a/static/ng/resources/js/components/repository/list-tag.directive.js b/static/ng/resources/js/components/repository/list-tag.directive.js index 0ee834fab..d312f2d3e 100644 --- a/static/ng/resources/js/components/repository/list-tag.directive.js +++ b/static/ng/resources/js/components/repository/list-tag.directive.js @@ -40,7 +40,7 @@ $scope.$emit('modalTitle', $filter('tr')('alert_delete_tag_title', [e.tag])); var message; - if(vm.tags.length == 1) { + if(vm.tags.length === 1) { message = $filter('tr')('alert_delete_last_tag', [e.tag]); }else { message = $filter('tr')('alert_delete_tag', [e.tag]); diff --git a/static/ng/resources/js/components/repository/popup-details.directive.js b/static/ng/resources/js/components/repository/popup-details.directive.js index 75766966a..b5f89013b 100644 --- a/static/ng/resources/js/components/repository/popup-details.directive.js +++ b/static/ng/resources/js/components/repository/popup-details.directive.js @@ -66,15 +66,15 @@ '
' + '

' + ctrl.manifest['Created'] + '

' + '
' + - '

' + (ctrl.manifest['Duration Days'] == '' ? 'N/A' : ctrl.manifest['Duration Days']) + ' days

' + + '

' + (ctrl.manifest['Duration Days'] === '' ? 'N/A' : ctrl.manifest['Duration Days']) + ' days

' + '
' + - '

' + (ctrl.manifest['Author'] == '' ? 'N/A' : ctrl.manifest['Author']) + '

' + + '

' + (ctrl.manifest['Author'] === '' ? 'N/A' : ctrl.manifest['Author']) + '

' + '
' + - '

' + (ctrl.manifest['Architecture'] == '' ? 'N/A' : ctrl.manifest['Architecture']) + '

' + + '

' + (ctrl.manifest['Architecture'] === '' ? 'N/A' : ctrl.manifest['Architecture']) + '

' + '
' + - '

' + (ctrl.manifest['Docker Version'] == '' ? 'N/A' : ctrl.manifest['Docker Version']) + '

' + + '

' + (ctrl.manifest['Docker Version'] === '' ? 'N/A' : ctrl.manifest['Docker Version']) + '

' + '
' + - '

' + (ctrl.manifest['OS'] == '' ? 'N/A' : ctrl.manifest['OS']) + '

' + + '

' + (ctrl.manifest['OS'] === '' ? 'N/A' : ctrl.manifest['OS']) + '

' + ''; return content; } diff --git a/static/ng/resources/js/components/sign-in/sign-in.directive.js b/static/ng/resources/js/components/sign-in/sign-in.directive.js index 0b9205b14..608080b52 100644 --- a/static/ng/resources/js/components/sign-in/sign-in.directive.js +++ b/static/ng/resources/js/components/sign-in/sign-in.directive.js @@ -60,7 +60,8 @@ 'controller': SignInController, 'controllerAs': 'vm', 'bindToController': true - } + }; + return directive; } diff --git a/static/ng/resources/js/components/user/toggle-admin.directive.js b/static/ng/resources/js/components/user/toggle-admin.directive.js index d0eb96a1a..37e8f2073 100644 --- a/static/ng/resources/js/components/user/toggle-admin.directive.js +++ b/static/ng/resources/js/components/user/toggle-admin.directive.js @@ -11,7 +11,7 @@ function ToggleAdminController($scope, ToggleAdminService) { var vm = this; - vm.isAdmin = (vm.hasAdminRole == 1) ? true : false; + vm.isAdmin = (vm.hasAdminRole === 1) ? true : false; vm.toggle = toggle; function toggle() { diff --git a/static/ng/resources/js/components/validator/confirm-password.validator.js b/static/ng/resources/js/components/validator/confirm-password.validator.js index 743cc3790..8c1119251 100644 --- a/static/ng/resources/js/components/validator/confirm-password.validator.js +++ b/static/ng/resources/js/components/validator/confirm-password.validator.js @@ -21,7 +21,7 @@ ctrl.$validators.compareTo = validator; function validator(modelValue) { - return modelValue == scope.otherModelValue; + return modelValue === scope.otherModelValue; } scope.$watch("otherModelValue", function(current, origin) { diff --git a/static/ng/resources/js/harbor.config.js b/static/ng/resources/js/harbor.config.js index d256c5cf2..b549b2055 100644 --- a/static/ng/resources/js/harbor.config.js +++ b/static/ng/resources/js/harbor.config.js @@ -19,8 +19,14 @@ name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; + if (!results) { + return null; + } + + if (!results[2]) { + return ''; + } + return decodeURIComponent(results[2].replace(/\+/g, " ")); } } diff --git a/static/ng/resources/js/harbor.data.js b/static/ng/resources/js/harbor.data.js index 30f977df7..388cd7505 100644 --- a/static/ng/resources/js/harbor.data.js +++ b/static/ng/resources/js/harbor.data.js @@ -20,7 +20,7 @@ unset: function() { $cookies.remove('user', {'path': '/'}); } - } + }; } currentProjectMember.$inject = ['$cookies']; @@ -36,7 +36,7 @@ unset: function() { $cookies.remove('member', {'path': '/'}); } - } + }; } })(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/details/details.config.js b/static/ng/resources/js/layout/details/details.config.js index cd2b36cd2..1adecbb6a 100644 --- a/static/ng/resources/js/layout/details/details.config.js +++ b/static/ng/resources/js/layout/details/details.config.js @@ -35,10 +35,10 @@ input = input || []; var filteredResults = []; - if (filterInput != '') { + if (filterInput !== '') { for(var i = 0; i < input.length; i++) { var item = input[i]; - if((key == "" && item.indexOf(filterInput) >= 0) || (key != "" && item[key].indexOf(filterInput) >= 0)) { + if((key === "" && item.indexOf(filterInput) >= 0) || (key !== "" && item[key].indexOf(filterInput) >= 0)) { filteredResults.push(item); continue; } diff --git a/static/ng/resources/js/layout/navigation/navigation-details.directive.js b/static/ng/resources/js/layout/navigation/navigation-details.directive.js index 8c34b40a6..24dea5ee8 100644 --- a/static/ng/resources/js/layout/navigation/navigation-details.directive.js +++ b/static/ng/resources/js/layout/navigation/navigation-details.directive.js @@ -32,7 +32,7 @@ controller: NavigationDetailsController, controllerAs: 'vm', bindToController: true - } + }; return directive; diff --git a/static/ng/resources/js/layout/navigation/navigation-header.directive.js b/static/ng/resources/js/layout/navigation/navigation-header.directive.js index 974f19d22..0a9574c2d 100644 --- a/static/ng/resources/js/layout/navigation/navigation-header.directive.js +++ b/static/ng/resources/js/layout/navigation/navigation-header.directive.js @@ -22,13 +22,13 @@ controller: NavigationHeaderController, controllerAs: 'vm', bindToController: true - } + }; return directive; function link(scope, element, attrs, ctrl) { var visited = ctrl.url; - if (visited != "/ng") { + if (visited !== "/ng") { element.find('a[href*="' + visited + '"]').addClass('active'); } element.find('a').on('click', click); diff --git a/static/ng/resources/js/layout/project/project.controller.js b/static/ng/resources/js/layout/project/project.controller.js index 3ed2d3df4..9a7a01698 100644 --- a/static/ng/resources/js/layout/project/project.controller.js +++ b/static/ng/resources/js/layout/project/project.controller.js @@ -59,7 +59,7 @@ } function showAddButton() { - if(vm.publicity == 0) { + if(vm.publicity === 0) { return true; }else{ return false; diff --git a/static/ng/resources/js/services/i18n/services.i18n.js b/static/ng/resources/js/services/i18n/services.i18n.js index 00b5ced18..10ff7ebd5 100644 --- a/static/ng/resources/js/services/i18n/services.i18n.js +++ b/static/ng/resources/js/services/i18n/services.i18n.js @@ -18,15 +18,16 @@ }; var isSupportLanguage = function(language) { for (var i in supportLanguages) { - if(language == i) { + if(language === i) { return true; } } return false; - } + }; return tr; function tr() { + return { 'setCurrentLanguage': function(language) { if(!angular.isDefined(language) || !isSupportLanguage(language)) { @@ -52,7 +53,8 @@ 'getValue': function(key) { return messages[key]; } - } + }; + } } diff --git a/static/ng/resources/js/services/user/services.reset-password.js b/static/ng/resources/js/services/user/services.reset-password.js index 0aede9911..f434cfab4 100644 --- a/static/ng/resources/js/services/user/services.reset-password.js +++ b/static/ng/resources/js/services/user/services.reset-password.js @@ -17,8 +17,9 @@ headers: {'Content-Type': 'application/x-www-form-urlencoded'}, transformRequest: function(obj) { var str = []; - for(var p in obj) - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + for(var p in obj) { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + } return str.join("&"); }, data: {'reset_uuid': uuid, 'password': password} diff --git a/static/ng/resources/js/services/user/services.sign-in.js b/static/ng/resources/js/services/user/services.sign-in.js index 0f64739c0..d86edb6ba 100644 --- a/static/ng/resources/js/services/user/services.sign-in.js +++ b/static/ng/resources/js/services/user/services.sign-in.js @@ -19,8 +19,9 @@ headers: {'Content-Type': 'application/x-www-form-urlencoded'}, transformRequest: function(obj) { var str = []; - for(var p in obj) - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + for(var p in obj) { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + } return str.join("&"); }, data: {'principal': principal, 'password': password}