-
Notifications
You must be signed in to change notification settings - Fork 0
/
ramen_client.js
43 lines (37 loc) · 981 Bytes
/
ramen_client.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
var loadJS = function() {
var ramenJsUrl = 'https://cdn.ramen.is/assets/ramen.js';
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = ramenJsUrl;
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s,x);
};
//Meteor.subscribe('currentUserRamenHash');
var tracker_callback = function() {
var user = Meteor.user();
if (!user) {
delete(window.ramenSettings);
if (window.Ramen && window.Ramen.abort) {
window.Ramen.abort.die();
}
return;
}
var name = user.name || user.emails[0].address;
window.ramenSettings = {
organization_id: Meteor.settings.public.ramen.organization_id,
user: {
id: user._id,
email: user.emails[0].address,
name: name
}
};
if (window.Ramen && typeof window.Ramen.go === 'function') {
window.Ramen.go();
} else {
loadJS();
}
};
Meteor.startup(function() {
Tracker.autorun(tracker_callback);
});