-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
89 lines (75 loc) · 2.52 KB
/
app.js
File metadata and controls
89 lines (75 loc) · 2.52 KB
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
var app = angular.module('app', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/login', {
templateUrl: 'html/mainWindowSections/login.html',
controller: 'login_controller',
controllerAs: 'login_ctrl',
resolve: {
clear_user: function(password_check_service) {
document.getElementById('top_row').style.display='none';
password_check_service.logOut();
}
}
})
.when('/signup', {
templateUrl: 'html/mainWindowSections/signup.html',
controller: 'signup_controller',
controllerAs: 'signup_ctrl',
resolve: {
hideTop: function() {
document.getElementById('top_row').style.display='none';
}
}
})
.when('/loading', {
templateUrl: 'html/mainWindowSections/loading.html',
resolve: {
setUser: function(password_check_service, user_service) {
var route_string = password_check_service.getRouteString();
var log_name = password_check_service.getUserName();
var log_string = "?username=" + log_name;
user_service.getLoginUser(log_string, route_string);
}
}
})
.when('/loading_1', {
templateUrl: 'html/mainWindowSections/loading.html',
resolve: {
friendLists: function(friend_service) {
friend_service.setVisibleFriendList();
}
}
})
// routing for Main pages
.when('/main', {
templateUrl: 'html/mainWindowSections/main.html',
controller: 'main_window_controller',
controllerAs: 'main_win_ctrl',
})
.when('/profile', {
templateUrl: 'html/mainWindowSections/profile.html',
controller: 'profile_controller',
controllerAs: 'profile_ctrl',
})
.when('/friends', {
templateUrl: 'html/mainWindowSections/friends.html',
controller: 'friends_controller',
controllerAs: 'friends_ctrl',
})
.otherwise({redirectTo: '/login'});
}]);
app.run(['$rootScope', '$location', 'password_check_service', function ($rootScope, $location, password_check_service) {
$rootScope.$on('$routeChangeStart', function (event) {
if (password_check_service.getLoginStatus()
|| $location.path() === '/signup') {
if(!($location.path() === '/signup')) {
document.getElementById('top_row').style.display='block';
}
console.log('ALLOW');
}
else {
console.log('DENY');
$location.path('/login');
}
});
}]);