starting add douban books, not finished yet

This commit is contained in:
2014-03-25 08:34:54 +08:00
parent 299848b61b
commit 1bf728c969
15 changed files with 303 additions and 22 deletions
+44
View File
@@ -2,3 +2,47 @@
2014-03-11 21:30:44.394 Libr[50734:70b] Unlimited access to network resources
2014-03-11 21:30:44.510 Libr[50734:70b] Resetting plugins due to page load.
2014-03-11 21:30:44.730 Libr[50734:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/login
2014-03-24 16:23:21.454 Libr[2904:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:23:21.487 Libr[2904:70b] Unlimited access to network resources
2014-03-24 16:23:21.927 Libr[2904:70b] Resetting plugins due to page load.
2014-03-24 16:23:22.448 Libr[2904:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/login
2014-03-24 16:25:49.572 Libr[3102:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:25:49.578 Libr[3102:70b] Unlimited access to network resources
2014-03-24 16:25:49.658 Libr[3102:70b] Resetting plugins due to page load.
2014-03-24 16:25:49.873 Libr[3102:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:26:02.989 Libr[3283:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:26:02.995 Libr[3283:70b] Unlimited access to network resources
2014-03-24 16:26:03.079 Libr[3283:70b] Resetting plugins due to page load.
2014-03-24 16:26:03.307 Libr[3283:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:27:09.085 Libr[3470:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:27:09.091 Libr[3470:70b] Unlimited access to network resources
2014-03-24 16:27:09.135 Libr[3470:70b] Resetting plugins due to page load.
2014-03-24 16:27:09.341 Libr[3470:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:27:21.437 Libr[3651:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:27:21.443 Libr[3651:70b] Unlimited access to network resources
2014-03-24 16:27:21.521 Libr[3651:70b] Resetting plugins due to page load.
2014-03-24 16:27:21.758 Libr[3651:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:28:33.698 Libr[3835:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:28:33.704 Libr[3835:70b] Unlimited access to network resources
2014-03-24 16:28:33.748 Libr[3835:70b] Resetting plugins due to page load.
2014-03-24 16:28:33.954 Libr[3835:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:28:39.632 Libr[4015:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:28:39.638 Libr[4015:70b] Unlimited access to network resources
2014-03-24 16:28:39.722 Libr[4015:70b] Resetting plugins due to page load.
2014-03-24 16:28:39.940 Libr[4015:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:29:18.678 Libr[4197:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:29:18.684 Libr[4197:70b] Unlimited access to network resources
2014-03-24 16:29:18.728 Libr[4197:70b] Resetting plugins due to page load.
2014-03-24 16:29:18.935 Libr[4197:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:29:25.660 Libr[4376:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:29:25.665 Libr[4376:70b] Unlimited access to network resources
2014-03-24 16:29:25.773 Libr[4376:70b] Resetting plugins due to page load.
2014-03-24 16:29:26.059 Libr[4376:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:30:35.034 Libr[4561:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:30:35.039 Libr[4561:70b] Unlimited access to network resources
2014-03-24 16:30:35.085 Libr[4561:70b] Resetting plugins due to page load.
2014-03-24 16:30:35.291 Libr[4561:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
2014-03-24 16:30:39.187 Libr[4741:70b] Multi-tasking -> Device: YES, App: YES
2014-03-24 16:30:39.193 Libr[4741:70b] Unlimited access to network resources
2014-03-24 16:30:39.282 Libr[4741:70b] Resetting plugins due to page load.
2014-03-24 16:30:39.558 Libr[4741:70b] Finished load of: file:///Users/twer/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/27050D46-5713-492B-814C-7D0455F35FDC/Libr.app/www/index.html#/tab/home
+1
View File
@@ -28,6 +28,7 @@
<script src="js/app.js"></script>
<script src="js/app/handler/error-handler.js"></script>
<script src="js/services.js"></script>
<script src="js/app/services/douban-service.js"></script>
<script src="js/app/services/authication-service.js"></script>
<script src="js/app/services/scan-service.js"></script>
<script src="js/app/services/geolocation.js"></script>
+1
View File
@@ -5,6 +5,7 @@
// 'libr.controllers' is found in controllers.js
angular.module('libr', ['ionic', 'libr.services', 'libr.controllers', 'libr.services.scan',
'libr.handlers.errorHandler',
'libr.services.douban',
'libr.services.geolocation',
'libr.services.auth',
'libr.services.books',
@@ -2,8 +2,8 @@ libr = angular.module 'libr.controllers.books', ['ionic']
class BooksController
@$inject: ['$scope', 'Books', 'ScanService', '$ionicModal']
constructor: (@$scope, @Books, ScanService, @$ionicModal) ->
@$inject: ['$scope', 'Books', 'ScanService', '$ionicModal', 'DoubanService']
constructor: (@$scope, @Books, ScanService, @$ionicModal, @DoubanService) ->
currentPage = localStorage.setItem 'user_books_current_page', 0
@$scope.books = []
@$scope.moreItemsAvailable = true
@@ -34,6 +34,8 @@ class BooksController
]
@$scope.onRefresh = @refresh
@$scope.loadMore = @loadMore
@$scope.closeDialog = @closeDialog
@$scope.searchDoubanUser = @searchDoubanUser
refresh: ()=>
afterBookId = localStorage.getItem 'user_max_book_id'
@@ -66,5 +68,19 @@ class BooksController
@$scope.$broadcast('scroll.infiniteScrollComplete')
@$scope.moreItemsAvailable = false
closeDialog: =>
@$scope.modal.hide()
searchDoubanUser: (user)=>
if user is undefined or user.trim() is ''
alert '请输入有效昵称'
else
@DoubanService.userInfo user,
(data)=>
@$scope.resultEnabled = true
@$scope.doubanUser = data
, (error)=>
console.log error
libr.controller 'BooksController', BooksController
@@ -6,13 +6,16 @@
libr = angular.module('libr.controllers.books', ['ionic']);
BooksController = (function() {
BooksController.$inject = ['$scope', 'Books', 'ScanService', '$ionicModal'];
BooksController.$inject = ['$scope', 'Books', 'ScanService', '$ionicModal', 'DoubanService'];
function BooksController($scope, Books, ScanService, $ionicModal) {
function BooksController($scope, Books, ScanService, $ionicModal, DoubanService) {
var currentPage;
this.$scope = $scope;
this.Books = Books;
this.$ionicModal = $ionicModal;
this.DoubanService = DoubanService;
this.searchDoubanUser = __bind(this.searchDoubanUser, this);
this.closeDialog = __bind(this.closeDialog, this);
this.loadMore = __bind(this.loadMore, this);
this.refresh = __bind(this.refresh, this);
currentPage = localStorage.setItem('user_books_current_page', 0);
@@ -51,6 +54,8 @@
];
this.$scope.onRefresh = this.refresh;
this.$scope.loadMore = this.loadMore;
this.$scope.closeDialog = this.closeDialog;
this.$scope.searchDoubanUser = this.searchDoubanUser;
}
BooksController.prototype.refresh = function() {
@@ -101,6 +106,27 @@
}
};
BooksController.prototype.closeDialog = function() {
return this.$scope.modal.hide();
};
BooksController.prototype.searchDoubanUser = function(user) {
if (user === void 0 || user.trim() === '') {
return alert('请输入有效昵称');
} else {
return this.DoubanService.userInfo(user, (function(_this) {
return function(data) {
_this.$scope.resultEnabled = true;
return _this.$scope.doubanUser = data;
};
})(this), (function(_this) {
return function(error) {
return console.log(error);
};
})(this));
}
};
return BooksController;
})();
@@ -0,0 +1,25 @@
libr = angular.module 'libr.services.douban', []
class DoubanService
@$inject: ['$http']
constructor: (@$http)->
userInfo: (user, callback, error)->
@$http(
url: "http://api.douban.com/v2/user/#{user}"
method: 'GET'
timeout: 10000
)
.success (data, status, headers, config)->
if status is 200
callback data
else
error data
.error (data)->
error data
libr.service 'DoubanService', DoubanService
@@ -0,0 +1,36 @@
// Generated by CoffeeScript 1.7.1
(function() {
var DoubanService, libr;
libr = angular.module('libr.services.douban', []);
DoubanService = (function() {
DoubanService.$inject = ['$http'];
function DoubanService($http) {
this.$http = $http;
}
DoubanService.prototype.userInfo = function(user, callback, error) {
return this.$http({
url: "http://api.douban.com/v2/user/" + user,
method: 'GET',
timeout: 10000
}).success(function(data, status, headers, config) {
if (status === 200) {
return callback(data);
} else {
return error(data);
}
}).error(function(data) {
return error(data);
});
};
return DoubanService;
})();
libr.service('DoubanService', DoubanService);
}).call(this);
@@ -3,14 +3,32 @@
<button class="button button-icon ion-arrow-left-c" ng-click="closeDialog()"></button>
<h1 class="title"><img src="img/douban_24.png">从豆瓣读书导入书籍</h1>
</header>
<ion-content has-header="true" padding="true">
<label class="item item-input">
<span class="input-label">豆瓣用户名</span>
<input type="text" placeholder="请输入豆瓣用户名" ng-model="user.email">
</label>
<button class="button button-full button-energized" ng-click="doComment()">
提交
</button>
<form novalidate>
<label class="item item-input">
<span class="input-label">豆瓣用户名</span>
<input type="text" placeholder="请输入豆瓣用户名" ng-model="user">
</label>
<button class="button button-full button-royal" ng-click="searchDoubanUser(user)">
搜索用户
</button>
<button type="submit" class="button button-full button-energized" ng-click="searchDoubanUser(user)">
提交
</button>
</form>
<p>注意:绑定后不能更改用户名,请填入正确的用户名</p>
<hr>
<div ng-if="resultEnabled">
<h3>我们找到以下用户:</h3>
<p>昵称:{{doubanUser.name}}</p>
<p>描述:{{doubanUser.desc}}</p>
<img data-ng-src="{{doubanUser.large_avatar}}">
<p><b>注意:</b>如果正确请点击提交按钮</p>
</div>
</ion-content>
</div>
+1
View File
@@ -28,6 +28,7 @@
<script src="js/app.js"></script>
<script src="js/app/handler/error-handler.js"></script>
<script src="js/services.js"></script>
<script src="js/app/services/douban-service.js"></script>
<script src="js/app/services/authication-service.js"></script>
<script src="js/app/services/scan-service.js"></script>
<script src="js/app/services/geolocation.js"></script>
+1
View File
@@ -5,6 +5,7 @@
// 'libr.controllers' is found in controllers.js
angular.module('libr', ['ionic', 'libr.services', 'libr.controllers', 'libr.services.scan',
'libr.handlers.errorHandler',
'libr.services.douban',
'libr.services.geolocation',
'libr.services.auth',
'libr.services.books',
+15 -2
View File
@@ -2,8 +2,8 @@ libr = angular.module 'libr.controllers.books', ['ionic']
class BooksController
@$inject: ['$scope', 'Books', 'ScanService', '$ionicModal']
constructor: (@$scope, @Books, ScanService, @$ionicModal) ->
@$inject: ['$scope', 'Books', 'ScanService', '$ionicModal', 'DoubanService']
constructor: (@$scope, @Books, ScanService, @$ionicModal, @DoubanService) ->
currentPage = localStorage.setItem 'user_books_current_page', 0
@$scope.books = []
@$scope.moreItemsAvailable = true
@@ -35,6 +35,7 @@ class BooksController
@$scope.onRefresh = @refresh
@$scope.loadMore = @loadMore
@$scope.closeDialog = @closeDialog
@$scope.searchDoubanUser = @searchDoubanUser
refresh: ()=>
afterBookId = localStorage.getItem 'user_max_book_id'
@@ -70,4 +71,16 @@ class BooksController
closeDialog: =>
@$scope.modal.hide()
searchDoubanUser: (user)=>
if user is undefined or user.trim() is ''
alert '请输入有效昵称'
else
@DoubanService.userInfo user,
(data)=>
@$scope.resultEnabled = true
@$scope.doubanUser = data
, (error)=>
console.log error
libr.controller 'BooksController', BooksController
+22 -2
View File
@@ -6,13 +6,15 @@
libr = angular.module('libr.controllers.books', ['ionic']);
BooksController = (function() {
BooksController.$inject = ['$scope', 'Books', 'ScanService', '$ionicModal'];
BooksController.$inject = ['$scope', 'Books', 'ScanService', '$ionicModal', 'DoubanService'];
function BooksController($scope, Books, ScanService, $ionicModal) {
function BooksController($scope, Books, ScanService, $ionicModal, DoubanService) {
var currentPage;
this.$scope = $scope;
this.Books = Books;
this.$ionicModal = $ionicModal;
this.DoubanService = DoubanService;
this.searchDoubanUser = __bind(this.searchDoubanUser, this);
this.closeDialog = __bind(this.closeDialog, this);
this.loadMore = __bind(this.loadMore, this);
this.refresh = __bind(this.refresh, this);
@@ -53,6 +55,7 @@
this.$scope.onRefresh = this.refresh;
this.$scope.loadMore = this.loadMore;
this.$scope.closeDialog = this.closeDialog;
this.$scope.searchDoubanUser = this.searchDoubanUser;
}
BooksController.prototype.refresh = function() {
@@ -107,6 +110,23 @@
return this.$scope.modal.hide();
};
BooksController.prototype.searchDoubanUser = function(user) {
if (user === void 0 || user.trim() === '') {
return alert('请输入有效昵称');
} else {
return this.DoubanService.userInfo(user, (function(_this) {
return function(data) {
_this.$scope.resultEnabled = true;
return _this.$scope.doubanUser = data;
};
})(this), (function(_this) {
return function(error) {
return console.log(error);
};
})(this));
}
};
return BooksController;
})();
+25
View File
@@ -0,0 +1,25 @@
libr = angular.module 'libr.services.douban', []
class DoubanService
@$inject: ['$http']
constructor: (@$http)->
userInfo: (user, callback, error)->
@$http(
url: "http://api.douban.com/v2/user/#{user}"
method: 'GET'
timeout: 10000
)
.success (data, status, headers, config)->
if status is 200
callback data
else
error data
.error (data)->
error data
libr.service 'DoubanService', DoubanService
+36
View File
@@ -0,0 +1,36 @@
// Generated by CoffeeScript 1.7.1
(function() {
var DoubanService, libr;
libr = angular.module('libr.services.douban', []);
DoubanService = (function() {
DoubanService.$inject = ['$http'];
function DoubanService($http) {
this.$http = $http;
}
DoubanService.prototype.userInfo = function(user, callback, error) {
return this.$http({
url: "http://api.douban.com/v2/user/" + user,
method: 'GET',
timeout: 10000
}).success(function(data, status, headers, config) {
if (status === 200) {
return callback(data);
} else {
return error(data);
}
}).error(function(data) {
return error(data);
});
};
return DoubanService;
})();
libr.service('DoubanService', DoubanService);
}).call(this);
+25 -7
View File
@@ -3,14 +3,32 @@
<button class="button button-icon ion-arrow-left-c" ng-click="closeDialog()"></button>
<h1 class="title"><img src="img/douban_24.png">从豆瓣读书导入书籍</h1>
</header>
<ion-content has-header="true" padding="true">
<label class="item item-input">
<span class="input-label">豆瓣用户名</span>
<input type="text" placeholder="请输入豆瓣用户名" ng-model="user.email">
</label>
<button class="button button-full button-energized" ng-click="doComment()">
提交
</button>
<form novalidate>
<label class="item item-input">
<span class="input-label">豆瓣用户名</span>
<input type="text" placeholder="请输入豆瓣用户名" ng-model="user">
</label>
<button class="button button-full button-royal" ng-click="searchDoubanUser(user)">
搜索用户
</button>
<button type="submit" class="button button-full button-energized" ng-click="searchDoubanUser(user)">
提交
</button>
</form>
<p>注意:绑定后不能更改用户名,请填入正确的用户名</p>
<hr>
<div ng-if="resultEnabled">
<h3>我们找到以下用户:</h3>
<p>昵称:{{doubanUser.name}}</p>
<p>描述:{{doubanUser.desc}}</p>
<img data-ng-src="{{doubanUser.large_avatar}}">
<p><b>注意:</b>如果正确请点击提交按钮</p>
</div>
</ion-content>
</div>