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