facebook-js-stub 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
|
|
1
|
+
require "facebook-js-stub/engine"
|
@@ -0,0 +1,165 @@
|
|
1
|
+
var FB = (function(){
|
2
|
+
var self = { };
|
3
|
+
|
4
|
+
self.init = function(options) {
|
5
|
+
FBStub.appId(options.appId);
|
6
|
+
};
|
7
|
+
|
8
|
+
self.login = function(callback) {
|
9
|
+
if (!FBStub.initialized()) return;
|
10
|
+
FBStub.loginCallback = callback;
|
11
|
+
};
|
12
|
+
|
13
|
+
self.getLoginStatus = function(callback) {
|
14
|
+
if (!FBStub.initialized()) return;
|
15
|
+
var status;
|
16
|
+
var authResponse = null;
|
17
|
+
|
18
|
+
if (FBStub.isLoggedIn()) {
|
19
|
+
if (FBStub.isConnected()) {
|
20
|
+
status = "connected";
|
21
|
+
authResponse = {
|
22
|
+
accessToken: "",
|
23
|
+
expiresIn: 4095,
|
24
|
+
signedRequest: "",
|
25
|
+
userID: FBStub.userID()
|
26
|
+
};
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
status = "not_authorized";
|
30
|
+
}
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
status = "unknown";
|
34
|
+
}
|
35
|
+
|
36
|
+
callback({
|
37
|
+
status: status,
|
38
|
+
authResponse: authResponse
|
39
|
+
});
|
40
|
+
};
|
41
|
+
|
42
|
+
self.api = function(path, method, params, callback) {
|
43
|
+
var callbackMethod;
|
44
|
+
|
45
|
+
if (typeof method === 'function') {
|
46
|
+
callbackMethod = method;
|
47
|
+
} else {
|
48
|
+
if (typeof params == 'function') {
|
49
|
+
callbackMethod = params;
|
50
|
+
} else {
|
51
|
+
callbackMethod = callback;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
FBStub.addApiRequest(path, callbackMethod);
|
55
|
+
};
|
56
|
+
|
57
|
+
return self;
|
58
|
+
}( ));
|
59
|
+
var FBStub = (function() {
|
60
|
+
var self = { };
|
61
|
+
|
62
|
+
var state, apiRequests;
|
63
|
+
|
64
|
+
var initialize = function() {
|
65
|
+
state = {
|
66
|
+
'loggedIn': false,
|
67
|
+
'connected': false,
|
68
|
+
'appId': null,
|
69
|
+
'user': {}
|
70
|
+
};
|
71
|
+
apiRequests = { };
|
72
|
+
};
|
73
|
+
|
74
|
+
initialize();
|
75
|
+
|
76
|
+
self.addApiRequest = function(path, callback) {
|
77
|
+
apiRequests[path] = callback;
|
78
|
+
};
|
79
|
+
|
80
|
+
self.findApiRequest = function(path) {
|
81
|
+
return apiRequests[path];
|
82
|
+
};
|
83
|
+
|
84
|
+
self.loggedIn = function(user) {
|
85
|
+
state.loggedIn = true;
|
86
|
+
state.user = user || {};
|
87
|
+
};
|
88
|
+
|
89
|
+
self.notLoggedIn = function() {
|
90
|
+
state.loggedIn = false;
|
91
|
+
state.user = {};
|
92
|
+
};
|
93
|
+
|
94
|
+
self.connected = function() {
|
95
|
+
state.connected = true;
|
96
|
+
};
|
97
|
+
|
98
|
+
self.notConnected = function() {
|
99
|
+
state.connected = false;
|
100
|
+
};
|
101
|
+
|
102
|
+
self.isLoggedIn = function() {
|
103
|
+
return state.loggedIn;
|
104
|
+
};
|
105
|
+
|
106
|
+
self.isConnected = function() {
|
107
|
+
return state.connected;
|
108
|
+
};
|
109
|
+
|
110
|
+
self.userID = function() {
|
111
|
+
return state.user.userID;
|
112
|
+
};
|
113
|
+
|
114
|
+
self.appId = function(id) {
|
115
|
+
if (id) {
|
116
|
+
state.appId = id;
|
117
|
+
}
|
118
|
+
return state.appId;
|
119
|
+
};
|
120
|
+
|
121
|
+
self.reset = function() {
|
122
|
+
initialize();
|
123
|
+
};
|
124
|
+
|
125
|
+
self.logInAndAuthorize = function() {
|
126
|
+
if (!self.initialized()) return;
|
127
|
+
self.loginCallback({
|
128
|
+
status: "connected",
|
129
|
+
authResponse: {
|
130
|
+
accessToken: "",
|
131
|
+
userID: "",
|
132
|
+
expiresIn: 4374,
|
133
|
+
signedRequest: ""
|
134
|
+
}
|
135
|
+
});
|
136
|
+
};
|
137
|
+
|
138
|
+
self.logInAndDeny = function() {
|
139
|
+
if (!self.initialized()) return;
|
140
|
+
self.loginCallback({
|
141
|
+
status: "not_authorized",
|
142
|
+
authResponse: null
|
143
|
+
});
|
144
|
+
};
|
145
|
+
|
146
|
+
self.abortLogIn = function() {
|
147
|
+
if (!self.initialized()) return;
|
148
|
+
self.loginCallback({
|
149
|
+
status: "unknown",
|
150
|
+
authResponse: null
|
151
|
+
});
|
152
|
+
};
|
153
|
+
|
154
|
+
self.respondToApiRequest = function(path, response) {
|
155
|
+
if (typeof(apiRequests[path]) === 'undefined') return;
|
156
|
+
apiRequests[path](response);
|
157
|
+
};
|
158
|
+
|
159
|
+
self.initialized = function() {
|
160
|
+
var appId = state.appId;
|
161
|
+
return (typeof(appId) == 'number' || typeof(appId) == "string");
|
162
|
+
};
|
163
|
+
|
164
|
+
return self;
|
165
|
+
}( ));
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: facebook-js-stub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Involver
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- /Users/nort/git/facebook-js-stub/lib/facebook-js-stub/engine.rb
|
21
|
+
- /Users/nort/git/facebook-js-stub/lib/facebook-js-stub.rb
|
22
|
+
- /Users/nort/git/facebook-js-stub/vendor/assets/javascripts/facebook-js-stub.js
|
23
|
+
homepage:
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.25
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: ''
|
47
|
+
test_files: []
|
48
|
+
has_rdoc:
|