-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
113 lines (91 loc) · 3.76 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Created by chief on 1/18/14.
*/
var debate = angular.module('debate',[
'ngCookies',
'ui.router',
'ui.bootstrap',
'debate.ctrl',
'debate.services',
'angular-google-analytics'
]);
debate
.config(function(AnalyticsProvider){
// initial configuration
AnalyticsProvider.setAccount('UA-47169705-1');
// track all routes (or not)
AnalyticsProvider.trackPages(true);
// Ignore first page view... helpful when using hashes and whenever your bounce rate looks obscenely low.
AnalyticsProvider.ignoreFirstPageLoad(true);
})
.config(function($httpProvider){
$httpProvider.defaults.headers.common = {};
$httpProvider.defaults.headers.post = {};
$httpProvider.defaults.headers.put = {};
$httpProvider.defaults.headers.patch = {};
})
.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.when('/hi/:userkey',function($match, $http, villasApi, $state){
return $http.get('http://api.evsvillas.com/index.php/login/'+ $match.userkey).success(function(result){
villasApi.userkey = $match.userkey;
villasApi.appdata = result;
villasApi.userinfo = result.userData;
villasApi.posts = result.votingTopic.messages;
villasApi.users = result.votingTopic.users;
villasApi.topicID = result.votingTopic.id;
villasApi.postTopicOptions = result.votingTopic.options;
villasApi.userId = result.userData.id;
villasApi.voteOptions = result.votingTopic.options
}).then(function(){
$state.go('app');
});
})
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('app',{
url:'/home',
templateUrl: 'view/home.html',
controller:function($state){
$state.go('.home');
},
resolve:{
user:function($cookies, $http,villasApi){
if(!villasApi.userkey && $cookies.userkey){
return $http.get('http://api.evsvillas.com/index.php/login/'+ $cookies.userkey).success(function(result){
villasApi.userkey = $cookies.userkey;
villasApi.appdata = result;
villasApi.userinfo = result.userData;
villasApi.posts = result.votingTopic.messages;
villasApi.users = result.votingTopic.users;
villasApi.topicID = result.votingTopic.id;
villasApi.postTopicOptions = result.votingTopic.options;
villasApi.userId = result.userData.id;
});
} else {
return;
}
}
}
})
.state('app.home',{
url:'',
views:{
'header':{
templateUrl:'view/header.html',
controller: 'headerCtrl'
},
'info':{
templateUrl:'view/info.html',
controller: 'infoCtrl'
},
'forum':{
templateUrl: 'view/forum.html',
controller: 'forumCtrl'
},
'comingsoon':{
templateUrl:'view/comingsoon.html',
controller: 'comingsoonCtrl'
}
}
})
})