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