arnaucube
arnaucube/openEventsPlatformAppPublic Self-hosted repository
openEventsPlatformApp/www/js/app.js
www/js/app.jsRaw
  1var urlapi = "http://localhost:3000/api/";
  2//var urlapi = "http://192.168.1.33: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.mapEvents',
 14    'app.event',
 15    'app.alerts',
 16    'app.savedEvents',
 17    'app.categories',
 18    'app.byCategory',
 19    'app.place',
 20    'app.byPlace',
 21    'app.calendar',
 22    'app.users',
 23    'app.user',
 24    'app.login',
 25    'app.userZone',
 26    'app.newEvent'
 27  ])
 28
 29.run(function($ionicPlatform) {
 30  $ionicPlatform.ready(function() {
 31    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
 32    // for form inputs)
 33    if (window.cordova && window.cordova.plugins.Keyboard) {
 34      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
 35      cordova.plugins.Keyboard.disableScroll(true);
 36
 37    }
 38    if (window.StatusBar) {
 39      // org.apache.cordova.statusbar required
 40      StatusBar.styleDefault();
 41    }
 42  });
 43})
 44
 45.config(function($stateProvider, $urlRouterProvider) {
 46  $stateProvider
 47
 48  // setup an abstract state for the tabs directive
 49    .state('app', {
 50        url: '/app',
 51        abstract: true,
 52        templateUrl: 'templates/menu.html',
 53        controller: 'MenuCtrl'
 54    })
 55
 56    .state('app.main', {
 57      url: '/main',
 58      views: {
 59        'menuContent': {
 60          templateUrl: 'templates/main.html',
 61          controller: 'MainCtrl'
 62        }
 63      }
 64    })
 65    .state('app.events', {
 66      url: '/events',
 67      views: {
 68        'menuContent': {
 69          templateUrl: 'templates/events.html',
 70          controller: 'EventsCtrl'
 71        }
 72      }
 73    })
 74    .state('app.mapEvents', {
 75      url: '/mapEvents',
 76      views: {
 77        'menuContent': {
 78          templateUrl: 'templates/mapEvents.html',
 79          controller: 'MapEventsCtrl'
 80        }
 81      }
 82    })
 83    .state('app.event', {
 84      url: '/events/:eventid',
 85      views: {
 86        'menuContent': {
 87          templateUrl: 'templates/event.html',
 88          controller: 'EventCtrl'
 89        }
 90      }
 91    })
 92    .state('app.alerts', {
 93      url: '/alerts',
 94      views: {
 95        'menuContent': {
 96          templateUrl: 'templates/alerts.html',
 97          controller: 'AlertsCtrl'
 98        }
 99      }
100    })
101    .state('app.savedEvents', {
102      url: '/savedEvents',
103      views: {
104        'menuContent': {
105          templateUrl: 'templates/savedEvents.html',
106          controller: 'SavedEventsCtrl'
107        }
108      }
109    })
110    .state('app.categories', {
111      url: '/categories',
112      views: {
113        'menuContent': {
114          templateUrl: 'templates/categories.html',
115          controller: 'CategoriesCtrl'
116        }
117      }
118    })
119    .state('app.byCategory', {
120      url: '/byCategory/:categoryname',
121      views: {
122        'menuContent': {
123          templateUrl: 'templates/byCategory.html',
124          controller: 'ByCategoryCtrl'
125        }
126      }
127    })
128    .state('app.place', {
129      url: '/place',
130      views: {
131        'menuContent': {
132          templateUrl: 'templates/place.html',
133          controller: 'PlaceCtrl'
134        }
135      }
136    })
137    .state('app.byPlace', {
138      url: '/byPlace/:place',
139      views: {
140        'menuContent': {
141          templateUrl: 'templates/byPlace.html',
142          controller: 'ByPlaceCtrl'
143        }
144      }
145    })
146    .state('app.calendar', {
147      url: '/calendar',
148      views: {
149        'menuContent': {
150          templateUrl: 'templates/calendar.html',
151          controller: 'CalendarCtrl'
152        }
153      }
154    })
155    .state('app.users', {
156      url: '/users',
157      views: {
158        'menuContent': {
159          templateUrl: 'templates/users.html',
160          controller: 'UsersCtrl'
161        }
162      }
163    })
164    .state('app.user', {
165      url: '/users/:userid',
166      views: {
167        'menuContent': {
168          templateUrl: 'templates/user.html',
169          controller: 'UserCtrl'
170        }
171      }
172    })
173    .state('app.login', {
174      url: '/login',
175      views: {
176        'menuContent': {
177          templateUrl: 'templates/login.html',
178          controller: 'LoginCtrl'
179        }
180      }
181    })
182    .state('app.userZone', {
183      url: '/userZone',
184      views: {
185        'menuContent': {
186          templateUrl: 'templates/userZone.html',
187          controller: 'UserZoneCtrl'
188        }
189      }
190    })
191    .state('app.newEvent', {
192      url: '/newEvent',
193      views: {
194        'menuContent': {
195          templateUrl: 'templates/newEvent.html',
196          controller: 'NewEventCtrl'
197        }
198      }
199    });
200
201  // if none of the above states are matched, use this as the fallback
202  $urlRouterProvider.otherwise('/app/main');
203})
204  /* translator */
205  .config(['$translateProvider', function($translateProvider) {
206
207    /* get lang from the file translations.js */
208    for (lang in translations) {
209      $translateProvider.translations(lang, translations[lang]);
210    }
211
212    if (window.localStorage.getItem('lang')) {
213      $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
214    } else {
215      $translateProvider.preferredLanguage('english');
216    };
217
218    $translateProvider.useSanitizeValueStrategy('escape');
219
220  }])
221  .factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
222    return {
223      request: function(config) {
224        return config;
225      },
226      requestError: function(config) {
227        return config;
228      },
229      response: function(res) {
230        return res;
231      },
232      responseError: function(res) {
233        return res;
234      }
235    }
236  })
237  .factory('api', function($http) {
238    return {
239      init: function() {
240        $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("events_app_token");
241        $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("events_app_token");
242      }
243    };
244  })
245  .run(function(api) {
246    api.init();
247  });