From 893c284018efd413feb767b42fb077fd4d7eb33d Mon Sep 17 00:00:00 2001 From: Amio Date: Mon, 24 Mar 2014 12:15:16 +0800 Subject: [PATCH] =?UTF-8?q?WA=E4=BB=A3=E7=A0=81=EF=BC=9A=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scripts/app.js | 124 ++++++++++++------------ app/scripts/controllers/package-edit.js | 18 ++-- app/scripts/controllers/register.js | 8 +- app/scripts/directives/navbar.js | 4 +- app/scripts/directives/uploader.js | 10 +- app/scripts/services/login.js | 39 ++++---- app/scripts/services/modals.js | 2 +- gulpfile.js | 7 +- 8 files changed, 109 insertions(+), 103 deletions(-) diff --git a/app/scripts/app.js b/app/scripts/app.js index 6b1ac2a..c273e12 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -61,83 +61,83 @@ angular.module('toHELL', [ : 'http://wxddb1.qa.nt.ctripcorp.com/tohell/', errDesc: { // 用户登陆接口 /login/ - 1001: "请求方式错误", - 1002: "用户名或密码不正确", - 1003: "邮箱为空", - 1004: "密码为空", + 1001: '请求方式错误', + 1002: '用户名或密码不正确', + 1003: '邮箱为空', + 1004: '密码为空', // 用户注册接口 /register/ - 2001: "请求方式错误", - 2002: "用户已存在", - 2003: "服务器内部错误", - 2004: "用户名为空", - 2005: "密码为空", - 2006: "邮箱格式错误", + 2001: '请求方式错误', + 2002: '用户已存在', + 2003: '服务器内部错误', + 2004: '用户名为空', + 2005: '密码为空', + 2006: '邮箱格式错误', // 修改密码接口 // - 3001: "请求方式错误", - 3002: "Token无效需要重新登录", - 3003: "密码为空", - 3004: "旧密码错误", - 3005: "服务器内部错误", + 3001: '请求方式错误', + 3002: 'Token无效需要重新登录', + 3003: '密码为空', + 3004: '旧密码错误', + 3005: '服务器内部错误', // 获取用户信息接口 /usrinfo/ - 4001: "token为空", - 4002: "token无效", - 4003: "服务器内部错误", + 4001: 'token为空', + 4002: 'token无效', + 4003: '服务器内部错误', // 更新用户信息接口 /updateuser/ - 5001: "token为空", - 5002: "token无效", - 5003: "服务器内部错误", + 5001: 'token为空', + 5002: 'token无效', + 5003: '服务器内部错误', // 创建工程接口 /createProject/ - 6001: "请求方式错误", - 6002: "token无效", - 6003: "服务器内部错误", + 6001: '请求方式错误', + 6002: 'token无效', + 6003: '服务器内部错误', // 删除工程接口 /deleteProject/ - 7001: "请求方式错误", - 7002: "token为空", - 7003: "appid为空", - 7004: "token无效", - 7005: "服务器内部错误", + 7001: '请求方式错误', + 7002: 'token为空', + 7003: 'appid为空', + 7004: 'token无效', + 7005: '服务器内部错误', // 保存工程接口 // - 8001: "请求方式错误", - 8002: "用户名为空", - 8003: "用户名不存在", + 8001: '请求方式错误', + 8002: '用户名为空', + 8003: '用户名不存在', // 获取工程接口 // - 9001: "请求方式错误", - 9002: "token无效", - 9003: "服务器内部异常", + 9001: '请求方式错误', + 9002: 'token无效', + 9003: '服务器内部异常', // 获取工程列表接口 - 10001: "token为空", - 10002: "token认证失败", - 10003: "服务器内部错误", + 10001: 'token为空', + 10002: 'token认证失败', + 10003: '服务器内部错误', // 分享工程接口 /share/ - 11001: "分享工程接口:请求方式错误", - 11002: "分享工程接口:token为空或appid为空或user为空或option为空", - 11003: "分享工程接口:token失效", - 11004: "分享工程接口:分享的用户不存在", - 11005: "分享工程接口:已经分享过了", - 11006: "分享工程接口:未知操作(option为非12)", + 11001: '分享工程接口:请求方式错误', + 11002: '分享工程接口:token为空或appid为空或user为空或option为空', + 11003: '分享工程接口:token失效', + 11004: '分享工程接口:分享的用户不存在', + 11005: '分享工程接口:已经分享过了', + 11006: '分享工程接口:未知操作(option为非12)', // 获取分享用户列表 - 12001: "请求方式错误", - 12002: "token为空", - 12003: "token失效", + 12001: '请求方式错误', + 12002: 'token为空', + 12003: 'token失效', // 意见反馈 - 13001: "请求方式错误", - 13002: "邮箱为空", - 13003: "反馈内容为空", - 13004: "反馈来源为空", - 13005: "服务器内部错误", + 13001: '请求方式错误', + 13002: '邮箱为空', + 13003: '反馈内容为空', + 13004: '反馈来源为空', + 13005: '服务器内部错误', // iOS 注册推送token - 14001: "请求方式错误", - 14002: "token为空", - 14003: "服务器内部错误", + 14001: '请求方式错误', + 14002: 'token为空', + 14003: '服务器内部错误', // 生成ZIP包 - 15001: "请求方式错误", - 15002: "服务器IO操作错误", - 15003: "Lua解析错误", - 15004: "Lua解析异常", - 15005: "token失效", + 15001: '请求方式错误', + 15002: '服务器IO操作错误', + 15003: 'Lua解析错误', + 15004: 'Lua解析异常', + 15005: 'token失效', // 上传图片接口 - 0: "上传失败", - 1: "上传成功" + 0: '上传失败', + 1: '上传成功' }, errLogger: function (data, status, headers, config) { console.log('Status:', status, '\nData :', data, '\nConfig:', config); diff --git a/app/scripts/controllers/package-edit.js b/app/scripts/controllers/package-edit.js index 11ac489..2ecbb4a 100644 --- a/app/scripts/controllers/package-edit.js +++ b/app/scripts/controllers/package-edit.js @@ -23,7 +23,7 @@ angular.module('toHELL') } else { token = loginService.getLoggedInUser().token; } - + $scope.fileRoot = GLOBAL.pkgHost + '/' + $routeParams.pkgId + '/'; /** @@ -82,8 +82,8 @@ angular.module('toHELL') $scope.onActorItemClick = function (element) { editService.selectElement(element); }; - - function uploadDataFormater(args){ + + function uploadDataFormater(args) { args.url = GLOBAL.apiHost + 'uploadImage/'; args.transformRequest = formDataObject; args.data = { @@ -92,20 +92,20 @@ angular.module('toHELL') }; return args; } - + $scope.iconUploadHandlers = { before: uploadDataFormater, - after: function(data){ - if(data.status === '1'){ + after: function (data) { + if (data.status === '1') { $scope.package.icon = data.fileName; } } }; - + $scope.sceneBgUploadHandlers = { before: uploadDataFormater, - after: function(data){ - if(data.status == '1'){ + after: function (data) { + if (data.status === '1') { $scope.editStat.selectedScene.background = $scope.fileRoot + data.fileName; } } diff --git a/app/scripts/controllers/register.js b/app/scripts/controllers/register.js index 0a9b444..08542bd 100644 --- a/app/scripts/controllers/register.js +++ b/app/scripts/controllers/register.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('toHELL') -.controller('RegisterCTRL', ['$scope', '$location', '$http', 'GLOBAL', 'loginService', - function ($scope, $location, $http, GLOBAL, loginService) { +.controller('RegisterCTRL', ['$scope', '$location', '$http', 'GLOBAL', 'loginService', 'notifyService', + function ($scope, $location, $http, GLOBAL, loginService, notifyService) { $scope.doSignup = function () { // 将密码做 MD5 转换 @@ -24,11 +24,11 @@ angular.module('toHELL') break; default: var errDesc = GLOBAL.errDesc[res.error_code] || '未知错误'; - alert(errDesc); + notifyService.error(errDesc); console.log('Signup Error: ', errDesc, res); } }) .error(GLOBAL.errLogger); - } + }; } ]); diff --git a/app/scripts/directives/navbar.js b/app/scripts/directives/navbar.js index 4671e00..dc02c1a 100644 --- a/app/scripts/directives/navbar.js +++ b/app/scripts/directives/navbar.js @@ -1,3 +1,5 @@ +'use strict'; + angular.module('toHELL') /** @@ -52,5 +54,5 @@ angular.module('toHELL') $rootScope.$broadcast('package.save'); }; } - } + }; }]); diff --git a/app/scripts/directives/uploader.js b/app/scripts/directives/uploader.js index b85318b..5848264 100644 --- a/app/scripts/directives/uploader.js +++ b/app/scripts/directives/uploader.js @@ -1,5 +1,7 @@ +'use strict'; + angular.module('toHELL') -.directive('uploader', ['$http', 'GLOBAL', 'formDataObject', function ($http, GLOBAL, formDataObject) { +.directive('uploader', ['$http', 'GLOBAL', 'formDataObject', function ($http, GLOBAL) { return { restrict: 'A', link: function (scope, el, attrs) { @@ -8,14 +10,14 @@ angular.module('toHELL') el.bind('change', function (ev) { // handlers 对象包含两个方法:可选 before(postArgs), 必选 after(response) - var handlers = scope[attrs['handlers']]; + var handlers = scope[attrs.handlers]; if (handlers) { // 创建 POST 参数对象 var postArgs = { method: 'POST', - url: attrs['url'] || '', + url: attrs.url || '', headers: { 'Content-Type': 'multipart/form-data' }, @@ -25,7 +27,7 @@ angular.module('toHELL') }; // handlers.before() 应该返回经过整理的 postArgs. - if(handlers.before){ + if (handlers.before) { postArgs = handlers.before(postArgs); } diff --git a/app/scripts/services/login.js b/app/scripts/services/login.js index 3351f11..de82971 100644 --- a/app/scripts/services/login.js +++ b/app/scripts/services/login.js @@ -22,25 +22,24 @@ angular.module('toHELL').factory('loginService', [ '$http', 'GLOBAL', '$location // Login $http.post(GLOBAL.apiHost + 'login/', account) - .success(function (res) { - switch (res.status) { - - case '1': - // Success - loggedInUser = res.result; - localStorage.setItem('loggedInUser', JSON.stringify(loggedInUser)); - callback && callback(res.result); - break; - - default: - // Else - var errDesc = GLOBAL.errDesc[res.error_code] || '未知错误'; - alert(errDesc); - console.log('Login Error: ', errDesc, res); - errCallback && errCallback(res); - } - }) - .error(GLOBAL.errLogger); + .success(function (res) { + switch (res.status) { + + case '1': + // Success + loggedInUser = res.result; + localStorage.setItem('loggedInUser', JSON.stringify(loggedInUser)); + callback && callback(res.result); + break; + + default: + // Else + var errDesc = GLOBAL.errDesc[res.error_code] || '未知错误'; + console.log('Login Error: ', errDesc, res); + errCallback && errCallback(res); + } + }) + .error(GLOBAL.errLogger); }, doLogout: function (callback) { @@ -49,5 +48,5 @@ angular.module('toHELL').factory('loginService', [ '$http', 'GLOBAL', '$location $location.path('/'); callback && callback(); } - } + }; }]); \ No newline at end of file diff --git a/app/scripts/services/modals.js b/app/scripts/services/modals.js index b019fa8..7aaea31 100644 --- a/app/scripts/services/modals.js +++ b/app/scripts/services/modals.js @@ -6,7 +6,7 @@ angular.module('toHELL') controller: 'DialogShareCtrl', controllerAs: 'modal', templateUrl: 'partials/dialog-share.html' - }) + }); }]) .controller('DialogShareCtrl', [ 'dialogShare', diff --git a/gulpfile.js b/gulpfile.js index acdc82f..1546909 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -73,8 +73,11 @@ gulp.task('server:dist', ['build'], function () { * ===================================== */ -gulp.task('lint', function(){ - return gulp.src(SOURCE_ROOT + '/scripts/**/*.js') +gulp.task('lint', function () { + return gulp.src([ + SOURCE_ROOT + '/scripts/**/*.js', + '!' + SOURCE_ROOT + '/scripts/libs/**/*.js' + ]) .pipe($.jshint('.jshintrc')) .pipe($.jshint.reporter('jshint-stylish')) .pipe($.size());