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