rc-web@12
|
1 /////////////////////////////////////////////////
|
rc-web@12
|
2 // connect to websocket
|
rc-web@12
|
3
|
rc-web@12
|
4 var socket = io.connect();
|
rc-web@12
|
5
|
rc-web@12
|
6 //socket.on("metroPulse", metronomeTick);
|
rc-web@12
|
7 /////////////////////////////////////////////////
|
rc-web@12
|
8 socket.on("metroPulse", pulseInClient);
|
rc-web@12
|
9 function pulseInClient(pulse,groupID,metrobeat){
|
rc-web@12
|
10 var groupPage=document.getElementById('group').value
|
rc-web@12
|
11 if (groupID == groupPage) {
|
rc-web@12
|
12 metronomeTick(1000, groupID, metrobeat);
|
rc-web@12
|
13 }
|
rc-web@12
|
14 }
|
rc-web@12
|
15 /////////////////////////////////////////////////
|
rc-web@12
|
16 function metroCss(beat, beatcolor,text){
|
rc-web@12
|
17 var color = beatcolor;
|
rc-web@12
|
18
|
rc-web@12
|
19 $(".metrocase > div").each(function(){$(this).stop()});
|
rc-web@12
|
20 $(".metrocase > div").each(function(){$(this).css('background-color', beatcolor)});
|
rc-web@12
|
21 $(".metrocase > div").each(function(){$(this).text(" ")});
|
rc-web@12
|
22 $(".metrocase > div").each(function(){$(this).animate({opacity: 0.5},
|
rc-web@12
|
23 50,
|
rc-web@12
|
24 function() { $(this).animate({opacity:0.0}); }
|
rc-web@12
|
25 );
|
rc-web@12
|
26 })
|
rc-web@12
|
27 }
|
rc-web@12
|
28
|
rc-web@12
|
29 function metronomeTick(pulse, voice,metrobeat) {
|
rc-web@12
|
30 var color = "gray"
|
rc-web@12
|
31 metroCss(0, "red", "4")
|
rc-web@12
|
32 };
|
rc-web@12
|
33
|
rc-web@12
|
34 /////////////////////////////////////////////////
|
rc-web@12
|
35
|
rc-web@12
|
36 // update the stopwatch value on the client page in line with server
|
rc-web@12
|
37 socket.on("chronFromServer", function(chron) {
|
rc-web@12
|
38 $("div#client_chronometer").text(chron);
|
rc-web@12
|
39 });
|
rc-web@12
|
40
|
rc-web@20
|
41
|
rc-web@20
|
42
|
rc-web@20
|
43
|
rc-web@20
|
44 /////////////////////////////////////////////////
|
rc-web@20
|
45 // countdown to change
|
rc-web@20
|
46
|
rc-web@20
|
47 socket.on("countinFromServer", countinClient);
|
rc-web@20
|
48 function countinClient(groupID, currentseconds,mm,text,colour,background){
|
rc-web@20
|
49 var groupPage=document.getElementById('group').value
|
rc-web@20
|
50 if (groupID == groupPage) {
|
rc-web@20
|
51 console.log(currentseconds);
|
rc-web@20
|
52 document.getElementById("countinnumber").style.visibility="visible";
|
rc-web@20
|
53 document.getElementById("countinnumber").style.visibility="visible";
|
rc-web@20
|
54 //$("#countin").text(text);
|
rc-web@20
|
55 $("#countinnumber").text(currentseconds);
|
rc-web@20
|
56 $("#countinnumber").css('background-color', background);
|
rc-web@20
|
57
|
rc-web@20
|
58 document.getElementById("countinnumber").style.color=colour;
|
rc-web@20
|
59
|
rc-web@20
|
60 if ( currentseconds == 0) {
|
rc-web@20
|
61 document.getElementById("countinnumber").style.visibility='hidden';
|
rc-web@20
|
62 // document.getElementById("countin").style.visibility='hidden';
|
rc-web@20
|
63 }
|
rc-web@20
|
64 }}
|
rc-web@20
|
65
|
rc-web@12
|
66 /////////////////////////////////////////////////
|
rc-web@12
|
67
|
rc-web@12
|
68 function pageFlip(unit) {
|
rc-web@12
|
69 console.log("flipping page:"+ unit);
|
rc-web@12
|
70 $('#sections').trigger('goto', [parseFloat(unit)]);
|
rc-web@16
|
71 // $('#sections-preview').trigger('goto', [parseFloat(unit+1)]);
|
rc-web@12
|
72 //metroStart(1000);
|
rc-web@12
|
73 //document.getElementById("countdowncase").style.visibility="hidden";
|
rc-web@12
|
74 }
|
rc-web@12
|
75
|
rc-web@16
|
76
|
rc-web@16
|
77
|
rc-web@12
|
78 /////////////////////////////////////////////////
|
rc-web@16
|
79
|
rc-web@12
|
80 // call the fancy jquery functions
|
rc-web@12
|
81
|
rc-web@12
|
82 function slideTo (target) { $('#sections').trigger('goto', [target]); }
|
rc-web@12
|
83 function pad2(number) { return (number < 10 ? '0' : '') + number }
|
rc-web@12
|
84
|
rc-web@12
|
85 /////////////////////////////////////////////////
|
rc-web@12
|
86
|
rc-web@12
|
87 socket.on("pageFlipfromserver", pageTurn);
|
rc-web@12
|
88 function pageTurn (group,unit,time,mm) {
|
rc-web@12
|
89 var groupPage=document.getElementById('group').value;
|
rc-web@16
|
90 //console.log("fromservercommand has been executed on client");
|
rc-web@12
|
91 if (group == groupPage) {
|
rc-web@12
|
92 var g= pad2(group);
|
rc-web@12
|
93 var p= pad2(unit);
|
rc-web@16
|
94 // pageFlip(unit);
|
rc-web@20
|
95 pageTurnB(unit)
|
rc-web@16
|
96
|
rc-web@16
|
97 }
|
rc-web@12
|
98 else {
|
rc-web@12
|
99 console.log("not for this group... ignoring... for group:" + group );
|
rc-web@12
|
100 }
|
rc-web@12
|
101 }
|
rc-web@12
|
102
|
rc-web@16
|
103 function pageTurnB(unit) {
|
rc-web@21
|
104 var units=6;
|
rc-web@21
|
105 var section = "seta/"
|
rc-web@20
|
106 var next=(((unit+1)%units)+units)%units
|
rc-web@20
|
107 console.log("HOP TURN" + unit+ "next:" + next);
|
rc-web@20
|
108 // $("#live").html($("#unit"+unit).html());
|
rc-web@21
|
109 $("#live").load(section+"music.html #"+unit +" *");
|
rc-web@20
|
110
|
rc-web@21
|
111 $("#preview").html('<img src=' + section+"img/thumbs/"+next + ".png" + '>');
|
rc-web@16
|
112 }
|
rc-web@16
|
113
|
rc-web@18
|
114 ////////////////////////////////////////////////
|
rc-web@20
|
115
|
rc-web@20
|
116 /*
|
rc-web@20
|
117
|
rc-web@20
|
118 keyboard controls
|
rc-web@20
|
119 +++++++++++++++++++++++++
|
rc-web@20
|
120
|
rc-web@20
|
121 SPACE to toggle visibilty of preview
|
rc-web@20
|
122 m to toggle visibilty of metronome
|
rc-web@20
|
123 s to toggle visibilty of stopwatch
|
rc-web@20
|
124 h to hide all above
|
rc-web@20
|
125
|
rc-web@20
|
126 */
|
rc-web@20
|
127
|
rc-web@18
|
128 function toggle_visibility(id) {
|
rc-web@18
|
129 var e = document.getElementById(id);
|
rc-web@18
|
130 if(e.style.display == 'block')
|
rc-web@18
|
131 e.style.display = 'none';
|
rc-web@18
|
132 else
|
rc-web@18
|
133 e.style.display = 'block';
|
rc-web@18
|
134 }
|
rc-web@18
|
135
|
rc-web@18
|
136 $(document).keypress(function(e){
|
rc-web@19
|
137 // "space bar" for next unit preview
|
rc-web@18
|
138 var checkWebkitandIE=(e.which==32 ? 1 : 0);
|
rc-web@18
|
139 var checkMoz=(e.which==32 ? 1 : 0);
|
rc-web@19
|
140 // "m" button for metronome
|
rc-web@19
|
141 var mcheckWebkitandIE=(e.which==109 ? 1 : 0);
|
rc-web@19
|
142 var mcheckMoz=(e.which==109 ? 1 : 0);
|
rc-web@19
|
143 // "s" button for stopwatch/chronometer
|
rc-web@19
|
144 var ccheckWebkitandIE=(e.which==115 ? 1 : 0);
|
rc-web@19
|
145 var ccheckMoz=(e.which==115 ? 1 : 0);
|
rc-web@19
|
146
|
rc-web@19
|
147 // "h" button for hideall
|
rc-web@19
|
148 var hcheckWebkitandIE=(e.which==104 ? 1 : 0);
|
rc-web@19
|
149 var hcheckMoz=(e.which==104 ? 1 : 0);
|
rc-web@19
|
150
|
rc-web@19
|
151 console.log(e.which);
|
rc-web@19
|
152 if (checkWebkitandIE || checkMoz) { toggle_visibility('preview') }
|
rc-web@19
|
153 if (mcheckWebkitandIE || mcheckMoz) { toggle_visibility('metro') }
|
rc-web@19
|
154 if (ccheckWebkitandIE || ccheckMoz) { toggle_visibility('client_chronometer') }
|
rc-web@19
|
155 if (hcheckWebkitandIE || hcheckMoz) {
|
rc-web@19
|
156 toggle_visibility('client_chronometer')
|
rc-web@19
|
157 toggle_visibility('metro')
|
rc-web@19
|
158 toggle_visibility('preview')
|
rc-web@19
|
159 }
|
rc-web@18
|
160 });
|
rc-web@18
|
161
|
rc-web@18
|
162 ////////////////////////////////////////////////
|