comparison core.js @ 2013:57045ee30b64

Feature #1252: Test Wait Indicator now fully implemented with auto clearing on test ready.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Mon, 01 Jun 2015 09:46:51 +0100
parents bc178ec0e3b1
children 98a5db2ae8a1
comparison
equal deleted inserted replaced
2012:f2ef4be20d7f 2013:57045ee30b64
9 var audioContext; // Hold the browser web audio API 9 var audioContext; // Hold the browser web audio API
10 var projectXML; // Hold the parsed setup XML 10 var projectXML; // Hold the parsed setup XML
11 var popup; // Hold the interfacePopup object 11 var popup; // Hold the interfacePopup object
12 var testState; 12 var testState;
13 var currentState; // Keep track of the current state (pre/post test, which test, final test? first test?) 13 var currentState; // Keep track of the current state (pre/post test, which test, final test? first test?)
14 //var testXMLSetups = []; // Hold the parsed test instances
15 //var testResultsHolders =[]; // Hold the results from each test for publishing to XML
16 var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order 14 var currentTrackOrder = []; // Hold the current XML tracks in their (randomised) order
17 //var currentTestHolder; // Hold any intermediate results during test - metrics
18 var audioEngineContext; // The custome AudioEngine object 15 var audioEngineContext; // The custome AudioEngine object
19 var projectReturn; // Hold the URL for the return 16 var projectReturn; // Hold the URL for the return
20 //var preTestQuestions = document.createElement('PreTest'); // Store any pre-test question response 17
21 //var postTestQuestions = document.createElement('PostTest'); // Store any post-test question response
22 18
23 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it 19 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it
24 AudioBufferSourceNode.prototype.owner = undefined; 20 AudioBufferSourceNode.prototype.owner = undefined;
25 21
26 window.onload = function() { 22 window.onload = function() {
380 xmlhttp.onerror = function(){ 376 xmlhttp.onerror = function(){
381 console.log('Error saving file to server! Presenting download locally'); 377 console.log('Error saving file to server! Presenting download locally');
382 createProjectSave(null); 378 createProjectSave(null);
383 }; 379 };
384 xmlhttp.send(file); 380 xmlhttp.send(file);
381 if (xmlhttp.status == 404) {
382 createProjectSave(null);
383 }
385 } 384 }
386 return submitDiv; 385 return submitDiv;
387 } 386 }
388 387
389 // Only other global function which must be defined in the interface class. Determines how to create the XML document. 388 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
493 if (this.audioObjects[i].state == 0) { 492 if (this.audioObjects[i].state == 0) {
494 // Track not ready 493 // Track not ready
495 console.log('WAIT -- audioObject '+i+' not ready yet!'); 494 console.log('WAIT -- audioObject '+i+' not ready yet!');
496 ready = false; 495 ready = false;
497 }; 496 };
498 }
499 if (ready == false) {
500 var holder = document.getElementById('testWaitIndicator');
501 holder.style.visibility = "visible";
502 setInterval(function() {
503 document.getElementById('testWaitIndicator').style.visibility = "hidden";
504 }, 10000);
505 } 497 }
506 return ready; 498 return ready;
507 }; 499 };
508 500
509 } 501 }
761 return hold 753 return hold
762 754
763 } 755 }
764 756
765 function testWaitIndicator() { 757 function testWaitIndicator() {
766 var hold = document.createElement("div"); 758 if (audioEngineContext.checkAllReady() == false) {
767 hold.id = "testWaitIndicator"; 759 var hold = document.createElement("div");
768 hold.style.position = "absolute"; 760 hold.id = "testWaitIndicator";
769 hold.style.left = "100px"; 761 hold.className = "indicator-box";
770 hold.style.top = "10px"; 762 var span = document.createElement("span");
771 hold.style.width = "500px"; 763 span.textContent = "Please wait! Elements still loading";
772 hold.style.height = "100px"; 764 hold.appendChild(span);
773 hold.style.padding = "20px"; 765 var body = document.getElementsByTagName('body')[0];
774 hold.style.backgroundColor = "rgb(100,200,200)"; 766 body.appendChild(hold);
775 hold.style.visibility = "hidden"; 767 testWaitTimerIntervalHolder = setInterval(function(){
776 var span = document.createElement("span"); 768 var ready = audioEngineContext.checkAllReady();
777 span.textContent = "Please wait! Elements still loading"; 769 if (ready) {
778 hold.appendChild(span); 770 var elem = document.getElementById('testWaitIndicator');
779 var body = document.getElementsByTagName('body')[0]; 771 var body = document.getElementsByTagName('body')[0];
780 body.appendChild(hold); 772 body.removeChild(elem);
781 } 773 clearInterval(testWaitTimerIntervalHolder);
782 774 }
783 var hidetestwait = null; 775 },500,false);
776 }
777 }
778
779 var testWaitTimerIntervalHolder = null;