openEventsPlatformApp/www/js/app.js
www/js/app.jsRaw
1//var urlapi = "http://localhost:3000/api/";
2var urlapi = "http://192.168.1.34:3000/api/";
3
4
5
6angular.module('app', [
7 'ionic',
8 'pascalprecht.translate',
9 'ngCordova',
10 'app.menu',
11 'app.main',
12 'app.events',
13 'app.event',
14 'app.savedEvents',
15 'app.users',
16 'app.user'
17 ])
18
19.run(function($ionicPlatform) {
20 $ionicPlatform.ready(function() {
21 // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
22 // for form inputs)
23 if (window.cordova && window.cordova.plugins.Keyboard) {
24 cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
25 cordova.plugins.Keyboard.disableScroll(true);
26
27 }
28 if (window.StatusBar) {
29 // org.apache.cordova.statusbar required
30 StatusBar.styleDefault();
31 }
32 });
33})
34
35.config(function($stateProvider, $urlRouterProvider) {
36 $stateProvider
37
38 // setup an abstract state for the tabs directive
39 .state('app', {
40 url: '/app',
41 abstract: true,
42 templateUrl: 'templates/menu.html',
43 controller: 'MenuCtrl'
44 })
45
46 .state('app.main', {
47 url: '/main',
48 views: {
49 'menuContent': {
50 templateUrl: 'templates/main.html',
51 controller: 'MainCtrl'
52 }
53 }
54 })
55 .state('app.events', {
56 url: '/events',
57 views: {
58 'menuContent': {
59 templateUrl: 'templates/events.html',
60 controller: 'EventsCtrl'
61 }
62 }
63 })
64 .state('app.event', {
65 url: '/events/:eventid',
66 views: {
67 'menuContent': {
68 templateUrl: 'templates/event.html',
69 controller: 'EventCtrl'
70 }
71 }
72 })
73 .state('app.savedEvents', {
74 url: '/savedEvents',
75 views: {
76 'menuContent': {
77 templateUrl: 'templates/savedEvents.html',
78 controller: 'SavedEventsCtrl'
79 }
80 }
81 })
82 .state('app.users', {
83 url: '/users',
84 views: {
85 'menuContent': {
86 templateUrl: 'templates/users.html',
87 controller: 'UsersCtrl'
88 }
89 }
90 })
91 .state('app.user', {
92 url: '/users/:userid',
93 views: {
94 'menuContent': {
95 templateUrl: 'templates/user.html',
96 controller: 'UserCtrl'
97 }
98 }
99 });
100
101 // if none of the above states are matched, use this as the fallback
102 $urlRouterProvider.otherwise('/app/main');
103})
104 /* translator */
105 .config(['$translateProvider', function($translateProvider) {
106
107 /* get lang from the file translations.js */
108 for (lang in translations) {
109 $translateProvider.translations(lang, translations[lang]);
110 }
111
112 if (window.localStorage.getItem('lang')) {
113 $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
114 } else {
115 $translateProvider.preferredLanguage('english');
116 };
117
118 $translateProvider.useSanitizeValueStrategy('escape');
119
120 }])
121 .factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
122 return {
123 request: function(config) {
124 return config;
125 },
126 requestError: function(config) {
127 return config;
128 },
129 response: function(res) {
130 return res;
131 },
132 responseError: function(res) {
133 return res;
134 }
135 }
136 })
137 .factory('api', function($http) {
138 return {
139 init: function() {
140 $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token");
141 $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token");
142 }
143 };
144 })
145 .run(function(api) {
146 api.init();
147 });