/
modoDemo.js
76 lines (61 loc) · 1.48 KB
/
modoDemo.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
MAX_SLIDE=3
jQuery(document).ready(function(){
$('#screen').mousemove(function(e){
$('#status').html( e.pageX +', '+ e.pageY);
})
arrange_slides();
stListener();
goTo(1)
MAX_SLIDE=3
});
function pullNewSlides(){
total_slides
}
function arrange_slides() {
//console.log('arrangeslide')
$('.slide').each(function(index) {
$(this).css('top',196+10+index*166 + 'px');
}
)}
function goTo(n_slide){
$('#otherSlides').append($('.currentSlide'))
$('.currentSlide').switchClass('currentSlide','slide',0)
/* $('#contentbar').empty() */
//slide should be on and curentSlide off now
arrange_slides();
$('#n_'+n_slide).switchClass('slide','currentSlide',0);
$('.currentSlide').hide();
$('#contentbar').append($('.currentSlide'));
$('.currentSlide').show('clip',1000);
current_slide = n_slide;
}
function stListener(){
source = new EventSource('../../getAction')
source.onmessage = function (event) {
//setTimeout(this.send, 825);
if(event.data=='next'){
next();
console.log(event.data);
} else if(event.data=='prev') {
prev();
console.log(event.data);
}
console.log(event);
};
source.addEventListener("change", function( e ) {
console.log(e.data);
console.log(JSON.parse(e.data) );
}, false);
}
function next() {
if(current_slide==MAX_SLIDE)
return
else
goTo(current_slide+1)
}
function prev() {
if(current_slide==1)
return
else
goTo(current_slide-1)
}