diff www/martin/js/nodescore-client.js @ 93:6889df0494a4

now possible to select which of the 4 parts are displayed in solo view - this is also updated on the fly
author Rob Canning <rob@foo.net>
date Thu, 31 Jul 2014 14:28:21 +0100
parents 1a706a2880ee
children cb1862bbcd5a
line wrap: on
line diff
--- a/www/martin/js/nodescore-client.js	Thu Jul 31 08:58:08 2014 +0100
+++ b/www/martin/js/nodescore-client.js	Thu Jul 31 14:28:21 2014 +0100
@@ -1,8 +1,6 @@
 /////////////////////////////////////////////////
 // connect to websocket
-
 var socket = io.connect();
-
 function initPage() { socket.emit("initPage");  
 		      console.log("init.client.log")
 		    }
@@ -41,7 +39,8 @@
     });
 
 /////////////////////////////////////////////////
-// countdown to change
+
+// countin (solo part)
 
 socket.on("countinFromServer", countinClient);
 function countinClient(groupID, currentseconds,mm,text,colour,background,unit){
@@ -54,7 +53,9 @@
  }}
 
 /////////////////////////////////////////////////
-// countdown to change
+
+// countdown to change (solo)
+
 socket.on("counterText", cText);
 function cText(groupID, currentseconds,text){
     $("#totalcountdown"+groupID).text(text);	
@@ -64,70 +65,89 @@
 	$("#totalcountdown").text(text);	
     }}
 
-///////////////////////////////////////
-//function pageFlip(unit) { $('#sections').trigger('goto', [parseFloat(unit)]); }
+// when voice is changed in UI grab and update from server
 
-/////////////////////////////////////////////////
-// call the fancy jquery functions
+function changeSoloVoice(v) { socket.emit("changeSoloVoice", v); }
 
-//function slideTo (target) { $('#sections').trigger('goto', [target]); }
-//function pad2(number) { return (number < 10 ? '0' : '') + number }       
+// makes sure page is loaded if not it grabs svg etc
 
-/////////////////////////////////////////////////
+socket.on("pageIni", pageIni);
+function pageIni (group,unit,time,mm,seqcounter,nextunit) { 
+    //console.log(unit + " ---> " + nextunit)
+    var soloist = $("#group").attr('value'); //4//$("#group").value;
+    if (group==1){
+	var n1 = $("#previewbox-1").html().indexOf("svg"); 
+	//console.log(n1)
+	if (n1 == -1){
+	    //console.log("n1 == -1 so load svg:")
+	    $("#previewbox-1").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+	}
+    }
+    
+    if (group==2){
+	var n2 = $("#previewbox-2").html().indexOf("svg"); 
+	if (n2 == -1){ 
+	    $("#previewbox-2").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+	}
+    }
 
-//var testSound = new buzz.sound( 'audio/testfile', { formats: [ 'ogg', 'mp3' ] } );
-/*socket.on("pageFlipfromserver", pageTurn);
-function pageTurn (group,unit,time,mm,seqcounter,nextunit) {
-    var groupPage=document.getElementById('group').value;
-    if (group == groupPage) {
-	console.log(unit + " ---> " + nextunit)
+    if (group==3){
+	var n3 = $("#previewbox-3").html().indexOf("svg"); 
+	if (n3 == -1){ 
+	    $("#previewbox-3").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+	}
+    }
 
-	//$("#preview").html("<h3 style='background:transparent; position: relative; font-size:1.5em;top:14px; left:10px;';> n e x t : </h3><img src='svg/"+ (nextunit) + ".svg" + "' width='305'>")
-	//$("#previewbox-"+group).html("<img src='svg/"+(unit) + ".svg" + "' width='515'>")
+    if (group==4){
+	var n4 = $("#previewbox-4").html().indexOf("svg"); 
+	if (n4 == -1){ 
+	    $("#previewbox-4").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+	}
     }
-    else { 
-	console.log("not for this group... ignoring... for group:" + group );
+
+
+    if (group==soloist) { 	
+	//console.log("INI sooolooooist=: ---------------------- : " + soloist)
+	var n = $("#previewbox-solo").html().indexOf("svg"); 
+	if (n == -1){ 
+            $("#previewbox-solo").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+    	    $("#previewbox-solo-next").html("<img src='svg/"+(nextunit) + ".svg" + "' width='100%'>")
+	}   
+    }
+}   
+
+socket.on("pageFlip", pageFlip);
+
+//  some if logic to check if file is already displayed
+// if not load it - client doesnt need to be present at start
+
+function pageFlip (group,unit,time,mm,seqcounter,nextunit) { 
+    var soloist = $("#group").attr('value');
+
+    if (group==1){
+	$("#previewbox-1").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>") 
+    }
+    
+    if (group==2){
+	$("#previewbox-2").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+    }
+    
+    if (group==3){
+	
+	$("#previewbox-3").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+    }
+    
+    if (group==4){
+	$("#previewbox-4").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+    }
+    
+    
+    if (group==soloist) {
+	$("#previewbox-solo").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
+	$("#previewbox-solo-next").html("<img src='svg/"+(nextunit) + ".svg" + "' width='100%'>")
     }
 }
 
-*/
-
-socket.on("pageIni", pageIni);
-//  some if logic to check if file is already displayed
-// if not load it - client doesnt need to be present at start
-function pageIni (group,unit,time,mm,seqcounter,nextunit) { 
-    console.log(unit + " ---> " + nextunit)
-    
-    if (group==1){
-    var n1 = $("#previewbox-1").html().indexOf("svg"); 
-    if (n1 == -1){ $("#previewbox-1").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")}
-    }
-
-    if (group==2){
-    var n2 = $("#previewbox-2").html().indexOf("svg"); 
-    if (n2 == -1){ $("#previewbox-2").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")}
-    }
-
-    if (group==3){
-    var n3 = $("#previewbox-3").html().indexOf("svg"); 
-    if (n3 == -1){ $("#previewbox-3").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")}
-    }
-
-    if (group==4){
-    var n4 = $("#previewbox-4").html().indexOf("svg"); 
-    if (n4 == -1){ $("#previewbox-4").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")}
-    }
-    
-    var n = $("#previewbox-solo").html().indexOf("svg"); 
-    if (n == -1){ 
-        $("#previewbox-solo").html("<img src='svg/"+(unit) + ".svg" + "' width='100%'>")
-	$("#previewbox-solo-next").html("<img src='svg/"+(nextunit) + ".svg" + "' width='100%'>")
-}
-
-
-    //}
-    
-}
 
 ////////////////////////////////////////////////
 
@@ -144,6 +164,7 @@
 
 
 */
+
 function toggle_visibility(id) {
     var e = document.getElementById(id);
     if(e.style.display == 'block')
@@ -170,6 +191,7 @@
 // no! the server broadcasts the ping and the clients emit the pong!
 // ah but then the time reported back from the server needs to be targeted
 // to specific client..
+
 //////////////////////////////////////////////
 // Latency "Pong"