comparison www/m/js/controlseq.js @ 5:9070b2a7ca65

nodescore magicsquare example web files commited
author tzara <rc-web@kiben.net>
date Wed, 04 Jul 2012 13:10:04 +0000
parents
children 83dfd5f7186a
comparison
equal deleted inserted replaced
4:e1e53574e68d 5:9070b2a7ca65
1 //////////////////////////////////////////////
2
3 var socket = io.connect();
4
5 //////////////////////////////////////////////
6 // Sequencer Controls
7
8 function startSeq() { socket.emit("startSeq") }
9 function stopSeq() { socket.emit("stopSeq") }
10
11 //////////////////////////////////////////////
12 // Metronome Controls
13
14 //socket.on("metroPulse", metronomeTick);
15 function metroStart(pulse) { socket.emit("metroStart", pulse);}
16 function metroStop() { socket.emit("metroStop");}
17
18 //////////////////////////////////////////////
19 // Latency "Pong"
20
21 socket.on("timeFromServer", function(n) {
22 socket.emit("clientTimeResponse",n);
23 //console.log(n);
24 });
25 socket.on("latencyFromServer", function(latency) {
26 $("#client_latency").text(latency+"ms.")
27 });
28
29 function getLatencies(x) { socket.emit("getLatencies", x); }
30
31 //////////////////////////////////////////////
32 // Chronometer Controls
33
34 function startChr() { socket.emit("startChr"); }
35 function stopChr() { socket.emit("stopChr"); }
36 function resetChr() {
37 socket.emit("resetChr");
38 $("div#client_chronometer").text("00:00:00.0");
39 }
40 socket.on("chronFromServer", function(chron){
41 //console.log(chron);
42 $("div#client_chronometer").text(chron);
43 });
44
45 //////////////////////////////////////////////
46 // SEQUENCER MONITOR
47
48 socket.on("magicCtlfromserver", sequenceMonitor);
49 function sequenceMonitor(group, unit,time,mm,seq){
50 var n=6; var x=seq-1; var off=((x%n)+n)%n // thanks claudiusmaximus
51 seqnow = "#"+group+"magicsquare"+seq
52 turnmeoff = "#"+group+"magicsquare"+off
53 $(seqnow).css('background-color', 'white');
54 $(turnmeoff).css('background-color', 'blue')
55 //console.log("#"+group+"magicsquare"+seq +" time: " +time + " %:" + off)
56 }
57 //////////////////////////////////////////////
58 // CLient Popup window code
59
60 function newPopup(url) {
61 popupWindow = window.open(
62 url,'popUpWindow','height=400,width=800,left=10,top=10,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,titlebar=no,directories=no,status=yes')}