ymdp 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +0,0 @@
1
- var Logger;
2
-
3
- Logger = {
4
- on: false,
5
-
6
- init: function() {
7
- OIB.get("ymdp/state", {}, function(response) {
8
- Logger.on = response.observe;
9
- });
10
- },
11
-
12
- observe: function(message) {
13
- if (this.on) {
14
- this.log(message);
15
- }
16
- },
17
-
18
- log: function(message) {
19
- // console.log("LOGGING " + message);
20
- OIB.post("ymdp/logs", {
21
- "_hide_debug": true,
22
- "log": message
23
- }, function() {
24
-
25
- });
26
- }
27
- };
@@ -1,27 +0,0 @@
1
- var Params = {
2
- names: ["invitation", "page"],
3
- parameters: {},
4
-
5
- init: function(launchParams) {
6
- launchParams = launchParams || {};
7
- Debug.log("Params.init", launchParams);
8
-
9
- if (launchParams) {
10
- Params.parameters = launchParams;
11
- } else {
12
- Params.parameters = {};
13
- }
14
- },
15
-
16
- get: function(name) {
17
- Debug.log("Params.get", name);
18
- var index, result;
19
-
20
- index = $.inArray(name, Params.names);
21
-
22
- if (index >= 0) {
23
- result = Params.parameters["param" + index];
24
- }
25
- return result;
26
- }
27
- };
@@ -1,47 +0,0 @@
1
- // DO NOT USE the @view instance variable in any files in /app/javascripts/base.
2
- // The way they are cached makes it not safe to do so.
3
-
4
- var Reporter;
5
-
6
- // Reports pageviews to OIB for tracking counts of each pageview.
7
- //
8
- // The main interface to this class is located in "header.js" where it can
9
- // make use of the current view name.
10
- //
11
- // == Usage
12
- //
13
- // Reporter.reportCurrentView(guid);
14
- //
15
- Reporter = {
16
- error: function(guid, params) {
17
- // Debug.log("Reporter.error", params);
18
- Reporter.report(guid, "error", params);
19
- },
20
-
21
- reportCurrentView: function(guid) {
22
- Reporter.report(guid, View.name);
23
- },
24
-
25
- // Report the Ymail guid and page view name to OIB.
26
- //
27
- report: function(guid, view, params) {
28
- params = params || {};
29
-
30
- params["ymail_guid"] = guid;
31
- params["view"] = view;
32
-
33
- // Debug.log("Reporting guid " + guid + ", view " + view);
34
- Reporter.post(params);
35
- },
36
-
37
- // Post data back to OIB, to the URL /ymdp/report.
38
- //
39
- post: function(params) {
40
- params = params || {};
41
- OIB.post("ymdp/report", params, function(response) {
42
- // Debug.log("Reported page view", params);
43
- }, function(response) {
44
- // Debug.error("Error reporting page view with params", response);
45
- });
46
- }
47
- };
@@ -1,205 +0,0 @@
1
- // gets user's state info from /ymdp/state
2
- // including the user's OIB login
3
- //
4
- YMDP.getUserState = function(success_function, error_function) {
5
- Debug.log("YMDP.getUserState");
6
- OIB.get("ymdp/state", {}, function(response) {
7
- Debug.log("YMDP.getUserState callback", response);
8
- YMDP.setUserVariables(response);
9
-
10
- if (success_function) {
11
- Debug.log("YMDP.getUserState: About to success function")
12
- success_function(response);
13
- }
14
- },
15
- function() {
16
- Debug.log("Failed to get user's state");
17
- if (error_function) {
18
- error_function();
19
- }
20
- });
21
- };
22
-
23
- YMDP.setUserVariables = function(response) {
24
- YMDP.response = response;
25
- try {
26
- YMDP.since_date = formatUnixDate(YMDP.response.since_date.s);
27
- } catch(omg) {
28
- YMDP.since_date = 1294869484;
29
- }
30
- YMDP.login = response.login;
31
- YMDP.state = response.state;
32
- };
33
-
34
- /*
35
- YMDP.verifyUser
36
-
37
- global to all views. calls the 'verify' action on ymdp controller and executes
38
- a function with the result.
39
-
40
- Sends the server the user's guid and 'ymail_wssid', which signs the user in if the
41
- values match what we have in the database.
42
- */
43
- YMDP.verifyUser = function(success_function, error_function) {
44
- Debug.log("YMDP.verifyUser");
45
-
46
- OIB.get("ymdp/verify", {
47
- ymail_guid: YMDP.guid,
48
- ymail_wssid: YMDP.ymail_wssid
49
- }, function(response) {
50
- YMDP.user = response;
51
- Debug.log("YMDP.verifyUser YMDP.user", YMDP.user);
52
- if (success_function) {
53
- Debug.log("YMDP.verifyUser: About to success function");
54
- success_function(YMDP.user);
55
- }
56
- }, error_function);
57
- };
58
-
59
-
60
- /*
61
- AUTHENTICATION
62
- */
63
-
64
- // Gets the ymail_wssid which is stored in the database on the remote server
65
- // for the current user.
66
- //
67
- YMDP.confirm = function() {
68
- Debug.log("YMDP.confirm");
69
- OIB.get("ymdp/signin", {
70
- "ymail_guid": YMDP.guid
71
- }, function(response) {
72
- Debug.log("inside ymdp/signin callback", response);
73
-
74
- if (response.ymail_wssid) {
75
- Debug.log("YMDP.response wasn't false");
76
- // store ymail_wssid in permanent store
77
-
78
- var raw_wssid = response.ymail_wssid || "";
79
- var sliced_wssid = raw_wssid.slice(0, 255);
80
-
81
- var data = {
82
- "ymail_wssid": sliced_wssid
83
- };
84
-
85
- Debug.log("About to call Data.store", data);
86
-
87
- Data.store(data);
88
- YMDP.ymail_wssid = response.ymail_wssid;
89
-
90
- // now that we've got their ymail_wssid, we can sign them in:
91
- YMDP.verifyUser(Launcher.launchMain);
92
- // Launcher.launchMain();
93
- } else {
94
- // signin didn't work properly, display an error
95
- Debug.log("YMDP.response was false");
96
- YMDP.showError({
97
- "method": "YMDP.confirm",
98
- "description": "no ymail_wssid"
99
- });
100
- }
101
- });
102
- };
103
-
104
- // gets both guid and ymail_wssid and stores them then runs the callback_function
105
- //
106
- // YMDP.ymail_wssid
107
- // YMDP.guid
108
- //
109
- YMDP.getGuidAndYmailWssid = function(callback_function) {
110
- Debug.log("YMDP.getGuidAndYmailWssid");
111
- YMDP.getGuid(function(guid) {
112
- YMDP.getYmailWssid(function(ymail_wssid) {
113
- callback_function(guid, ymail_wssid);
114
- });
115
- });
116
- };
117
-
118
- // gets the ymail_wssid from the permanent store and executes the callback function
119
- // if there is a ymail_wssid, and the error callback if it's undefined
120
- //
121
- // YMDP.ymail_wssid
122
- //
123
- YMDP.getYmailWssid = function(success_function, error_function) {
124
- Debug.log("YMDP.getYmailWssid");
125
-
126
- // this function will show the error page if the ymail_wssid has not been set
127
- //
128
- var show_error = function() {
129
- if (!YMDP.ymail_wssid) {
130
- Debug.log("No YMDP.ymail_wssid");
131
-
132
- YMDP.showError({
133
- "retry": "hide"
134
- });
135
- }
136
- };
137
-
138
- // run the show_error function after 5 seconds
139
- //
140
- // Debug.log("Set timeout for error function to 10 seconds");
141
- // YMDP.setTimeoutInSeconds(show_error, 10);
142
- // Debug.log("About to call Data.fetch");
143
-
144
- // retrieve the user's ymail_wssid and store it in YMDP.ymail_wssid
145
- //
146
- Data.fetch(["ymail_wssid"], function(response) {
147
- Debug.log("Inside Data.fetch callback");
148
- YMDP.ymail_wssid = response.data.ymail_wssid;
149
-
150
- Debug.log("YMDP.ymail_wssid is defined", YMDP.ymail_wssid);
151
-
152
- success_function(YMDP.ymail_wssid);
153
- });
154
- };
155
-
156
- // gets the guid from the Yahoo! environment and executes the success callback
157
- // if there is a guid, and the error callback if it's undefined
158
- //
159
- // YMDP.guid
160
- //
161
- YMDP.getGuid = function(success_function, error_function) {
162
- Debug.log("YMDP.getGuid");
163
-
164
- openmail.Application.getParameters(function(response) {
165
- Debug.log("getParameters callback");
166
- YMDP.guid = response.user.guid;
167
-
168
- Debug.log("YMDP.getGuid getParameters response", response);
169
-
170
- var params = {};
171
- if (response.data) {
172
- params = response.data.launchParams;
173
- }
174
-
175
- Params.init(params);
176
-
177
- if (YMDP.guid !== undefined) {
178
- success_function(YMDP.guid);
179
- }
180
- else {
181
- error_function();
182
- }
183
- });
184
- };
185
-
186
- YMDP.deactivateUser = function() {
187
- YMDP.getGuidAndYmailWssid(function() {
188
- var guid, ymail_wssid;
189
-
190
- guid = YMDP.guid;
191
- ymail_wssid = YMDP.ymail_wssid;
192
-
193
- Data.clear();
194
-
195
- OIB.post("/ymdp/deactivate", {
196
- "ymail_guid": guid,
197
- "ymail_wssid": ymail_wssid
198
- },
199
- function(response) {
200
- if (View.name !== "deactivate") {
201
- Launcher.launchGoodbye();
202
- }
203
- });
204
- });
205
- };