-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathcontrollers.js
executable file
·115 lines (93 loc) · 3.31 KB
/
controllers.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
107
108
109
110
111
112
113
114
115
angular.module('sociogram.controllers', [])
.controller('AppCtrl', function ($scope, $state, OpenFB) {
$scope.logout = function () {
OpenFB.logout();
$state.go('app.login');
};
$scope.revokePermissions = function () {
OpenFB.revokePermissions().then(
function () {
$state.go('app.login');
},
function () {
alert('Revoke permissions failed');
});
};
})
.controller('LoginCtrl', function ($scope, $location, OpenFB) {
$scope.facebookLogin = function () {
OpenFB.login('email,read_stream,publish_actions').then(
function () {
$location.path('/app/person/me/feed');
},
function () {
alert('OpenFB login failed');
});
};
})
.controller('ShareCtrl', function ($scope, OpenFB) {
$scope.item = {};
$scope.share = function () {
OpenFB.post('/me/feed', $scope.item)
.success(function () {
$scope.status = "This item has been shared on OpenFB";
})
.error(function(data) {
alert(data.error.message);
});
};
})
.controller('ProfileCtrl', function ($scope, OpenFB) {
OpenFB.get('/me').success(function (user) {
$scope.user = user;
});
})
.controller('PersonCtrl', function ($scope, $stateParams, OpenFB) {
OpenFB.get('/' + $stateParams.personId).success(function (user) {
$scope.user = user;
});
})
.controller('FriendsCtrl', function ($scope, $stateParams, OpenFB) {
OpenFB.get('/' + $stateParams.personId + '/friends', {limit: 50})
.success(function (result) {
$scope.friends = result.data;
})
.error(function(data) {
alert(data.error.message);
});
})
.controller('MutualFriendsCtrl', function ($scope, $stateParams, OpenFB) {
OpenFB.get('/' + $stateParams.personId + '/mutualfriends', {limit: 50})
.success(function (result) {
$scope.friends = result.data;
})
.error(function(data) {
alert(data.error.message);
});
})
.controller('FeedCtrl', function ($scope, $stateParams, OpenFB, $ionicLoading) {
$scope.show = function() {
$scope.loading = $ionicLoading.show({
content: 'Loading feed...'
});
};
$scope.hide = function(){
$scope.loading.hide();
};
function loadFeed() {
$scope.show();
OpenFB.get('/' + $stateParams.personId + '/home', {limit: 30})
.success(function (result) {
$scope.hide();
$scope.items = result.data;
// Used with pull-to-refresh
$scope.$broadcast('scroll.refreshComplete');
})
.error(function(data) {
$scope.hide();
alert(data.error.message);
});
}
$scope.doRefresh = loadFeed;
loadFeed();
});