Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1750:1365362c12d5
Merge from 156:402bb0f56dc4
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Mon, 01 Jun 2015 12:56:15 +0100 |
parents | b3c0d605f7c9 |
children | 4df1b4e7596f |
comparison
equal
deleted
inserted
replaced
1601:1c7cd4613a96 | 1750:1365362c12d5 |
---|---|
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() { |
110 var textArea = document.createElement('textarea'); | 106 var textArea = document.createElement('textarea'); |
111 var br = document.createElement('br'); | 107 var br = document.createElement('br'); |
112 this.popupContent.appendChild(span); | 108 this.popupContent.appendChild(span); |
113 this.popupContent.appendChild(br); | 109 this.popupContent.appendChild(br); |
114 this.popupContent.appendChild(textArea); | 110 this.popupContent.appendChild(textArea); |
111 this.popupContent.childNodes[2].focus(); | |
115 } | 112 } |
116 this.popupContent.appendChild(this.popupButton); | 113 this.popupContent.appendChild(this.popupButton); |
117 } | 114 }; |
118 | 115 |
119 this.initState = function(node) { | 116 this.initState = function(node) { |
120 //Call this with your preTest and postTest nodes when needed to | 117 //Call this with your preTest and postTest nodes when needed to |
121 // initialise the popup procedure. | 118 // initialise the popup procedure. |
122 this.popupOptions = $(node).children(); | 119 this.popupOptions = $(node).children(); |
131 } | 128 } |
132 this.currentIndex = 0; | 129 this.currentIndex = 0; |
133 this.showPopup(); | 130 this.showPopup(); |
134 this.postNode(); | 131 this.postNode(); |
135 } | 132 } |
136 } | 133 }; |
137 | 134 |
138 this.buttonClicked = function() { | 135 this.buttonClicked = function() { |
139 // Each time the popup button is clicked! | 136 // Each time the popup button is clicked! |
140 var node = this.popupOptions[this.currentIndex]; | 137 var node = this.popupOptions[this.currentIndex]; |
141 if (node.nodeName == 'question') { | 138 if (node.nodeName == 'question') { |
172 } else { | 169 } else { |
173 testState.stateResults[testState.stateIndex].appendChild(this.responses); | 170 testState.stateResults[testState.stateIndex].appendChild(this.responses); |
174 } | 171 } |
175 advanceState(); | 172 advanceState(); |
176 } | 173 } |
177 } | 174 }; |
178 } | 175 } |
179 | 176 |
180 function advanceState() | 177 function advanceState() |
181 { | 178 { |
182 // Just for complete clarity | 179 // Just for complete clarity |
380 xmlhttp.onerror = function(){ | 377 xmlhttp.onerror = function(){ |
381 console.log('Error saving file to server! Presenting download locally'); | 378 console.log('Error saving file to server! Presenting download locally'); |
382 createProjectSave(null); | 379 createProjectSave(null); |
383 }; | 380 }; |
384 xmlhttp.send(file); | 381 xmlhttp.send(file); |
382 if (xmlhttp.status == 404) { | |
383 createProjectSave(null); | |
384 } | |
385 } | 385 } |
386 return submitDiv; | 386 return submitDiv; |
387 } | 387 } |
388 | 388 |
389 // Only other global function which must be defined in the interface class. Determines how to create the XML document. | 389 // 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) { | 493 if (this.audioObjects[i].state == 0) { |
494 // Track not ready | 494 // Track not ready |
495 console.log('WAIT -- audioObject '+i+' not ready yet!'); | 495 console.log('WAIT -- audioObject '+i+' not ready yet!'); |
496 ready = false; | 496 ready = false; |
497 }; | 497 }; |
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 } | 498 } |
506 return ready; | 499 return ready; |
507 }; | 500 }; |
508 | 501 |
509 } | 502 } |
761 return hold | 754 return hold |
762 | 755 |
763 } | 756 } |
764 | 757 |
765 function testWaitIndicator() { | 758 function testWaitIndicator() { |
766 var hold = document.createElement("div"); | 759 if (audioEngineContext.checkAllReady() == false) { |
767 hold.id = "testWaitIndicator"; | 760 var hold = document.createElement("div"); |
768 hold.style.position = "absolute"; | 761 hold.id = "testWaitIndicator"; |
769 hold.style.left = "100px"; | 762 hold.className = "indicator-box"; |
770 hold.style.top = "10px"; | 763 var span = document.createElement("span"); |
771 hold.style.width = "500px"; | 764 span.textContent = "Please wait! Elements still loading"; |
772 hold.style.height = "100px"; | 765 hold.appendChild(span); |
773 hold.style.padding = "20px"; | 766 var body = document.getElementsByTagName('body')[0]; |
774 hold.style.backgroundColor = "rgb(100,200,200)"; | 767 body.appendChild(hold); |
775 hold.style.visibility = "hidden"; | 768 testWaitTimerIntervalHolder = setInterval(function(){ |
776 var span = document.createElement("span"); | 769 var ready = audioEngineContext.checkAllReady(); |
777 span.textContent = "Please wait! Elements still loading"; | 770 if (ready) { |
778 hold.appendChild(span); | 771 var elem = document.getElementById('testWaitIndicator'); |
779 var body = document.getElementsByTagName('body')[0]; | 772 var body = document.getElementsByTagName('body')[0]; |
780 body.appendChild(hold); | 773 body.removeChild(elem); |
781 } | 774 clearInterval(testWaitTimerIntervalHolder); |
782 | 775 } |
783 var hidetestwait = null; | 776 },500,false); |
777 } | |
778 } | |
779 | |
780 var testWaitTimerIntervalHolder = null; |