You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 lines
7.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. // Ionic Starter App
  2. // angular.module is a global place for creating, registering and retrieving Angular modules
  3. // 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
  4. // the 2nd parameter is an array of 'requires'
  5. // 'starter.controllers' is found in controllers.js
  6. //var urlapi = "http://localhost:3000/api/";
  7. //var urlapi = "http://192.168.1.36:3000/api/";
  8. var urlapi = "http://37.59.123.45:3000/api/";
  9. angular.module('starter', [
  10. 'ionic',
  11. 'ngCordova',
  12. 'pascalprecht.translate',
  13. 'app.login',
  14. 'app.signup',
  15. 'app.menu',
  16. 'app.footerMenu',
  17. 'app.main',
  18. 'app.search',
  19. 'app.travels',
  20. 'app.travel',
  21. 'app.newTravel',
  22. 'app.offerCar',
  23. 'app.askForCar',
  24. 'app.askForPackage',
  25. 'app.users',
  26. 'app.user',
  27. 'app.userTravels',
  28. 'app.userLikes',
  29. 'app.editUser',
  30. 'app.notifications',
  31. 'app.settings',
  32. 'app.password',
  33. 'app.help'
  34. ])
  35. .run(function($ionicPlatform) {
  36. $ionicPlatform.ready(function() {
  37. // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  38. // for form inputs)
  39. if (window.cordova && window.cordova.plugins.Keyboard) {
  40. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  41. cordova.plugins.Keyboard.disableScroll(true);
  42. }
  43. if (window.StatusBar) {
  44. // org.apache.cordova.statusbar required
  45. StatusBar.styleDefault();
  46. }
  47. });
  48. })
  49. .config(function($stateProvider, $urlRouterProvider) {
  50. $stateProvider
  51. .state('app', {
  52. cache: false,
  53. url: '/app',
  54. abstract: true,
  55. templateUrl: 'templates/menu.html',
  56. controller: 'MenuCtrl'
  57. })
  58. .state('app.main', {
  59. cache: false,
  60. url: '/main',
  61. views: {
  62. 'menuContent': {
  63. templateUrl: 'templates/main.html',
  64. controller: 'MainCtrl'
  65. }
  66. }
  67. })
  68. .state('app.login', {
  69. url: '/login',
  70. views: {
  71. 'menuContent': {
  72. templateUrl: 'templates/login.html',
  73. controller: 'LoginCtrl'
  74. }
  75. }
  76. })
  77. .state('app.signup', {
  78. url: '/signup',
  79. views: {
  80. 'menuContent': {
  81. templateUrl: 'templates/signup.html',
  82. controller: 'SignupCtrl'
  83. }
  84. }
  85. })
  86. .state('app.search', {
  87. url: '/search',
  88. views: {
  89. 'menuContent': {
  90. templateUrl: 'templates/search.html',
  91. controller: 'SearchCtrl'
  92. }
  93. }
  94. })
  95. .state('app.travels', {
  96. url: '/travels',
  97. views: {
  98. 'menuContent': {
  99. templateUrl: 'templates/travels.html',
  100. controller: 'TravelsCtrl'
  101. }
  102. }
  103. })
  104. .state('app.travel', {
  105. url: '/travels/:travelid',
  106. views: {
  107. 'menuContent': {
  108. templateUrl: 'templates/travel.html',
  109. controller: 'TravelCtrl'
  110. }
  111. }
  112. })
  113. .state('app.newTravel', {
  114. url: '/newTravel',
  115. views: {
  116. 'menuContent': {
  117. templateUrl: 'templates/newTravel.html',
  118. controller: 'NewTravelCtrl'
  119. }
  120. }
  121. })
  122. .state('app.offerCar', {
  123. url: '/offerCar',
  124. views: {
  125. 'menuContent': {
  126. templateUrl: 'templates/offerCar.html',
  127. controller: 'OfferCarCtrl'
  128. }
  129. }
  130. })
  131. .state('app.askForCar', {
  132. url: '/askForCar',
  133. views: {
  134. 'menuContent': {
  135. templateUrl: 'templates/askForCar.html',
  136. controller: 'AskForCarCtrl'
  137. }
  138. }
  139. })
  140. .state('app.askForPackage', {
  141. url: '/askForPackage',
  142. views: {
  143. 'menuContent': {
  144. templateUrl: 'templates/askForPackage.html',
  145. controller: 'AskForPackageCtrl'
  146. }
  147. }
  148. })
  149. .state('app.users', {
  150. url: '/users',
  151. views: {
  152. 'menuContent': {
  153. templateUrl: 'templates/users.html',
  154. controller: 'UsersCtrl'
  155. }
  156. }
  157. })
  158. .state('app.user', {
  159. url: '/users/:userid',
  160. views: {
  161. 'menuContent': {
  162. templateUrl: 'templates/user.html',
  163. controller: 'UserCtrl'
  164. }
  165. }
  166. })
  167. .state('app.userTravels', {
  168. url: '/users/userTravels/:userid',
  169. views: {
  170. 'menuContent': {
  171. templateUrl: 'templates/userTravels.html',
  172. controller: 'UserTravelsCtrl'
  173. }
  174. }
  175. })
  176. .state('app.userLikes', {
  177. url: '/users/userLikes/:userid',
  178. views: {
  179. 'menuContent': {
  180. templateUrl: 'templates/userLikes.html',
  181. controller: 'UserLikesCtrl'
  182. }
  183. }
  184. })
  185. .state('app.editUser', {
  186. url: '/editUser',
  187. views: {
  188. 'menuContent': {
  189. templateUrl: 'templates/editUser.html',
  190. controller: 'EditUserCtrl'
  191. }
  192. }
  193. })
  194. .state('app.notifications', {
  195. url: '/notifications',
  196. views: {
  197. 'menuContent': {
  198. templateUrl: 'templates/notifications.html',
  199. controller: 'NotificationsCtrl'
  200. }
  201. }
  202. })
  203. .state('app.settings', {
  204. url: '/settings',
  205. views: {
  206. 'menuContent': {
  207. templateUrl: 'templates/settings.html',
  208. controller: 'SettingsCtrl'
  209. }
  210. }
  211. })
  212. .state('app.password', {
  213. url: '/password',
  214. views: {
  215. 'menuContent': {
  216. templateUrl: 'templates/password.html',
  217. controller: 'PasswordCtrl'
  218. }
  219. }
  220. })
  221. .state('app.help', {
  222. url: '/help',
  223. views: {
  224. 'menuContent': {
  225. templateUrl: 'templates/help.html',
  226. controller: 'HelpCtrl'
  227. }
  228. }
  229. });
  230. // if none of the above states are matched, use this as the fallback
  231. if ((localStorage.getItem("cim_app_token")) && (JSON.parse(localStorage.getItem("cim_app_userdata")) != "null") && (JSON.parse(localStorage.getItem("cim_app_userdata")) != null)) {
  232. if ((window.location.hash == "#/app/login") || (window.location.hash == "#/app/signup")) {
  233. window.location = '#/app/main';
  234. }
  235. $urlRouterProvider.otherwise('/app/main');
  236. } else {
  237. if ((window.location != "#/app/login") || (window.location != "#/app/signup")) {
  238. console.log("removing data, and going to login");
  239. localStorage.removeItem("cim_app_token");
  240. localStorage.removeItem("cim_app_userdata");
  241. window.location = "#/app/login";
  242. $urlRouterProvider.otherwise('/app/login');
  243. }
  244. }
  245. })
  246. /* translator */
  247. .config(['$translateProvider', function($translateProvider) {
  248. /* get lang from the file translations.js */
  249. for (lang in translations) {
  250. $translateProvider.translations(lang, translations[lang]);
  251. }
  252. if (window.localStorage.getItem('lang')) {
  253. $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
  254. } else {
  255. $translateProvider.preferredLanguage('english');
  256. };
  257. $translateProvider.useSanitizeValueStrategy('escape');
  258. }])
  259. .factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
  260. return {
  261. request: function(config) {
  262. return config;
  263. },
  264. requestError: function(config) {
  265. return config;
  266. },
  267. response: function(res) {
  268. return res;
  269. },
  270. responseError: function(res) {
  271. return res;
  272. }
  273. }
  274. })
  275. .factory('api', function($http) {
  276. return {
  277. init: function() {
  278. $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token");
  279. $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token");
  280. }
  281. };
  282. })
  283. .run(function(api) {
  284. api.init();
  285. });