-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipad_hooks.js
75 lines (67 loc) · 1.84 KB
/
ipad_hooks.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
var isPlaying = false;
var streamId = "someStreamId2";
function emit(command, data) {
console.log("emit");
data.streamId = streamId;
socket.emit(command,data);
}
function connect() {
console.log("connecting to " + serverLocation + " using streamId " + streamId);
socket = io.connect(serverLocation);
socket.emit("join", {'streamId': streamId});
socket.emit("getTime", {'emptystuff': streamId});
socket.on('onPlay', handleOnPlay);
socket.on('onPause', handleOnPause);
socket.on('time', handleTime);
}
var getTime = function() {
socket.emit("getTime", {'emptystuff': streamId});
}
var handleFeed = function(currenttime) {
//console.log("hanleFeed currenttime " + currenttime);
var data = timeFeed;
var topItem = null;
$.each(data.timefeed, function(i, item) {
var x = document.getElementById('item' + item.feedid);
//console.log(i + " " + item.feedid + " ct: " + currenttime + " start: " + item.start + " " + x);
if (x == null) {
console.log("cant find " + item.feedid);
}
else if (currenttime >= item.start) {
//console.log("showing");
//console.log(i + " " + item.feedid + " " + item.start);
if (x.style.display == 'none') {
$(x).fadeIn("fast");
topItem = item;
//x.style.display = '';
}
}
else {
//console.log("hiding");
x.style.display = 'none';
}
});
if (topItem && autosurf) {
console.log("topItem" + topItem.title);
if (topItem.url) {
openUrl(topItem.url);
}
}
}
var handleTime = function(data) {
console.log("handleTime");
handleFeed(data.time);
}
var handleOnPlay = function(data) {
console.log("handleOnPlay");
handleFeed(data.time);
isPlaying = true;
};
var handleOnPause = function(data) {
if (isPlaying == false) {
return;
}
console.log("handleOnPause");
handleFeed(data.time);
isPlaying = false;
};