Mercurial > hg > nodescore
comparison www/m/js/nodescore-client.js @ 12:d2eda8be1fca
add phantomjs dependency for thumbnail preview generation
author | tzara <rc-web@kiben.net> |
---|---|
date | Sun, 08 Jul 2012 23:51:17 +0100 |
parents | |
children | e05eede75e0d |
comparison
equal
deleted
inserted
replaced
11:0a8133490050 | 12:d2eda8be1fca |
---|---|
1 ///////////////////////////////////////////////// | |
2 // connect to websocket | |
3 | |
4 var socket = io.connect(); | |
5 | |
6 //socket.on("metroPulse", metronomeTick); | |
7 ///////////////////////////////////////////////// | |
8 socket.on("metroPulse", pulseInClient); | |
9 function pulseInClient(pulse,groupID,metrobeat){ | |
10 var groupPage=document.getElementById('group').value | |
11 if (groupID == groupPage) { | |
12 metronomeTick(1000, groupID, metrobeat); | |
13 } | |
14 } | |
15 ///////////////////////////////////////////////// | |
16 function metroCss(beat, beatcolor,text){ | |
17 var color = beatcolor; | |
18 | |
19 $(".metrocase > div").each(function(){$(this).stop()}); | |
20 $(".metrocase > div").each(function(){$(this).css('background-color', beatcolor)}); | |
21 $(".metrocase > div").each(function(){$(this).text(" ")}); | |
22 $(".metrocase > div").each(function(){$(this).animate({opacity: 0.5}, | |
23 50, | |
24 function() { $(this).animate({opacity:0.0}); } | |
25 ); | |
26 }) | |
27 } | |
28 | |
29 | |
30 | |
31 function metronomeTick(pulse, voice,metrobeat) { | |
32 console.log( voice+ " metronome tick" + metrobeat) | |
33 var color = "gray" | |
34 | |
35 metroCss(0, "red", "4") | |
36 | |
37 //if (metrobeat == 0) { | |
38 // metroCss(0, "gray", "1") | |
39 // } | |
40 | |
41 //if (metrobeat == 3) { | |
42 // metroCss(0, "white", "4") | |
43 // } | |
44 | |
45 // if (metrobeat == 1||metrobeat == 2){ | |
46 // $("#metronome"+metrobeat).stop(); | |
47 // $("#metronome"+metrobeat).css('background-color', color); | |
48 // $("#metronome"+metrobeat).text(" "); | |
49 //$("#metronome"+metrobeat).text(metrobeat+1); | |
50 // $("#metronome"+metrobeat).animate({opacity: 1}, | |
51 // 50, | |
52 // function() { $(this).animate({opacity:0.0}); } | |
53 // ); | |
54 // } | |
55 }; | |
56 | |
57 ///////////////////////////////////////////////// | |
58 | |
59 // update the stopwatch value on the client page in line with server | |
60 socket.on("chronFromServer", function(chron) { | |
61 $("div#client_chronometer").text(chron); | |
62 }); | |
63 | |
64 ///////////////////////////////////////////////// | |
65 | |
66 function pageFlip(unit) { | |
67 console.log("flipping page:"+ unit); | |
68 $('#sections').trigger('goto', [parseFloat(unit)]); | |
69 //metroStart(1000); | |
70 //document.getElementById("countdowncase").style.visibility="hidden"; | |
71 } | |
72 | |
73 ///////////////////////////////////////////////// | |
74 // call the fancy jquery functions | |
75 | |
76 function slideTo (target) { $('#sections').trigger('goto', [target]); } | |
77 function pad2(number) { return (number < 10 ? '0' : '') + number } | |
78 | |
79 ///////////////////////////////////////////////// | |
80 | |
81 socket.on("pageFlipfromserver", pageTurn); | |
82 function pageTurn (group,unit,time,mm) { | |
83 var groupPage=document.getElementById('group').value; | |
84 console.log("fromservercommand has been executed on client"); | |
85 if (group == groupPage) { | |
86 var g= pad2(group); | |
87 var p= pad2(unit); | |
88 pageFlip(unit); | |
89 } | |
90 else { | |
91 console.log("not for this group... ignoring... for group:" + group ); | |
92 } | |
93 } | |
94 | |
95 ///////////////////////////////////////////////// |