changeset 136:c849dcbe71aa

Merge
author Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk>
date Thu, 28 May 2015 19:27:39 +0100
parents d769f1623203 (diff) 93fa802a9318 (current diff)
children 076f014a6847 04fcd51441e5
files ape.js core.js
diffstat 2 files changed, 49 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ape.js	Wed May 27 20:24:17 2015 +0100
+++ b/ape.js	Thu May 28 19:27:39 2015 +0100
@@ -22,6 +22,7 @@
 	// The injection point into the HTML page
 	var insertPoint = document.getElementById("topLevelBody");
 	var testContent = document.createElement('div');
+	
 	testContent.id = 'testContent';
 	
 	
@@ -264,6 +265,8 @@
 	// Load the full interface
 	testState.initialise();
 	testState.advanceState();
+	
+	testWaitIndicator();
 }
 
 function loadTest(textXML)
@@ -444,20 +447,23 @@
 		trackSliderObj.onclick = function() {
 			// Start the test on first click, that way timings are more accurate.
 			audioEngineContext.play();
-			// Get the track ID from the object ID
-			var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
-			//audioEngineContext.metric.sliderPlayed(id);
-			audioEngineContext.selectedTrack(id);
-            // Currently playing track red, rest green
-            document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
-            for (var i = 0; i<$(currentTrackOrder).length; i++)
-            {
-                if (i!=index) // Make all other sliders green
-                {
-                    document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)";
-                }
-                              
-            }
+			if (audioEngineContext.audioObjectsReady) {
+				// Cannot continue to issue play command until audioObjects reported as ready!
+				// Get the track ID from the object ID
+				var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
+				//audioEngineContext.metric.sliderPlayed(id);
+				audioEngineContext.selectedTrack(id);
+	            // Currently playing track red, rest green
+	            document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
+	            for (var i = 0; i<$(currentTrackOrder).length; i++)
+	            {
+	                if (i!=index) // Make all other sliders green
+	                {
+	           	        document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)";
+	                }
+	                              
+	            }
+			}
 		};
 		
 		canvas.appendChild(trackSliderObj);
--- a/core.js	Wed May 27 20:24:17 2015 +0100
+++ b/core.js	Thu May 28 19:27:39 2015 +0100
@@ -192,6 +192,7 @@
 	this.currentIndex = null;
 	this.currentTestId = 0;
 	this.stateResults = [];
+	this.timerCallBackHolders = null;
 	this.initialise = function(){
 		if (this.stateMap.length > 0) {
 			if(this.stateIndex != null) {
@@ -492,6 +493,13 @@
 				ready = false;
 			};
 		}
+		if (ready == false) {
+			var holder = document.getElementById('testWaitIndicator');
+			holder.style.visibility = "visible";
+			setInterval(function() {
+				document.getElementById('testWaitIndicator').style.visibility = "hidden";
+			}, 10000);
+		}
 		return ready;
 	};
 	
@@ -753,4 +761,24 @@
 	hold.appendChild(time);
 	return hold
 	
-}
\ No newline at end of file
+}
+
+function testWaitIndicator() {
+	var hold = document.createElement("div");
+	hold.id = "testWaitIndicator";
+	hold.style.position = "absolute";
+	hold.style.left = "100px";
+	hold.style.top = "10px";
+	hold.style.width = "500px";
+	hold.style.height = "100px";
+	hold.style.padding = "20px";
+	hold.style.backgroundColor = "rgb(100,200,200)";
+	hold.style.visibility = "hidden";
+	var span = document.createElement("span");
+	span.textContent = "Please wait! Elements still loading";
+	hold.appendChild(span);
+	var body = document.getElementsByTagName('body')[0];
+	body.appendChild(hold);
+}
+
+var hidetestwait = null;