diff --git a/public/scripts/controllers/bookmarks-controller.js b/public/scripts/controllers/bookmarks-controller.js index 4dbc06f..3203a90 100644 --- a/public/scripts/controllers/bookmarks-controller.js +++ b/public/scripts/controllers/bookmarks-controller.js @@ -10,8 +10,11 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' show: $scope.showStyle, } - $scope.jumpToUrl = function(url) { + $scope.jumpToUrl = function(url, id) { $window.open(url, '_blank'); + bookmarkService.clickBookmark({ + id: id + }); } getBookmarks(params); pubSubService.subscribe('MenuCtr.bookmarks', $scope, function(event, params) { diff --git a/public/scripts/controllers/edit-controller.js b/public/scripts/controllers/edit-controller.js index 2f92568..ffc5379 100644 --- a/public/scripts/controllers/edit-controller.js +++ b/public/scripts/controllers/edit-controller.js @@ -25,10 +25,12 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', 'bookmarkService', 'p var params = []; tags.forEach(function(tag) { tag = tag.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, ' '); // 去除前后空格,多个空格转为一个空格; - params.push(tag); + // 过滤是""的情况 + if (tag) { + params.push(tag); + } }); - console.log(params); bookmarkService.addTags(params).then( function(data) { $scope.tags = data; diff --git a/public/scripts/services/bookmark-service.js b/public/scripts/services/bookmark-service.js index 5d1491b..0364551 100644 --- a/public/scripts/services/bookmark-service.js +++ b/public/scripts/services/bookmark-service.js @@ -15,6 +15,19 @@ app.factory('bookmarkService', ['$http', '$q', function($http, $q) { }); return def.promise; }, + clickBookmark: function(params) { + var def = $q.defer(); + $http.post('/api/clickBookmark/', { + params: params + }) + .success(function(data) { + def.resolve(data); + }) + .error(function(data) { + console.log('Error: ' + data); + }); + return def.promise; + }, logout: function(params) { var def = $q.defer(); $http.post('/api/logout/', { @@ -128,9 +141,9 @@ app.factory('AuthenticationService', function() { return auth; }); -app.factory('TokenInterceptor', function ($q, $window, $location, AuthenticationService) { +app.factory('TokenInterceptor', function($q, $window, $location, AuthenticationService) { return { - request: function (config) { + request: function(config) { config.headers = config.headers || {}; if ($window.sessionStorage.token) { config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token; @@ -143,7 +156,7 @@ app.factory('TokenInterceptor', function ($q, $window, $location, Authentication }, /* Set Authentication.isAuthenticated to true if 200 received */ - response: function (response) { + response: function(response) { if (response != null && response.status == 200 && $window.sessionStorage.token && !AuthenticationService.isAuthenticated) { AuthenticationService.isAuthenticated = true; } diff --git a/public/views/bookmarks.html b/public/views/bookmarks.html index 6ff35d3..1046c0e 100644 --- a/public/views/bookmarks.html +++ b/public/views/bookmarks.html @@ -6,7 +6,14 @@