-
Notifications
You must be signed in to change notification settings - Fork 2
/
leaderboard.js
91 lines (56 loc) · 1.83 KB
/
leaderboard.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
//Track users online status
urls = new Mongo.Collection("urls");
//Make the routes
// simple route with
// name 'home' that
// matches '/' and automatically renders
// template 'home'
Router.route('/', function () {
this.render('home');
});
//Videos!
Router.map(function() {
this.route('video', {
path: '/video',
data: function () {
//get the player on the page with the right ID
callTheYouTube(this.params.query.video_id)
//trying to set up the real time chat
window.myDataRef = new Firebase('https://torrid-fire-9103.firebaseio-demo.com/' + this.params.query.video_id);
window.myDataRef.on('child_added', function(snapshot) {
var message = snapshot.val();
displayChatMessage(message.time, message.name, message.text);
});
function displayChatMessage(time, name, text) {
$('<div/>').text(text).prepend($('<em/>').text(time + ' -- ' +name+' -- ')).appendTo($('#messagesDiv'));
$('#messagesDiv')[0].scrollTop = $('#messagesDiv')[0].scrollHeight;
}
//Track online status
}
});
});
if (Meteor.isClient) {
function callTheYouTube(videoID) {
// YouTube API will call onYouTubeIframeAPIReady() when API ready.
// Make sure it's a global variable.
onYouTubeIframeAPIReady = function () {
// New Video Player, the first argument is the urlsid of the div.
// Make sure it's a global variable.
player = new YT.Player("player", {
height: "400",
width: "800",
videoId: videoID,
// Events like ready, state change,
events: {
onReady: function (event) {
// Play video when player ready.
event.target.playVideo();
}
}
});
};
}
YT.load();
}
if (Meteor.isServer) {
}