annotate www/m/js/nodescore-slides.js @ 42:49c94f63b8b0

css for nexus 7 and associated files- archive m.a added - remove later
author tzara <rc-web@kiben.net>
date Tue, 04 Sep 2012 07:25:49 +0000
parents
children 7f0485e0d0ff
rev   line source
rc-web@42 1 /////////////////////////////////////////////////
rc-web@42 2 // connect to websocket
rc-web@42 3
rc-web@42 4 var socket = io.connect();
rc-web@42 5
rc-web@42 6 //socket.on("metroPulse", metronomeTick);
rc-web@42 7 /////////////////////////////////////////////////
rc-web@42 8 socket.on("metroPulse", pulseInClient);
rc-web@42 9 function pulseInClient(pulse,groupID,metrobeat){
rc-web@42 10 var groupPage=document.getElementById('group').value
rc-web@42 11 if (groupID == groupPage) {
rc-web@42 12 metronomeTick(1000, groupID, metrobeat);
rc-web@42 13 }
rc-web@42 14 }
rc-web@42 15 /////////////////////////////////////////////////
rc-web@42 16 function metroCss(beat, beatcolor,text){
rc-web@42 17 var color = beatcolor;
rc-web@42 18
rc-web@42 19 $(".metrocase > div").each(function(){$(this).stop()});
rc-web@42 20 $(".metrocase > div").each(function(){$(this).css('background-color', beatcolor)});
rc-web@42 21 $(".metrocase > div").each(function(){$(this).text(" ")});
rc-web@42 22 // $(".metrocase > div").each(function(){$(this).animate({color: blue},
rc-web@42 23 // 50,
rc-web@42 24 // function() { $(this).animate({color:red}); }
rc-web@42 25 // );
rc-web@42 26 // })
rc-web@42 27 }
rc-web@42 28
rc-web@42 29 function metronomeTick(pulse, voice,metrobeat) {
rc-web@42 30 var color = "gray"
rc-web@42 31 metroCss(0, "red", "4")
rc-web@42 32 setTimeout(function(){metroCss(0, "black", "4")},150);
rc-web@42 33 };
rc-web@42 34
rc-web@42 35 /////////////////////////////////////////////////
rc-web@42 36
rc-web@42 37 // update the stopwatch value on the client page in line with server
rc-web@42 38 socket.on("chronFromServer", function(chron) {
rc-web@42 39 $("div#client_chronometer").text(chron);
rc-web@42 40 });
rc-web@42 41
rc-web@42 42
rc-web@42 43 // server time
rc-web@42 44
rc-web@42 45 //var groupPage=document.getElementById('group').value
rc-web@42 46 //if (groupID == groupPage) {
rc-web@42 47 socket.on("dateTime", function(datetime) {
rc-web@42 48 // console.log(datetime)
rc-web@42 49 $("div#datetime").text("" +datetime);
rc-web@42 50
rc-web@42 51 });
rc-web@42 52
rc-web@42 53
rc-web@42 54 /////////////////////////////////////////////////
rc-web@42 55 // countdown to change
rc-web@42 56
rc-web@42 57 socket.on("countinFromServer", countinClient);
rc-web@42 58 function countinClient(groupID, currentseconds,mm,text,colour,background){
rc-web@42 59 var groupPage=document.getElementById('group').value
rc-web@42 60 if (groupID == groupPage) {
rc-web@42 61 document.getElementById("count").style.visibility="visible";
rc-web@42 62 document.getElementById("count").style.visibility="visible";
rc-web@42 63 $("#counttitle").text(text);
rc-web@42 64 $("#count").text(currentseconds);
rc-web@42 65 //$("#cnt").text(currentseconds);
rc-web@42 66 $("#count").css('background-color', background);
rc-web@42 67 document.getElementById("count").style.color=colour;
rc-web@42 68 // if ( currentseconds == 0) {
rc-web@42 69 //document.getElementById("midcomms").style.visibility='hidden';
rc-web@42 70 // }
rc-web@42 71 }}
rc-web@42 72 /////////////////////////////////////////////////
rc-web@42 73
rc-web@42 74 /////////////////////////////////////////////////
rc-web@42 75 // countdown to change
rc-web@42 76
rc-web@42 77 socket.on("counterText", cText);
rc-web@42 78 function cText(groupID, currentseconds,text){
rc-web@42 79 var groupPage=document.getElementById('group').value
rc-web@42 80 if (groupID == groupPage) {
rc-web@42 81 //console.log(text)
rc-web@42 82 $("#totalcountdown").text(text);
rc-web@42 83 }}
rc-web@42 84
rc-web@42 85 ///////////////////////////////////////
rc-web@42 86
rc-web@42 87 function pageFlip(unit) {
rc-web@42 88 console.log("flipping page:"+ unit);
rc-web@42 89 $('#sections').trigger('goto', [parseFloat(unit)]);
rc-web@42 90 }
rc-web@42 91
rc-web@42 92
rc-web@42 93 /////////////////////////////////////////////////
rc-web@42 94
rc-web@42 95 // call the fancy jquery functions
rc-web@42 96
rc-web@42 97 function slideTo (target) { $('#sections').trigger('goto', [target]); }
rc-web@42 98 function pad2(number) { return (number < 10 ? '0' : '') + number }
rc-web@42 99
rc-web@42 100 /////////////////////////////////////////////////
rc-web@42 101
rc-web@42 102 socket.on("pageFlipfromserver", pageTurn);
rc-web@42 103 function pageTurn (group,unit,time,mm) {
rc-web@42 104 var groupPage=document.getElementById('group').value;
rc-web@42 105 if (group == groupPage) {
rc-web@42 106 var g= pad2(group);
rc-web@42 107 var p= pad2(unit);
rc-web@42 108 // pageFlip(unit);
rc-web@42 109 pageTurnB(unit)
rc-web@42 110
rc-web@42 111 }
rc-web@42 112 else {
rc-web@42 113 console.log("not for this group... ignoring... for group:" + group );
rc-web@42 114 }
rc-web@42 115 }
rc-web@42 116
rc-web@42 117 function pageTurnB(unit) {
rc-web@42 118 var units=6;
rc-web@42 119 var next=(((unit+1)%units)+units)%units
rc-web@42 120 //console.log("HOP TURN" + unit+ "next:" + next);
rc-web@42 121 $("#live").load("music.html #"+unit +" *");
rc-web@42 122 $("#preview").html("<h3 style='background:transparent; position: absolute; font-size:2em;top:14px; right:4px;';> n e x t : </h3><img src='thumbs/"+next + ".png" + "' width='400'>")
rc-web@42 123 }
rc-web@42 124
rc-web@42 125 ////////////////////////////////////////////////
rc-web@42 126
rc-web@42 127 /* commented out for now as interferes with chat
rc-web@42 128 need to introduce metakey...manyana... not so usefull anyway really...
rc-web@42 129
rc-web@42 130 keyboard controls
rc-web@42 131 +++++++++++++++++++++++++
rc-web@42 132
rc-web@42 133 SPACE to toggle visibilty of preview
rc-web@42 134 m to toggle visibilty of metronome
rc-web@42 135 s to toggle visibilty of stopwatch
rc-web@42 136 h to hide all above
rc-web@42 137
rc-web@42 138
rc-web@42 139 */
rc-web@42 140 function toggle_visibility(id) {
rc-web@42 141 var e = document.getElementById(id);
rc-web@42 142 if(e.style.display == 'block')
rc-web@42 143 e.style.display = 'none';
rc-web@42 144 else
rc-web@42 145 e.style.display = 'block';
rc-web@42 146 }
rc-web@42 147
rc-web@42 148 $(document).keypress(function(e){
rc-web@42 149 // "space bar" for next unit preview
rc-web@42 150 var checkWebkitandIE=(e.which==32 ? 1 : 0);
rc-web@42 151 var checkMoz=(e.which==32 ? 1 : 0);
rc-web@42 152 // "m" button for metronome
rc-web@42 153 var mcheckWebkitandIE=(e.which==109 ? 1 : 0);
rc-web@42 154 var mcheckMoz=(e.which==109 ? 1 : 0);
rc-web@42 155 // "s" button for stopwatch/chronometer
rc-web@42 156 var ccheckWebkitandIE=(e.which==115 ? 1 : 0);
rc-web@42 157 var ccheckMoz=(e.which==115 ? 1 : 0);
rc-web@42 158
rc-web@42 159 // "h" button for hideall
rc-web@42 160 var hcheckWebkitandIE=(e.which==104 ? 1 : 0);
rc-web@42 161 var hcheckMoz=(e.which==104 ? 1 : 0);
rc-web@42 162
rc-web@42 163 // console.log(e.which);
rc-web@42 164 // if (checkWebkitandIE || checkMoz) { toggle_visibility('preview') }
rc-web@42 165 // if (mcheckWebkitandIE || mcheckMoz) { toggle_visibility('comms') }
rc-web@42 166 // if (ccheckWebkitandIE || ccheckMoz) { toggle_visibility('client_chronometer') }
rc-web@42 167 if (hcheckWebkitandIE || hcheckMoz) {
rc-web@42 168 toggle_visibility('info')
rc-web@42 169 //toggle_visibility('comms')
rc-web@42 170 //toggle_visibility('preview')
rc-web@42 171 }
rc-web@42 172 });
rc-web@42 173
rc-web@42 174 //*/
rc-web@42 175
rc-web@42 176 ////////////////////////////////////////////////
rc-web@42 177 // this needs to have a variable to define the websocket
rc-web@42 178 // otherwise we will pings from all sockets connected
rc-web@42 179 // no! the server broadcasts the ping and the clients emit the pong!
rc-web@42 180 // ah but then the time reported back from the server needs to be targeted
rc-web@42 181 // to specific client..
rc-web@42 182 //////////////////////////////////////////////
rc-web@42 183 // Latency "Pong"
rc-web@42 184
rc-web@42 185 socket.on("timeFromServer", function(n) {
rc-web@42 186 socket.emit("clientTimeResponse",n);
rc-web@42 187 });
rc-web@42 188 socket.on("latencyFromServer", function(latency) {
rc-web@42 189 $("#client_latency").text("Latency: "+latency+"ms.")
rc-web@42 190 //console.log(latency)
rc-web@42 191 });
rc-web@42 192
rc-web@42 193 function getLatencies(x) { socket.emit("getLatencies", x); }
rc-web@42 194
rc-web@42 195 //////////////////////////////////////////////
rc-web@42 196
rc-web@42 197
rc-web@42 198 socket.on('connect', function () {
rc-web@42 199 $('#chat').addClass('connected');
rc-web@42 200 });
rc-web@42 201
rc-web@42 202 socket.on('announcement', function (msg) {
rc-web@42 203 $('#lines').append($('<p>').append($('<em>').text(msg)));
rc-web@42 204 });
rc-web@42 205
rc-web@42 206 socket.on('nicknames', function (nicknames) {
rc-web@42 207 $('#nicknames').empty().append($('<span>Online: </span>'));
rc-web@42 208 for (var i in nicknames) {
rc-web@42 209 $('#nicknames').append($('<b>').text(nicknames[i]));
rc-web@42 210 }
rc-web@42 211 });
rc-web@42 212
rc-web@42 213 socket.on('user message', message);
rc-web@42 214 socket.on('reconnect', function () {
rc-web@42 215 $('#lines').remove();
rc-web@42 216 message('System', 'Reconnected to the server');
rc-web@42 217 });
rc-web@42 218
rc-web@42 219 socket.on('reconnecting', function () {
rc-web@42 220 message('System', 'Attempting to re-connect to the server');
rc-web@42 221 });
rc-web@42 222
rc-web@42 223 socket.on('error', function (e) {
rc-web@42 224 message('System', e ? e : 'A unknown error occurred');
rc-web@42 225 });
rc-web@42 226
rc-web@42 227 function message (from, msg) {
rc-web@42 228 $('#lines').append($('<p>').append($('<b>').text(from), msg));
rc-web@42 229 }
rc-web@42 230
rc-web@42 231 // dom manipulation
rc-web@42 232 $(function () {
rc-web@42 233 $('#set-nickname').submit(function (ev) {
rc-web@42 234 socket.emit('nickname', $('#nick').val(), function (set) {
rc-web@42 235 if (!set) {
rc-web@42 236 clear();
rc-web@42 237 return $('#chat').addClass('nickname-set');
rc-web@42 238 }
rc-web@42 239 $('#nickname-err').css('visibility', 'visible');
rc-web@42 240 });
rc-web@42 241 return false;
rc-web@42 242 });
rc-web@42 243
rc-web@42 244 $('#send-message').submit(function () {
rc-web@42 245 message('me', $('#message').val());
rc-web@42 246 socket.emit('user message', $('#message').val());
rc-web@42 247 clear();
rc-web@42 248 $('#lines').get(0).scrollTop = 10000000;
rc-web@42 249 return false;
rc-web@42 250 });
rc-web@42 251
rc-web@42 252 function clear () {
rc-web@42 253 $('#message').val('').focus();
rc-web@42 254 };
rc-web@42 255 });