remove auto generated js files

This commit is contained in:
2014-04-01 20:58:17 +08:00
parent 11232bbddf
commit 133ca23394
25 changed files with 138 additions and 31 deletions
+1
View File
@@ -0,0 +1 @@
baseUrl = "http://libr.herokuapp.com/api/v1"
+1
View File
@@ -0,0 +1 @@
baseUrl = "http://localhost:3000/api/v1"
+1
View File
@@ -0,0 +1 @@
baseUrl = "http://libr.herokuapp.com/api/v1"
+18 -4
View File
@@ -4,18 +4,26 @@ var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var exec = require('gulp-exec');
var paths = {
scripts: ['www/js/app/utils/*.coffee',
scripts: [
'www/js/app/utils/*.coffee',
'www/js/app/handler/*.coffee',
'www/js/app/services/*.coffee',
'www/js/app/controllers/*.coffee',
'www/js/*.coffee'],
css: ['www/css/*.css'],
fonts: ['www/fonts/*.*']
fonts: ['www/fonts/*.*'],
dev:['env/dev/**.js'],
local:['env/local/**.js'],
prod:['env/local/**.js']
};
var options = {
silent: false
};
gulp.task('css', function () {
var opts = {
@@ -30,7 +38,7 @@ gulp.task('css', function () {
});
gulp.task('scripts', function () {
gulp.src(paths.scripts)
gulp.src(paths.scripts.concat(paths.dev))
.pipe(coffee())
.pipe(uglify({mangle: false}))
.pipe(concat('all.min.js'))
@@ -45,8 +53,14 @@ gulp.task('fonts', function () {
gulp.task('watch', function () {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.css, ['css']);
});
gulp.task('default', ['scripts', 'css', 'watch','fonts']);
gulp.task('server',function(){
gulp.src('')
.pipe(exec('http-server ./www/ -p 4000'),options);
});
gulp.task('default', ['scripts', 'css', 'watch','fonts','server']);
gulp.task('dist',['scripts','css','fonts']);
+7 -2
View File
@@ -14,6 +14,11 @@
"gulp-coffee": ">=1.4.1",
"gulp-minify-css":">= 0.3.0",
"gulp-concat":">=2.1.7",
"gulp-uglify":">=0.2.1"
}
"gulp-uglify":">=0.2.1t",
"gulp-exec":">=1.0.4"
},
"scripts": {
"preinstall": "npm install -g http-server"
}
}
@@ -6,6 +6,9 @@
<option name="LIBRARY_PROJECT" value="true" />
</configuration>
</facet>
<facet type="android" name="Android2">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
@@ -1,5 +1,5 @@
#Last build type
#Mon, 31 Mar 2014 18:47:45 +0800
#Tue, 01 Apr 2014 20:43:48 +0800
build.last.target=debug
+4
View File
@@ -4,6 +4,9 @@
<facet type="android" name="Android">
<configuration />
</facet>
<facet type="android" name="Android2">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
@@ -16,6 +19,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="classes" level="project" />
<orderEntry type="module" module-name="CordovaLib" />
<orderEntry type="module" module-name="CordovaLib" />
</component>
</module>
+4 -3
View File
@@ -7,11 +7,12 @@
(function(){var GeolocationService,libr;libr=angular.module("libr.services.geolocation",[]),GeolocationService=function(){function GeolocationService($http){this.$http=$http}var getLocation,onError,onSuccess;return GeolocationService.$inject=["$http"],onSuccess=function(position){return alert("lat"+position.coords.latitude),{Latitude:position.coords.latitude,Longitude:position.coords.longitude,Altitude:position.coords.altitude,Accuracy:position.coords.accuracy,"Altitude Accuracy":position.coords.altitudeAccuracy,Heading:position.coords.heading,Speed:position.coords.speed,Timestamp:position.timestamp}},onError=function(error){throw"code: "+error.code+" \n message: "+error.message},GeolocationService.prototype.getCurrentLocation=function(callback,error){return navigator.geolocation.getCurrentPosition(callback,error)},GeolocationService.prototype.getDetailAddress=function(callback){var baseUrl;return baseUrl="http://libr.herokuapp.com/api/v1/locations/detail",this.getCurrentLocation(function(_this){return function(position){return _this.$http({url:""+baseUrl+"?lat="+position.coords.latitude+"&lng="+position.coords.longitude,cache:!0,method:"GET"}).success(function(data){return callback(data)})}}(this),function(error){throw Error(error)})},GeolocationService.prototype.getLocations=function(callback,error){var baseUrl,email,token;return baseUrl="http://libr.herokuapp.com/api/v1/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"?user_email="+email+"&user_token="+token,method:"GET",cache:!1}).success(function(data){return callback(data)}).error(function(){throw Error(error)})},GeolocationService.prototype.createLocation=function(callback){var baseUrl,email,location,token;return baseUrl="http://libr.herokuapp.com/api/v1/locations",location=getLocation(),email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"POST",url:baseUrl+("?user_email="+email+"&user_token="+token),data:"address="+location.address+"&lat="+location.lat+"&lng="+location.lng,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return callback(data)})},GeolocationService.prototype.deleteLocation=function(item,callback){var baseUrl,email,token;return baseUrl="http://libr.herokuapp.com/api/v1/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"DELETE",url:baseUrl+("?user_email="+email+"&user_token="+token+"&id="+item.id),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return console.log("=====",data),callback(data)})},getLocation=function(){var location;return location={},location.address=localStorage.getItem("cur_address_detail"),location.lat=localStorage.getItem("cur_lat"),location.lng=localStorage.getItem("cur_lng"),location},GeolocationService}(),libr.service("GeolocationService",GeolocationService)}).call(this);
(function(){var RecommendService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.recommend",[]),RecommendService=function(){function RecommendService(GeolocationService,$http){this.GeolocationService=GeolocationService,this.$http=$http,this.changeRecommendAction=__bind(this.changeRecommendAction,this),this.popularBooksAroundMe=__bind(this.popularBooksAroundMe,this)}var baseUrl;return baseUrl="http://libr.herokuapp.com/api/v1",RecommendService.$injector=["GeolocationService","$http"],RecommendService.prototype.getActionSheetList=function(){var actionList;return actionList=[],actionList.push({text:"你可能喜欢的书"}),this.GeolocationService.getLocations(function(){return function(locations){var locationIds;return locationIds=[],locations.map(function(location){return locationIds.push(location.id),location={text:""+location.address+"附近流行的书"},actionList.push(location)}),localStorage.setItem("recommend_action_sheet_arr",JSON.stringify(locationIds)),localStorage.setItem("recommend_action_sheet_full_arr",JSON.stringify(actionList))}}(this)),actionList},RecommendService.prototype.popularBooksForMe=function(callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"/recommend/me?user_email="+email+"&user_token="+token,method:"GET",timeout:13e3}).success(function(data){return callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.popularBooksAroundMe=function(locationId,callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"/recommend/locations/"+locationId+"?user_email="+email+"&user_token="+token,method:"GET",timeout:13e3}).success(function(data){return console.log("数据",data),callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.changeRecommendAction=function(index,callback,error){var locations;return 0===index?this.popularBooksForMe(callback,error):(locations=JSON.parse(localStorage.getItem("recommend_action_sheet_arr")),this.popularBooksAroundMe(locations[index-1],function(result){return console.log("callback....",result),callback(result)},function(errorMessage){return error(errorMessage)}))},RecommendService}(),libr.service("RecommendService",RecommendService)}).call(this);
(function(){var ScanService,libr;libr=angular.module("libr.services.scan",[]),ScanService=function(){function ScanService(Books){this.Books=Books}return ScanService.$inject=["Books"],ScanService.prototype.scan=function(callback,errorCallback){return setTimeout(function(_this){return function(){return cordova.plugins.barcodeScanner.scan(function(result){return 1!==result.cancelled?"EAN_13"!==result.format?void errorCallback("条形码类型不匹配,请确认所扫为书籍,并尝试更换角度"):_this.Books.save({isbn:result.text},null,function(data){return"error"===data.status?errorCallback(data.message):callback(data)},function(error){return errorCallback("添加图书失败"+error.toString())}):void 0},function(error){return errorCallback("Scanning failed:"+error+" ")})}}(this),600),navigator.notification.vibrate(50)},ScanService}(),libr.service("ScanService",ScanService)}).call(this);
(function(){var BooksController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.books",["ionic"]),BooksController=function(){function BooksController($scope,Books,ScanService,$ionicModal,DoubanService,IonicUtils){var currentPage;this.$scope=$scope,this.Books=Books,this.ScanService=ScanService,this.$ionicModal=$ionicModal,this.DoubanService=DoubanService,this.IonicUtils=IonicUtils,this.submitDoubanUser=__bind(this.submitDoubanUser,this),this.scanBooks=__bind(this.scanBooks,this),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),this.$scope.books=[],this.$scope.moreItemsAvailable=!0,this.$scope.submitAllowed=!0,this.$ionicModal.fromTemplateUrl("templates/modal/import_books.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.$scope.data={isLoading:!1,text:null},this.IonicUtils.initCustomLoading(this.$scope),this.$scope.onRefresh=this.refresh,this.$scope.loadMore=this.loadMore,this.$scope.closeDialog=this.closeDialog,this.$scope.searchDoubanUser=this.searchDoubanUser,this.$scope.scanBooks=this.scanBooks,this.$scope.submitDoubanUser=this.submitDoubanUser,this.$scope.doubanInputDisabled=!1}return BooksController.$inject=["$scope","Books","ScanService","$ionicModal","DoubanService","IonicUtils"],BooksController.prototype.refresh=function(){var afterBookId;return afterBookId=localStorage.getItem("user_max_book_id"),this.Books.fetchNew({afterId:afterBookId},function(_this){return function(data){return _this.$scope.$broadcast("scroll.refreshComplete"),0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),data.books.forEach(function(item){return _this.$scope.books.push(item)})):void 0}}(this))},BooksController.prototype.loadMore=function(){var currentPage,maxPage;return currentPage=localStorage.getItem("user_books_current_page"),maxPage=localStorage.getItem("user_books_max_page"),maxPage=parseInt(maxPage),currentPage=parseInt(currentPage),currentPage>=maxPage?(this.$scope.$broadcast("scroll.infiniteScrollComplete"),this.$scope.moreItemsAvailable=!1):this.Books.query({page:currentPage+1},function(_this){return function(data){return 0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),localStorage.setItem("user_books_current_page",data.current_page),localStorage.setItem("user_books_max_page",data.total_page),data.books.forEach(function(item){return _this.$scope.books.push(item)})):_this.$scope.moreItemsAvailable=!1,_this.$scope.$broadcast("scroll.infiniteScrollComplete")}}(this))},BooksController.prototype.closeDialog=function(){return this.$scope.modal.hide()},BooksController.prototype.searchDoubanUser=function(user){return void 0===user||""===user.trim()?alert("请输入有效昵称"):this.DoubanService.userInfo(user,function(_this){return function(data){return _this.$scope.resultEnabled=!0,_this.$scope.submitAllowed=!0,_this.$scope.doubanUser=data}}(this),function(_this){return function(error){return console.log(error),_this.$scope.resultEnabled=!1,_this.$scope.submitAllowed=!1}}(this))},BooksController.prototype.scanBooks=function(){return this.ScanService.scan(function(_this){return function(result){return navigator.notification.alert("添加图书《"+result.book.name+"》成功",null,"Libr","确定"),_this.$scope.books.unshift(result.book)}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,error)}}(this))},BooksController.prototype.submitDoubanUser=function(){var username;return username=angular.element(document.getElementById("douban-username")),username=username.val(),this.DoubanService.submitUser(username,function(_this){return function(){return _this.$scope.doubanInputDisabled=!0,alert("成功绑定豆瓣用户",function(){return alert("绑定豆瓣用户失败,请稍后再试")})}}(this))},BooksController}(),libr.controller("BooksController",BooksController)}).call(this);
(function(){var BookService,libr;libr=angular.module("libr.services",["ngResource"]),BookService=function(){function BookService($http){var baseUrl,bookFactory;return baseUrl="http://libr.herokuapp.com/api/v1/books",bookFactory={},bookFactory.getBook=function(isbn){return $http.get(baseUrl+"/bookinfo/"+isbn)},bookFactory}return BookService.$inject=["$http"],BookService}(),libr.factory("BookService",BookService)}).call(this);
(function(){var BooksController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.books",["ionic"]),BooksController=function(){function BooksController($scope,Books,ScanService,$ionicModal,DoubanService,IonicUtils){var currentPage;this.$scope=$scope,this.Books=Books,this.ScanService=ScanService,this.$ionicModal=$ionicModal,this.DoubanService=DoubanService,this.IonicUtils=IonicUtils,this.submitDoubanUser=__bind(this.submitDoubanUser,this),this.scanBooks=__bind(this.scanBooks,this),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),this.$scope.books=[],this.$scope.moreItemsAvailable=!0,this.$scope.submitAllowed=!0,this.$ionicModal.fromTemplateUrl("templates/modal/import_books.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.$scope.data={isLoading:!1,text:null},this.IonicUtils.initCustomLoading(this.$scope),this.$scope.onRefresh=this.refresh,this.$scope.loadMore=this.loadMore,this.$scope.closeDialog=this.closeDialog,this.$scope.searchDoubanUser=this.searchDoubanUser,this.$scope.scanBooks=this.scanBooks,this.$scope.submitDoubanUser=this.submitDoubanUser,this.$scope.doubanInputDisabled=!1}return BooksController.$inject=["$scope","Books","ScanService","$ionicModal","DoubanService","IonicUtils"],BooksController.prototype.refresh=function(){var afterBookId;return afterBookId=localStorage.getItem("user_max_book_id"),this.Books.fetchNew({afterId:afterBookId},function(_this){return function(data){return _this.$scope.$broadcast("scroll.refreshComplete"),0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),data.books.forEach(function(item){return _this.$scope.books.push(item)})):void 0}}(this))},BooksController.prototype.loadMore=function(){var currentPage,maxPage;return currentPage=localStorage.getItem("user_books_current_page"),maxPage=localStorage.getItem("user_books_max_page"),maxPage=parseInt(maxPage),currentPage=parseInt(currentPage),currentPage>=maxPage?(this.$scope.$broadcast("scroll.infiniteScrollComplete"),this.$scope.moreItemsAvailable=!1):this.Books.query({page:currentPage+1},function(_this){return function(data){return 0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),localStorage.setItem("user_books_current_page",data.current_page),localStorage.setItem("user_books_max_page",data.total_page),data.books.forEach(function(item){return _this.$scope.books.push(item)})):_this.$scope.moreItemsAvailable=!1,_this.$scope.$broadcast("scroll.infiniteScrollComplete")}}(this))},BooksController.prototype.closeDialog=function(){return this.$scope.modal.hide()},BooksController.prototype.searchDoubanUser=function(user){return void 0===user||""===user.trim()?this.IonicUtils.showLoading(this.$scope,"请输入有效昵称"):this.DoubanService.userInfo(user,function(_this){return function(data){return _this.$scope.resultEnabled=!0,_this.$scope.submitAllowed=!0,_this.$scope.doubanUser=data}}(this),function(_this){return function(error){return console.log(error),_this.$scope.resultEnabled=!1,_this.$scope.submitAllowed=!1}}(this))},BooksController.prototype.scanBooks=function(){return this.ScanService.scan(function(_this){return function(result){return navigator.notification.alert("添加图书《"+result.book.name+"》成功",null,"Libr","确定"),_this.$scope.books.unshift(result.book)}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,error)}}(this))},BooksController.prototype.submitDoubanUser=function(){var username;return username=angular.element(document.getElementById("douban-username")),username=username.val(),this.DoubanService.submitUser(username,function(_this){return function(){return _this.$scope.doubanInputDisabled=!0,alert("成功绑定豆瓣用户",function(){return _this.IonicUtils.showLoading(_this.$scope,"绑定豆瓣用户失败,请稍后再试")})}}(this))},BooksController}(),libr.controller("BooksController",BooksController)}).call(this);
(function(){var BookDetailController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers",["ionic"]),BookDetailController=function(){function BookDetailController($scope,$stateParams,BookService,$window,$ionicModal,Comments,IonicUtils){this.$scope=$scope,this.$stateParams=$stateParams,this.BookService=BookService,this.$window=$window,this.$ionicModal=$ionicModal,this.Comments=Comments,this.IonicUtils=IonicUtils,this.back=__bind(this.back,this),this.doComment=__bind(this.doComment,this),this.closeCommentDialog=__bind(this.closeCommentDialog,this),this.openCommentDialog=__bind(this.openCommentDialog,this),this.$scope.openDialog=this.openCommentDialog,this.$scope.closeDialog=this.closeCommentDialog,this.$scope.doComment=this.doComment,this.$scope.back=this.back,this.$ionicModal.fromTemplateUrl("templates/modal/comment.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),BookService.getBook(this.$stateParams.isbn).success(function(_this){return function(result){return _this.$scope.book=result,_this.$scope.usersAccount=result.users.length,_this.$scope.bookName=_this.$scope.book.name,_this.Comments.query({book_id:result.id},function(data){return console.log(data),_this.$scope.comments=data})}}(this)),this.$scope.$on("$destroy",function(_this){return function(){return _this.$scope.modal.remove()}}(this)),this.IonicUtils.initCustomLoading(this.$scope)}return BookDetailController.$inject=["$scope","$stateParams","BookService","$window","$ionicModal","Comments","IonicUtils"],BookDetailController.prototype.openCommentDialog=function(){return this.$scope.modal.show()},BookDetailController.prototype.closeCommentDialog=function(){return this.$scope.modal.hide()},BookDetailController.prototype.doComment=function(){var text;return text=angular.element(document.getElementById("comment")).val(),""===text.trim()?(this.IonicUtils.showLoading(this.$scope,"请输入有效字符"),!1):this.Comments.save({book_id:this.$scope.book.id,content:text},null,function(_this){return function(data){return null===data.id?_this.IonicUtils.showLoading(_this.$scope,"添加图书评论失败"):(console.log("成功。。。。。。。"),_this.$scope.comments.push(data),_this.closeCommentDialog())}}(this))},BookDetailController.prototype.back=function(){return this.$window.history.back()},BookDetailController}(),libr.controller("BookDetailController",BookDetailController)}).call(this);
(function(){var HomeController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.home",["ionic"]),HomeController=function(){function HomeController($scope,$location,BookService,ScanService,$ionicLoading,$ionicActionSheet,RecommendService,ErrorHandler){return this.$scope=$scope,this.$location=$location,this.$ionicLoading=$ionicLoading,this.$ionicActionSheet=$ionicActionSheet,this.RecommendService=RecommendService,this.ErrorHandler=ErrorHandler,this.changeRecommend=__bind(this.changeRecommend,this),this.showRecommendActionSheet=__bind(this.showRecommendActionSheet,this),this.$scope.showRecommendActionSheet=this.showRecommendActionSheet,isUserLogedIn()?(showLoading(this.$scope,this.$ionicLoading),this.$scope.title="你可能喜欢的书",this.RecommendService.popularBooksForMe(function(_this){return function(result){return 0===result.length?alert("请先添加一些你阅读的书,再来查看推荐吧"):_this.$scope.books=result,_this.$scope.loading.hide()}}(this),function(_this){return function(){return _this.ErrorHandler.loadingHandler(_this.$scope,null)}}(this)),void 0):void this.$location.path("/tab/settings")}var isUserLogedIn,showLoading;return HomeController.$inject=["$scope","$location","BookService","ScanService","$ionicLoading","$ionicActionSheet","RecommendService","ErrorHandler"],showLoading=function($scope,$ionicLoading){return $scope.loading=$ionicLoading.show({content:"加载中",animation:"fade-in",showBackdrop:!0,maxWidth:200,showDelay:500})},isUserLogedIn=function(){return null!==localStorage.getItem("token")&&null!==localStorage.getItem("email")?!0:!1},HomeController.prototype.showRecommendActionSheet=function(){return this.$ionicActionSheet.show({titleText:"Libr 为你推荐",buttons:this.RecommendService.getActionSheetList(),cancelText:"取消",cancel:function(){return console.log("CANCELLED")},buttonClicked:function(_this){return function(index){return console.log(""+index+" has been taped"),_this.changeRecommend(index),!0}}(this)})},HomeController.prototype.changeRecommend=function(index){var msg;return msg="喔,看来附近还没有好书推荐,快去推荐你的朋友也来使用吧!",this.RecommendService.changeRecommendAction(index,function(_this){return function(result){var listArray;return 0===result.length?navigator.notification.alert(msg,null,"libr","确定"):(_this.$scope.books=result,listArray=JSON.parse(localStorage.getItem("recommend_action_sheet_full_arr")),_this.$scope.title=listArray[index].text)}}(this),function(_this){return function(){return _this.ErrorHandler.whenError(null)}}(this))},HomeController}(),libr.controller("HomeCtrl",HomeController)}).call(this);
(function(){var LocationController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.location",["ionic"]),LocationController=function(){function LocationController($scope,$location,GeolocationService,IonicUtils){this.$scope=$scope,this.$location=$location,this.GeolocationService=GeolocationService,this.IonicUtils=IonicUtils,this.addLocation=__bind(this.addLocation,this),this.$scope.addLocation=this.addLocation,this.$scope.itemButtons=[{text:"删除",type:"button-assertive",onTap:function(_this){return function(item){return _this.GeolocationService.deleteLocation(item,function(){return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item),1)})}}(this)}],this.GeolocationService.getLocations(function(_this){return function(locations){return _this.$scope.locations=locations}}(this)),this.GeolocationService.getDetailAddress(function(_this){return function(position){return localStorage.setItem("cur_address_detail",position.result.formatted_address),localStorage.setItem("cur_lat",position.result.location.lat),localStorage.setItem("cur_lng",position.result.location.lng),_this.$scope.address=position.result.formatted_address}}(this)),this.IonicUtils.initCustomLoading(this.$scope)}return LocationController.$inject=["$scope","$location","GeolocationService","IonicUtils"],LocationController.prototype.addLocation=function(){return this.$scope.locations.length>=3?this.IonicUtils.showLoading(this.$scope,"只能创建3个常用的地址哦,你可以尝试删除部分,再添加"):null===localStorage.getItem("cur_address_detail")?this.IonicUtils.showLoading(this.$scope,"定位成功后方可添加常用地址"):this.GeolocationService.createLocation(function(_this){return function(result){return _this.$scope.locations.push(result)}}(this))},LocationController}(),libr.controller("LocationController",LocationController)}).call(this);
(function(){var LoginController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.login",["ionic"]),LoginController=function(){function LoginController($scope,AuthService,$state,$ionicModal,IonicUtils){this.$scope=$scope,this.AuthService=AuthService,this.$state=$state,this.$ionicModal=$ionicModal,this.IonicUtils=IonicUtils,this.closeDialog=__bind(this.closeDialog,this),this.registerUser=__bind(this.registerUser,this),this.registerForm=__bind(this.registerForm,this),this.login=__bind(this.login,this),isUserLogedIn()&&this.$state.go("tab.home"),this.$scope.login=this.login,this.$scope.registerForm=this.registerForm,this.$scope.registerUser=this.registerUser,this.$scope.closeDialog=this.closeDialog,this.$ionicModal.fromTemplateUrl("templates/modal/registration.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.IonicUtils.initCustomLoading(this.$scope)}var isUserLogedIn;return LoginController.$inject=["$scope","AuthService","$state","$ionicModal","IonicUtils"],LoginController.prototype.login=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.login(user,function(_this){return function(result){return localStorage.setItem("token",result.user.token),localStorage.setItem("avatar",result.user.avatar),localStorage.setItem("username",result.user.name),localStorage.setItem("email",user.email),_this.$state.go("tab.home")}}(this),function(_this){return function(data){return _this.IonicUtils.showLoading(_this.$scope,data)}}(this)):void this.IonicUtils.showLoading(this.$scope,"请输入有效的用户名和密码")},isUserLogedIn=function(){return null!==localStorage.getItem("token")&&null!==localStorage.getItem("email")?!0:!1},LoginController.prototype.registerForm=function(){return this.$scope.modal.show()},LoginController.prototype.registerUser=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.register(user,function(_this){return function(result,status){return 201===status?(alert("注册成功,请返回登录"),_this.$scope.modal.hide()):_this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试")}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试"),console.log("registerError",error)}}(this)):void this.IonicUtils.showLoading(this.$scope,"请输入有效的用户名和密码")},LoginController.prototype.closeDialog=function(){return this.$scope.modal.hide()},LoginController}(),libr.controller("LoginController",LoginController)}).call(this);
(function(){var MainController,libr;libr=angular.module("libr.controllers.main",["ionic"]),MainController=function(){function MainController($scope,$location,$ionicModal,$state){this.$scope=$scope,this.$location=$location,this.$ionicModal=$ionicModal,this.$state=$state}return MainController.$inject=["$scope","$location","$ionicModal","$state"],MainController}(),libr.controller("MainCtrl",MainController)}).call(this);
(function(){var SettingsController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.settings",["ionic"]),SettingsController=function(){function SettingsController($scope,$ionicModal,AuthService,$state,$cacheFactory){this.$scope=$scope,this.$ionicModal=$ionicModal,this.AuthService=AuthService,this.$state=$state,this.$cacheFactory=$cacheFactory,this.logout=__bind(this.logout,this),this.$scope.logout=this.logout,this.$scope.feedback=this.feedback,this.$scope.showMe=this.showMe,this.$scope.isLogedIn=isUserLogedIn()?!0:!1,this.$scope.avatar=localStorage.getItem("avatar"),this.$scope.username=localStorage.getItem("username")}var isUserLogedIn;return SettingsController.$inject=["$scope","$ionicModal","AuthService","$state","$cacheFactory"],SettingsController.prototype.logout=function(){var httpDefaultCache;return localStorage.clear(),httpDefaultCache=this.$cacheFactory.get("$http"),console.log("cacheFactory",httpDefaultCache),httpDefaultCache.removeAll(),this.$state.go("login")},SettingsController.prototype.feedback=function(){return window.open("https://jinshuju.net/f/F96z3s","_blank","location=no")},SettingsController.prototype.showMe=function(){return window.open("http://libr.herokuapp.com","_blank","location=no")},isUserLogedIn=function(){return null!==localStorage.getItem("token")&&null!==localStorage.getItem("email")?!0:!1},SettingsController}(),libr.controller("SettingsController",SettingsController)}).call(this);
(function(){var BookDetailController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers",["ionic"]),BookDetailController=function(){function BookDetailController($scope,$stateParams,BookService,$window,$ionicModal,Comments){this.$scope=$scope,this.$stateParams=$stateParams,this.BookService=BookService,this.$window=$window,this.$ionicModal=$ionicModal,this.Comments=Comments,this.back=__bind(this.back,this),this.doComment=__bind(this.doComment,this),this.closeCommentDialog=__bind(this.closeCommentDialog,this),this.openCommentDialog=__bind(this.openCommentDialog,this),this.$scope.openDialog=this.openCommentDialog,this.$scope.closeDialog=this.closeCommentDialog,this.$scope.doComment=this.doComment,this.$scope.back=this.back,this.$ionicModal.fromTemplateUrl("templates/modal/comment.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),BookService.getBook(this.$stateParams.isbn).success(function(_this){return function(result){return _this.$scope.book=result,_this.$scope.usersAccount=result.users.length,_this.$scope.bookName=_this.$scope.book.name,_this.Comments.query({book_id:result.id},function(data){return console.log(data),_this.$scope.comments=data})}}(this)),this.$scope.$on("$destroy",function(_this){return function(){return _this.$scope.modal.remove()}}(this))}return BookDetailController.$inject=["$scope","$stateParams","BookService","$window","$ionicModal","Comments"],BookDetailController.prototype.openCommentDialog=function(){return this.$scope.modal.show()},BookDetailController.prototype.closeCommentDialog=function(){return this.$scope.modal.hide()},BookDetailController.prototype.doComment=function(){var text;return text=angular.element(document.getElementById("comment")).val(),""===text.trim()?(alert("请输入有效字符"),!1):this.Comments.save({book_id:this.$scope.book.id,content:text},null,function(_this){return function(data){return null===data.id?alert("添加图书失败"):(console.log("成功。。。。。。。"),_this.$scope.comments.push(data),_this.closeCommentDialog())}}(this))},BookDetailController.prototype.back=function(){return this.$window.history.back()},BookDetailController}(),libr.controller("BookDetailController",BookDetailController)}).call(this);
(function(){var BookService,libr;libr=angular.module("libr.services",["ngResource"]),BookService=function(){function BookService($http){var baseUrl,bookFactory;return baseUrl="http://libr.herokuapp.com/api/v1/books",bookFactory={},bookFactory.getBook=function(isbn){return $http.get(baseUrl+"/bookinfo/"+isbn)},bookFactory}return BookService.$inject=["$http"],BookService}(),libr.factory("BookService",BookService)}).call(this);
(function(){var baseUrl;baseUrl="http://libr.herokuapp.com/api/v1"}).call(this);
-1
View File
@@ -22,5 +22,4 @@
<script src="dist/js/all.min.js"></script>
<!--<script src="http://10.17.2.1:8080/target/target-script-min.js#anonymous"></script>-->
</body>
</html>
@@ -67,7 +67,7 @@ class BooksController
searchDoubanUser: (user)=>
if user is undefined or user.trim() is ''
alert '请输入有效昵称'
@IonicUtils.showLoading(@$scope,'请输入有效昵称')
else
@DoubanService.userInfo user,
(data)=>
@@ -94,7 +94,7 @@ class BooksController
@$scope.doubanInputDisabled = true
alert '成功绑定豆瓣用户'
, (data)->
alert '绑定豆瓣用户失败,请稍后再试'
, (data)=>
@IonicUtils.showLoading(@$scope,'绑定豆瓣用户失败,请稍后再试')
libr.controller 'BooksController', BooksController
@@ -58,4 +58,4 @@ class HomeController
@$scope.title = listArray[index].text
, (error)=>
@ErrorHandler.whenError null
libr.controller 'HomeCtrl', HomeController
libr.controller 'HomeCtrl', HomeController
@@ -3,6 +3,9 @@
<button class="button button-icon ion-arrow-left-c" ng-click="closeDialog()"></button>
<h1 class="title">添加评论</h1>
</header>
<div class="bar bar-loading bar-assertive" ng-if="data.isLoading">
{{data.text}}
</div>
<ion-content has-header="true" padding="true">
<textarea name="content" class="comment-container" id="comment">
</textarea>
@@ -10,4 +13,4 @@
提交
</button>
</ion-content>
</div>
</div>
+4 -3
View File
@@ -7,11 +7,12 @@
(function(){var GeolocationService,libr;libr=angular.module("libr.services.geolocation",[]),GeolocationService=function(){function GeolocationService($http){this.$http=$http}var getLocation,onError,onSuccess;return GeolocationService.$inject=["$http"],onSuccess=function(position){return alert("lat"+position.coords.latitude),{Latitude:position.coords.latitude,Longitude:position.coords.longitude,Altitude:position.coords.altitude,Accuracy:position.coords.accuracy,"Altitude Accuracy":position.coords.altitudeAccuracy,Heading:position.coords.heading,Speed:position.coords.speed,Timestamp:position.timestamp}},onError=function(error){throw"code: "+error.code+" \n message: "+error.message},GeolocationService.prototype.getCurrentLocation=function(callback,error){return navigator.geolocation.getCurrentPosition(callback,error)},GeolocationService.prototype.getDetailAddress=function(callback){var baseUrl;return baseUrl="http://libr.herokuapp.com/api/v1/locations/detail",this.getCurrentLocation(function(_this){return function(position){return _this.$http({url:""+baseUrl+"?lat="+position.coords.latitude+"&lng="+position.coords.longitude,cache:!0,method:"GET"}).success(function(data){return callback(data)})}}(this),function(error){throw Error(error)})},GeolocationService.prototype.getLocations=function(callback,error){var baseUrl,email,token;return baseUrl="http://libr.herokuapp.com/api/v1/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"?user_email="+email+"&user_token="+token,method:"GET",cache:!1}).success(function(data){return callback(data)}).error(function(){throw Error(error)})},GeolocationService.prototype.createLocation=function(callback){var baseUrl,email,location,token;return baseUrl="http://libr.herokuapp.com/api/v1/locations",location=getLocation(),email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"POST",url:baseUrl+("?user_email="+email+"&user_token="+token),data:"address="+location.address+"&lat="+location.lat+"&lng="+location.lng,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return callback(data)})},GeolocationService.prototype.deleteLocation=function(item,callback){var baseUrl,email,token;return baseUrl="http://libr.herokuapp.com/api/v1/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"DELETE",url:baseUrl+("?user_email="+email+"&user_token="+token+"&id="+item.id),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return console.log("=====",data),callback(data)})},getLocation=function(){var location;return location={},location.address=localStorage.getItem("cur_address_detail"),location.lat=localStorage.getItem("cur_lat"),location.lng=localStorage.getItem("cur_lng"),location},GeolocationService}(),libr.service("GeolocationService",GeolocationService)}).call(this);
(function(){var RecommendService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.recommend",[]),RecommendService=function(){function RecommendService(GeolocationService,$http){this.GeolocationService=GeolocationService,this.$http=$http,this.changeRecommendAction=__bind(this.changeRecommendAction,this),this.popularBooksAroundMe=__bind(this.popularBooksAroundMe,this)}var baseUrl;return baseUrl="http://libr.herokuapp.com/api/v1",RecommendService.$injector=["GeolocationService","$http"],RecommendService.prototype.getActionSheetList=function(){var actionList;return actionList=[],actionList.push({text:"你可能喜欢的书"}),this.GeolocationService.getLocations(function(){return function(locations){var locationIds;return locationIds=[],locations.map(function(location){return locationIds.push(location.id),location={text:""+location.address+"附近流行的书"},actionList.push(location)}),localStorage.setItem("recommend_action_sheet_arr",JSON.stringify(locationIds)),localStorage.setItem("recommend_action_sheet_full_arr",JSON.stringify(actionList))}}(this)),actionList},RecommendService.prototype.popularBooksForMe=function(callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"/recommend/me?user_email="+email+"&user_token="+token,method:"GET",timeout:13e3}).success(function(data){return callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.popularBooksAroundMe=function(locationId,callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"/recommend/locations/"+locationId+"?user_email="+email+"&user_token="+token,method:"GET",timeout:13e3}).success(function(data){return console.log("数据",data),callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.changeRecommendAction=function(index,callback,error){var locations;return 0===index?this.popularBooksForMe(callback,error):(locations=JSON.parse(localStorage.getItem("recommend_action_sheet_arr")),this.popularBooksAroundMe(locations[index-1],function(result){return console.log("callback....",result),callback(result)},function(errorMessage){return error(errorMessage)}))},RecommendService}(),libr.service("RecommendService",RecommendService)}).call(this);
(function(){var ScanService,libr;libr=angular.module("libr.services.scan",[]),ScanService=function(){function ScanService(Books){this.Books=Books}return ScanService.$inject=["Books"],ScanService.prototype.scan=function(callback,errorCallback){return setTimeout(function(_this){return function(){return cordova.plugins.barcodeScanner.scan(function(result){return 1!==result.cancelled?"EAN_13"!==result.format?void errorCallback("条形码类型不匹配,请确认所扫为书籍,并尝试更换角度"):_this.Books.save({isbn:result.text},null,function(data){return"error"===data.status?errorCallback(data.message):callback(data)},function(error){return errorCallback("添加图书失败"+error.toString())}):void 0},function(error){return errorCallback("Scanning failed:"+error+" ")})}}(this),600),navigator.notification.vibrate(50)},ScanService}(),libr.service("ScanService",ScanService)}).call(this);
(function(){var BooksController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.books",["ionic"]),BooksController=function(){function BooksController($scope,Books,ScanService,$ionicModal,DoubanService,IonicUtils){var currentPage;this.$scope=$scope,this.Books=Books,this.ScanService=ScanService,this.$ionicModal=$ionicModal,this.DoubanService=DoubanService,this.IonicUtils=IonicUtils,this.submitDoubanUser=__bind(this.submitDoubanUser,this),this.scanBooks=__bind(this.scanBooks,this),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),this.$scope.books=[],this.$scope.moreItemsAvailable=!0,this.$scope.submitAllowed=!0,this.$ionicModal.fromTemplateUrl("templates/modal/import_books.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.$scope.data={isLoading:!1,text:null},this.IonicUtils.initCustomLoading(this.$scope),this.$scope.onRefresh=this.refresh,this.$scope.loadMore=this.loadMore,this.$scope.closeDialog=this.closeDialog,this.$scope.searchDoubanUser=this.searchDoubanUser,this.$scope.scanBooks=this.scanBooks,this.$scope.submitDoubanUser=this.submitDoubanUser,this.$scope.doubanInputDisabled=!1}return BooksController.$inject=["$scope","Books","ScanService","$ionicModal","DoubanService","IonicUtils"],BooksController.prototype.refresh=function(){var afterBookId;return afterBookId=localStorage.getItem("user_max_book_id"),this.Books.fetchNew({afterId:afterBookId},function(_this){return function(data){return _this.$scope.$broadcast("scroll.refreshComplete"),0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),data.books.forEach(function(item){return _this.$scope.books.push(item)})):void 0}}(this))},BooksController.prototype.loadMore=function(){var currentPage,maxPage;return currentPage=localStorage.getItem("user_books_current_page"),maxPage=localStorage.getItem("user_books_max_page"),maxPage=parseInt(maxPage),currentPage=parseInt(currentPage),currentPage>=maxPage?(this.$scope.$broadcast("scroll.infiniteScrollComplete"),this.$scope.moreItemsAvailable=!1):this.Books.query({page:currentPage+1},function(_this){return function(data){return 0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),localStorage.setItem("user_books_current_page",data.current_page),localStorage.setItem("user_books_max_page",data.total_page),data.books.forEach(function(item){return _this.$scope.books.push(item)})):_this.$scope.moreItemsAvailable=!1,_this.$scope.$broadcast("scroll.infiniteScrollComplete")}}(this))},BooksController.prototype.closeDialog=function(){return this.$scope.modal.hide()},BooksController.prototype.searchDoubanUser=function(user){return void 0===user||""===user.trim()?alert("请输入有效昵称"):this.DoubanService.userInfo(user,function(_this){return function(data){return _this.$scope.resultEnabled=!0,_this.$scope.submitAllowed=!0,_this.$scope.doubanUser=data}}(this),function(_this){return function(error){return console.log(error),_this.$scope.resultEnabled=!1,_this.$scope.submitAllowed=!1}}(this))},BooksController.prototype.scanBooks=function(){return this.ScanService.scan(function(_this){return function(result){return navigator.notification.alert("添加图书《"+result.book.name+"》成功",null,"Libr","确定"),_this.$scope.books.unshift(result.book)}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,error)}}(this))},BooksController.prototype.submitDoubanUser=function(){var username;return username=angular.element(document.getElementById("douban-username")),username=username.val(),this.DoubanService.submitUser(username,function(_this){return function(){return _this.$scope.doubanInputDisabled=!0,alert("成功绑定豆瓣用户",function(){return alert("绑定豆瓣用户失败,请稍后再试")})}}(this))},BooksController}(),libr.controller("BooksController",BooksController)}).call(this);
(function(){var BookService,libr;libr=angular.module("libr.services",["ngResource"]),BookService=function(){function BookService($http){var baseUrl,bookFactory;return baseUrl="http://libr.herokuapp.com/api/v1/books",bookFactory={},bookFactory.getBook=function(isbn){return $http.get(baseUrl+"/bookinfo/"+isbn)},bookFactory}return BookService.$inject=["$http"],BookService}(),libr.factory("BookService",BookService)}).call(this);
(function(){var BooksController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.books",["ionic"]),BooksController=function(){function BooksController($scope,Books,ScanService,$ionicModal,DoubanService,IonicUtils){var currentPage;this.$scope=$scope,this.Books=Books,this.ScanService=ScanService,this.$ionicModal=$ionicModal,this.DoubanService=DoubanService,this.IonicUtils=IonicUtils,this.submitDoubanUser=__bind(this.submitDoubanUser,this),this.scanBooks=__bind(this.scanBooks,this),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),this.$scope.books=[],this.$scope.moreItemsAvailable=!0,this.$scope.submitAllowed=!0,this.$ionicModal.fromTemplateUrl("templates/modal/import_books.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.$scope.data={isLoading:!1,text:null},this.IonicUtils.initCustomLoading(this.$scope),this.$scope.onRefresh=this.refresh,this.$scope.loadMore=this.loadMore,this.$scope.closeDialog=this.closeDialog,this.$scope.searchDoubanUser=this.searchDoubanUser,this.$scope.scanBooks=this.scanBooks,this.$scope.submitDoubanUser=this.submitDoubanUser,this.$scope.doubanInputDisabled=!1}return BooksController.$inject=["$scope","Books","ScanService","$ionicModal","DoubanService","IonicUtils"],BooksController.prototype.refresh=function(){var afterBookId;return afterBookId=localStorage.getItem("user_max_book_id"),this.Books.fetchNew({afterId:afterBookId},function(_this){return function(data){return _this.$scope.$broadcast("scroll.refreshComplete"),0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),data.books.forEach(function(item){return _this.$scope.books.push(item)})):void 0}}(this))},BooksController.prototype.loadMore=function(){var currentPage,maxPage;return currentPage=localStorage.getItem("user_books_current_page"),maxPage=localStorage.getItem("user_books_max_page"),maxPage=parseInt(maxPage),currentPage=parseInt(currentPage),currentPage>=maxPage?(this.$scope.$broadcast("scroll.infiniteScrollComplete"),this.$scope.moreItemsAvailable=!1):this.Books.query({page:currentPage+1},function(_this){return function(data){return 0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),localStorage.setItem("user_books_current_page",data.current_page),localStorage.setItem("user_books_max_page",data.total_page),data.books.forEach(function(item){return _this.$scope.books.push(item)})):_this.$scope.moreItemsAvailable=!1,_this.$scope.$broadcast("scroll.infiniteScrollComplete")}}(this))},BooksController.prototype.closeDialog=function(){return this.$scope.modal.hide()},BooksController.prototype.searchDoubanUser=function(user){return void 0===user||""===user.trim()?this.IonicUtils.showLoading(this.$scope,"请输入有效昵称"):this.DoubanService.userInfo(user,function(_this){return function(data){return _this.$scope.resultEnabled=!0,_this.$scope.submitAllowed=!0,_this.$scope.doubanUser=data}}(this),function(_this){return function(error){return console.log(error),_this.$scope.resultEnabled=!1,_this.$scope.submitAllowed=!1}}(this))},BooksController.prototype.scanBooks=function(){return this.ScanService.scan(function(_this){return function(result){return navigator.notification.alert("添加图书《"+result.book.name+"》成功",null,"Libr","确定"),_this.$scope.books.unshift(result.book)}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,error)}}(this))},BooksController.prototype.submitDoubanUser=function(){var username;return username=angular.element(document.getElementById("douban-username")),username=username.val(),this.DoubanService.submitUser(username,function(_this){return function(){return _this.$scope.doubanInputDisabled=!0,alert("成功绑定豆瓣用户",function(){return _this.IonicUtils.showLoading(_this.$scope,"绑定豆瓣用户失败,请稍后再试")})}}(this))},BooksController}(),libr.controller("BooksController",BooksController)}).call(this);
(function(){var BookDetailController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers",["ionic"]),BookDetailController=function(){function BookDetailController($scope,$stateParams,BookService,$window,$ionicModal,Comments,IonicUtils){this.$scope=$scope,this.$stateParams=$stateParams,this.BookService=BookService,this.$window=$window,this.$ionicModal=$ionicModal,this.Comments=Comments,this.IonicUtils=IonicUtils,this.back=__bind(this.back,this),this.doComment=__bind(this.doComment,this),this.closeCommentDialog=__bind(this.closeCommentDialog,this),this.openCommentDialog=__bind(this.openCommentDialog,this),this.$scope.openDialog=this.openCommentDialog,this.$scope.closeDialog=this.closeCommentDialog,this.$scope.doComment=this.doComment,this.$scope.back=this.back,this.$ionicModal.fromTemplateUrl("templates/modal/comment.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),BookService.getBook(this.$stateParams.isbn).success(function(_this){return function(result){return _this.$scope.book=result,_this.$scope.usersAccount=result.users.length,_this.$scope.bookName=_this.$scope.book.name,_this.Comments.query({book_id:result.id},function(data){return console.log(data),_this.$scope.comments=data})}}(this)),this.$scope.$on("$destroy",function(_this){return function(){return _this.$scope.modal.remove()}}(this)),this.IonicUtils.initCustomLoading(this.$scope)}return BookDetailController.$inject=["$scope","$stateParams","BookService","$window","$ionicModal","Comments","IonicUtils"],BookDetailController.prototype.openCommentDialog=function(){return this.$scope.modal.show()},BookDetailController.prototype.closeCommentDialog=function(){return this.$scope.modal.hide()},BookDetailController.prototype.doComment=function(){var text;return text=angular.element(document.getElementById("comment")).val(),""===text.trim()?(this.IonicUtils.showLoading(this.$scope,"请输入有效字符"),!1):this.Comments.save({book_id:this.$scope.book.id,content:text},null,function(_this){return function(data){return null===data.id?_this.IonicUtils.showLoading(_this.$scope,"添加图书评论失败"):(console.log("成功。。。。。。。"),_this.$scope.comments.push(data),_this.closeCommentDialog())}}(this))},BookDetailController.prototype.back=function(){return this.$window.history.back()},BookDetailController}(),libr.controller("BookDetailController",BookDetailController)}).call(this);
(function(){var HomeController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.home",["ionic"]),HomeController=function(){function HomeController($scope,$location,BookService,ScanService,$ionicLoading,$ionicActionSheet,RecommendService,ErrorHandler){return this.$scope=$scope,this.$location=$location,this.$ionicLoading=$ionicLoading,this.$ionicActionSheet=$ionicActionSheet,this.RecommendService=RecommendService,this.ErrorHandler=ErrorHandler,this.changeRecommend=__bind(this.changeRecommend,this),this.showRecommendActionSheet=__bind(this.showRecommendActionSheet,this),this.$scope.showRecommendActionSheet=this.showRecommendActionSheet,isUserLogedIn()?(showLoading(this.$scope,this.$ionicLoading),this.$scope.title="你可能喜欢的书",this.RecommendService.popularBooksForMe(function(_this){return function(result){return 0===result.length?alert("请先添加一些你阅读的书,再来查看推荐吧"):_this.$scope.books=result,_this.$scope.loading.hide()}}(this),function(_this){return function(){return _this.ErrorHandler.loadingHandler(_this.$scope,null)}}(this)),void 0):void this.$location.path("/tab/settings")}var isUserLogedIn,showLoading;return HomeController.$inject=["$scope","$location","BookService","ScanService","$ionicLoading","$ionicActionSheet","RecommendService","ErrorHandler"],showLoading=function($scope,$ionicLoading){return $scope.loading=$ionicLoading.show({content:"加载中",animation:"fade-in",showBackdrop:!0,maxWidth:200,showDelay:500})},isUserLogedIn=function(){return null!==localStorage.getItem("token")&&null!==localStorage.getItem("email")?!0:!1},HomeController.prototype.showRecommendActionSheet=function(){return this.$ionicActionSheet.show({titleText:"Libr 为你推荐",buttons:this.RecommendService.getActionSheetList(),cancelText:"取消",cancel:function(){return console.log("CANCELLED")},buttonClicked:function(_this){return function(index){return console.log(""+index+" has been taped"),_this.changeRecommend(index),!0}}(this)})},HomeController.prototype.changeRecommend=function(index){var msg;return msg="喔,看来附近还没有好书推荐,快去推荐你的朋友也来使用吧!",this.RecommendService.changeRecommendAction(index,function(_this){return function(result){var listArray;return 0===result.length?navigator.notification.alert(msg,null,"libr","确定"):(_this.$scope.books=result,listArray=JSON.parse(localStorage.getItem("recommend_action_sheet_full_arr")),_this.$scope.title=listArray[index].text)}}(this),function(_this){return function(){return _this.ErrorHandler.whenError(null)}}(this))},HomeController}(),libr.controller("HomeCtrl",HomeController)}).call(this);
(function(){var LocationController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.location",["ionic"]),LocationController=function(){function LocationController($scope,$location,GeolocationService,IonicUtils){this.$scope=$scope,this.$location=$location,this.GeolocationService=GeolocationService,this.IonicUtils=IonicUtils,this.addLocation=__bind(this.addLocation,this),this.$scope.addLocation=this.addLocation,this.$scope.itemButtons=[{text:"删除",type:"button-assertive",onTap:function(_this){return function(item){return _this.GeolocationService.deleteLocation(item,function(){return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item),1)})}}(this)}],this.GeolocationService.getLocations(function(_this){return function(locations){return _this.$scope.locations=locations}}(this)),this.GeolocationService.getDetailAddress(function(_this){return function(position){return localStorage.setItem("cur_address_detail",position.result.formatted_address),localStorage.setItem("cur_lat",position.result.location.lat),localStorage.setItem("cur_lng",position.result.location.lng),_this.$scope.address=position.result.formatted_address}}(this)),this.IonicUtils.initCustomLoading(this.$scope)}return LocationController.$inject=["$scope","$location","GeolocationService","IonicUtils"],LocationController.prototype.addLocation=function(){return this.$scope.locations.length>=3?this.IonicUtils.showLoading(this.$scope,"只能创建3个常用的地址哦,你可以尝试删除部分,再添加"):null===localStorage.getItem("cur_address_detail")?this.IonicUtils.showLoading(this.$scope,"定位成功后方可添加常用地址"):this.GeolocationService.createLocation(function(_this){return function(result){return _this.$scope.locations.push(result)}}(this))},LocationController}(),libr.controller("LocationController",LocationController)}).call(this);
(function(){var LoginController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.login",["ionic"]),LoginController=function(){function LoginController($scope,AuthService,$state,$ionicModal,IonicUtils){this.$scope=$scope,this.AuthService=AuthService,this.$state=$state,this.$ionicModal=$ionicModal,this.IonicUtils=IonicUtils,this.closeDialog=__bind(this.closeDialog,this),this.registerUser=__bind(this.registerUser,this),this.registerForm=__bind(this.registerForm,this),this.login=__bind(this.login,this),isUserLogedIn()&&this.$state.go("tab.home"),this.$scope.login=this.login,this.$scope.registerForm=this.registerForm,this.$scope.registerUser=this.registerUser,this.$scope.closeDialog=this.closeDialog,this.$ionicModal.fromTemplateUrl("templates/modal/registration.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.IonicUtils.initCustomLoading(this.$scope)}var isUserLogedIn;return LoginController.$inject=["$scope","AuthService","$state","$ionicModal","IonicUtils"],LoginController.prototype.login=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.login(user,function(_this){return function(result){return localStorage.setItem("token",result.user.token),localStorage.setItem("avatar",result.user.avatar),localStorage.setItem("username",result.user.name),localStorage.setItem("email",user.email),_this.$state.go("tab.home")}}(this),function(_this){return function(data){return _this.IonicUtils.showLoading(_this.$scope,data)}}(this)):void this.IonicUtils.showLoading(this.$scope,"请输入有效的用户名和密码")},isUserLogedIn=function(){return null!==localStorage.getItem("token")&&null!==localStorage.getItem("email")?!0:!1},LoginController.prototype.registerForm=function(){return this.$scope.modal.show()},LoginController.prototype.registerUser=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.register(user,function(_this){return function(result,status){return 201===status?(alert("注册成功,请返回登录"),_this.$scope.modal.hide()):_this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试")}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试"),console.log("registerError",error)}}(this)):void this.IonicUtils.showLoading(this.$scope,"请输入有效的用户名和密码")},LoginController.prototype.closeDialog=function(){return this.$scope.modal.hide()},LoginController}(),libr.controller("LoginController",LoginController)}).call(this);
(function(){var MainController,libr;libr=angular.module("libr.controllers.main",["ionic"]),MainController=function(){function MainController($scope,$location,$ionicModal,$state){this.$scope=$scope,this.$location=$location,this.$ionicModal=$ionicModal,this.$state=$state}return MainController.$inject=["$scope","$location","$ionicModal","$state"],MainController}(),libr.controller("MainCtrl",MainController)}).call(this);
(function(){var SettingsController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.settings",["ionic"]),SettingsController=function(){function SettingsController($scope,$ionicModal,AuthService,$state,$cacheFactory){this.$scope=$scope,this.$ionicModal=$ionicModal,this.AuthService=AuthService,this.$state=$state,this.$cacheFactory=$cacheFactory,this.logout=__bind(this.logout,this),this.$scope.logout=this.logout,this.$scope.feedback=this.feedback,this.$scope.showMe=this.showMe,this.$scope.isLogedIn=isUserLogedIn()?!0:!1,this.$scope.avatar=localStorage.getItem("avatar"),this.$scope.username=localStorage.getItem("username")}var isUserLogedIn;return SettingsController.$inject=["$scope","$ionicModal","AuthService","$state","$cacheFactory"],SettingsController.prototype.logout=function(){var httpDefaultCache;return localStorage.clear(),httpDefaultCache=this.$cacheFactory.get("$http"),console.log("cacheFactory",httpDefaultCache),httpDefaultCache.removeAll(),this.$state.go("login")},SettingsController.prototype.feedback=function(){return window.open("https://jinshuju.net/f/F96z3s","_blank","location=no")},SettingsController.prototype.showMe=function(){return window.open("http://libr.herokuapp.com","_blank","location=no")},isUserLogedIn=function(){return null!==localStorage.getItem("token")&&null!==localStorage.getItem("email")?!0:!1},SettingsController}(),libr.controller("SettingsController",SettingsController)}).call(this);
(function(){var BookDetailController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers",["ionic"]),BookDetailController=function(){function BookDetailController($scope,$stateParams,BookService,$window,$ionicModal,Comments){this.$scope=$scope,this.$stateParams=$stateParams,this.BookService=BookService,this.$window=$window,this.$ionicModal=$ionicModal,this.Comments=Comments,this.back=__bind(this.back,this),this.doComment=__bind(this.doComment,this),this.closeCommentDialog=__bind(this.closeCommentDialog,this),this.openCommentDialog=__bind(this.openCommentDialog,this),this.$scope.openDialog=this.openCommentDialog,this.$scope.closeDialog=this.closeCommentDialog,this.$scope.doComment=this.doComment,this.$scope.back=this.back,this.$ionicModal.fromTemplateUrl("templates/modal/comment.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),BookService.getBook(this.$stateParams.isbn).success(function(_this){return function(result){return _this.$scope.book=result,_this.$scope.usersAccount=result.users.length,_this.$scope.bookName=_this.$scope.book.name,_this.Comments.query({book_id:result.id},function(data){return console.log(data),_this.$scope.comments=data})}}(this)),this.$scope.$on("$destroy",function(_this){return function(){return _this.$scope.modal.remove()}}(this))}return BookDetailController.$inject=["$scope","$stateParams","BookService","$window","$ionicModal","Comments"],BookDetailController.prototype.openCommentDialog=function(){return this.$scope.modal.show()},BookDetailController.prototype.closeCommentDialog=function(){return this.$scope.modal.hide()},BookDetailController.prototype.doComment=function(){var text;return text=angular.element(document.getElementById("comment")).val(),""===text.trim()?(alert("请输入有效字符"),!1):this.Comments.save({book_id:this.$scope.book.id,content:text},null,function(_this){return function(data){return null===data.id?alert("添加图书失败"):(console.log("成功。。。。。。。"),_this.$scope.comments.push(data),_this.closeCommentDialog())}}(this))},BookDetailController.prototype.back=function(){return this.$window.history.back()},BookDetailController}(),libr.controller("BookDetailController",BookDetailController)}).call(this);
(function(){var BookService,libr;libr=angular.module("libr.services",["ngResource"]),BookService=function(){function BookService($http){var baseUrl,bookFactory;return baseUrl="http://libr.herokuapp.com/api/v1/books",bookFactory={},bookFactory.getBook=function(isbn){return $http.get(baseUrl+"/bookinfo/"+isbn)},bookFactory}return BookService.$inject=["$http"],BookService}(),libr.factory("BookService",BookService)}).call(this);
(function(){var baseUrl;baseUrl="http://libr.herokuapp.com/api/v1"}).call(this);
-1
View File
@@ -22,5 +22,4 @@
<script src="dist/js/all.min.js"></script>
<!--<script src="http://10.17.2.1:8080/target/target-script-min.js#anonymous"></script>-->
</body>
</html>
@@ -67,7 +67,7 @@ class BooksController
searchDoubanUser: (user)=>
if user is undefined or user.trim() is ''
alert '请输入有效昵称'
@IonicUtils.showLoading(@$scope,'请输入有效昵称')
else
@DoubanService.userInfo user,
(data)=>
@@ -94,7 +94,7 @@ class BooksController
@$scope.doubanInputDisabled = true
alert '成功绑定豆瓣用户'
, (data)->
alert '绑定豆瓣用户失败,请稍后再试'
, (data)=>
@IonicUtils.showLoading(@$scope,'绑定豆瓣用户失败,请稍后再试')
libr.controller 'BooksController', BooksController
@@ -58,4 +58,4 @@ class HomeController
@$scope.title = listArray[index].text
, (error)=>
@ErrorHandler.whenError null
libr.controller 'HomeCtrl', HomeController
libr.controller 'HomeCtrl', HomeController
@@ -3,6 +3,9 @@
<button class="button button-icon ion-arrow-left-c" ng-click="closeDialog()"></button>
<h1 class="title">添加评论</h1>
</header>
<div class="bar bar-loading bar-assertive" ng-if="data.isLoading">
{{data.text}}
</div>
<ion-content has-header="true" padding="true">
<textarea name="content" class="comment-container" id="comment">
</textarea>
@@ -10,4 +13,4 @@
提交
</button>
</ion-content>
</div>
</div>
@@ -10,6 +10,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="classes" level="project" />
<orderEntry type="module" module-name="CordovaLib" />
<orderEntry type="module" module-name="CordovaLib" />
</component>
</module>
-1
View File
@@ -22,5 +22,4 @@
<script src="dist/js/all.min.js"></script>
<!--<script src="http://10.17.2.1:8080/target/target-script-min.js#anonymous"></script>-->
</body>
</html>
@@ -67,7 +67,7 @@ class BooksController
searchDoubanUser: (user)=>
if user is undefined or user.trim() is ''
alert '请输入有效昵称'
@IonicUtils.showLoading(@$scope,'请输入有效昵称')
else
@DoubanService.userInfo user,
(data)=>
@@ -94,7 +94,7 @@ class BooksController
@$scope.doubanInputDisabled = true
alert '成功绑定豆瓣用户'
, (data)->
alert '绑定豆瓣用户失败,请稍后再试'
, (data)=>
@IonicUtils.showLoading(@$scope,'绑定豆瓣用户失败,请稍后再试')
libr.controller 'BooksController', BooksController
+57
View File
@@ -0,0 +1,57 @@
libr = angular.module('libr.controllers', ['ionic'])
class BookDetailController
@$inject: ['$scope', '$stateParams', 'BookService', '$window', '$ionicModal', 'Comments']
constructor: (@$scope, @$stateParams, @BookService, @$window, @$ionicModal, @Comments) ->
@$scope.openDialog = @openCommentDialog
@$scope.closeDialog = @closeCommentDialog
@$scope.doComment = @doComment
@$scope.back = @back
@$ionicModal.fromTemplateUrl 'templates/modal/comment.html', (modal)=>
@$scope.modal = modal
, {
scope: @$scope,
animation: 'slide-in-up'
}
BookService.getBook(@$stateParams.isbn).success (result) =>
@$scope.book = result
@$scope.usersAccount = result.users.length
@$scope.bookName = @$scope.book.name
@Comments.query {book_id: result.id}, (data)=>
console.log data
@$scope.comments = data
@$scope.$on '$destroy', ()=>
@$scope.modal.remove()
openCommentDialog: ()=>
@$scope.modal.show()
closeCommentDialog: ()=>
@$scope.modal.hide()
doComment: ()=>
text = angular.element(document.getElementById('comment')).val()
if text.trim() is ''
alert '请输入有效字符'
return false
else
@Comments.save {
book_id: @$scope.book.id
content: text
}, null, (data)=>
if data.id is null
alert '添加图书失败'
else
console.log '成功。。。。。。。'
@$scope.comments.push data
@closeCommentDialog()
back: ()=>
@$window.history.back()
libr.controller 'BookDetailController', BookDetailController
@@ -58,4 +58,4 @@ class HomeController
@$scope.title = listArray[index].text
, (error)=>
@ErrorHandler.whenError null
libr.controller 'HomeCtrl', HomeController
libr.controller 'HomeCtrl', HomeController
+12
View File
@@ -0,0 +1,12 @@
libr = angular.module 'libr.services', ['ngResource']
class BookService
@$inject: ['$http']
constructor: ($http)->
baseUrl = 'http://libr.herokuapp.com/api/v1/books'
bookFactory = {}
bookFactory.getBook = (isbn) ->
$http.get baseUrl + '/bookinfo/' + isbn
return bookFactory
libr.factory 'BookService', BookService
+4 -1
View File
@@ -3,6 +3,9 @@
<button class="button button-icon ion-arrow-left-c" ng-click="closeDialog()"></button>
<h1 class="title">添加评论</h1>
</header>
<div class="bar bar-loading bar-assertive" ng-if="data.isLoading">
{{data.text}}
</div>
<ion-content has-header="true" padding="true">
<textarea name="content" class="comment-container" id="comment">
</textarea>
@@ -10,4 +13,4 @@
提交
</button>
</ion-content>
</div>
</div>