nicholas@2: /** nicholas@2: * ape.js nicholas@2: * Create the APE interface nicholas@2: */ nicholas@2: n@38: var currentState; // Keep track of the current state (pre/post test, which test, final test? first test?) n@38: // preTest - In preTest state n@38: // testRun-ID - In test running, test Id number at the end 'testRun-2' n@38: // testRunPost-ID - Post test of test ID n@38: // testRunPre-ID - Pre-test of test ID n@38: // postTest - End of test, final submission! n@38: n@32: nicholas@2: // Once this is loaded and parsed, begin execution nicholas@2: loadInterface(projectXML); nicholas@2: nicholas@2: function loadInterface(xmlDoc) { nicholas@2: n@16: // Get the dimensions of the screen available to the page nicholas@2: var width = window.innerWidth; nicholas@2: var height = window.innerHeight; nicholas@2: nicholas@2: // The injection point into the HTML page nicholas@2: var insertPoint = document.getElementById("topLevelBody"); n@22: var testContent = document.createElement('div'); n@22: testContent.id = 'testContent'; nicholas@2: nicholas@7: nicholas@2: // Decode parts of the xmlDoc that are needed nicholas@2: // xmlDoc MUST already be parsed by jQuery! nicholas@2: var xmlSetup = xmlDoc.find('setup'); nicholas@2: // Should put in an error function here incase of malprocessed or malformed XML nicholas@2: n@34: // Extract the different test XML DOM trees n@50: var audioHolders = xmlDoc.find('audioHolder'); n@50: audioHolders.each(function(index,element) { n@50: var repeatN = element.attributes['repeatCount'].value; n@50: for (var r=0; r<=repeatN; r++) { n@50: testXMLSetups[testXMLSetups.length] = element; n@50: } n@50: }); n@44: n@50: // New check if we need to randomise the test order n@50: var randomise = xmlSetup[0].attributes['randomiseOrder']; n@50: if (randomise != undefined) { nicholas@109: if (randomise.value === 'true'){ nicholas@109: randomise = true; nicholas@109: } else { nicholas@109: randomise = false; nicholas@109: } n@50: } else { n@50: randomise = false; n@50: } nicholas@109: n@50: if (randomise) n@50: { n@54: testXMLSetups = randomiseOrder(testXMLSetups); n@50: } n@44: n@50: // Obtain the metrics enabled n@50: var metricNode = xmlSetup.find('Metric'); n@50: var metricNode = metricNode.find('metricEnable'); n@50: metricNode.each(function(index,node){ n@50: var enabled = node.textContent; n@50: switch(enabled) n@50: { n@50: case 'testTimer': n@50: sessionMetrics.prototype.enableTestTimer = true; n@50: break; n@50: case 'elementTimer': n@50: sessionMetrics.prototype.enableElementTimer = true; n@50: break; n@50: case 'elementTracker': n@50: sessionMetrics.prototype.enableElementTracker = true; n@50: break; n@50: case 'elementInitalPosition': n@50: sessionMetrics.prototype.enableElementInitialPosition = true; n@50: break; n@50: case 'elementFlagListenedTo': n@50: sessionMetrics.prototype.enableFlagListenedTo = true; n@50: break; n@50: case 'elementFlagMoved': n@50: sessionMetrics.prototype.enableFlagMoved = true; n@50: break; n@50: case 'elementFlagComments': n@50: sessionMetrics.prototype.enableFlagComments = true; n@50: break; n@50: } n@50: }); n@34: n@52: // Create APE specific metric functions n@52: audioEngineContext.metric.initialiseTest = function() n@52: { n@52: var sliders = document.getElementsByClassName('track-slider'); n@52: for (var i=0; i= 0) n@52: { n@52: audioEngineContext.audioObjects[this.lastClicked].metric.listening(time); n@52: } n@52: this.lastClicked = id; n@52: audioEngineContext.audioObjects[id].metric.listening(time); n@52: } n@52: }; n@52: nicholas@2: // Create the top div for the Title element nicholas@2: var titleAttr = xmlSetup[0].attributes['title']; nicholas@2: var title = document.createElement('div'); nicholas@2: title.className = "title"; nicholas@2: title.align = "center"; nicholas@2: var titleSpan = document.createElement('span'); nicholas@2: nicholas@2: // Set title to that defined in XML, else set to default nicholas@2: if (titleAttr != undefined) { n@25: titleSpan.innerHTML = titleAttr.value; nicholas@2: } else { b@75: titleSpan.innerHTML = 'Listening test'; nicholas@2: } nicholas@2: // Insert the titleSpan element into the title div element. nicholas@2: title.appendChild(titleSpan); nicholas@2: n@47: var pagetitle = document.createElement('div'); n@47: pagetitle.className = "pageTitle"; n@47: pagetitle.align = "center"; n@47: var titleSpan = document.createElement('span'); n@47: titleSpan.id = "pageTitle"; n@47: pagetitle.appendChild(titleSpan); n@47: nicholas@7: // Store the return URL path in global projectReturn nicholas@7: projectReturn = xmlSetup[0].attributes['projectReturn'].value; nicholas@7: nicholas@7: // Create Interface buttons! nicholas@7: var interfaceButtons = document.createElement('div'); nicholas@7: interfaceButtons.id = 'interface-buttons'; nicholas@7: nicholas@7: // MANUAL DOWNLOAD POINT nicholas@7: // If project return is null, this MUST be specified as the location to create the download link nicholas@7: var downloadPoint = document.createElement('div'); nicholas@7: downloadPoint.id = 'download-point'; nicholas@7: nicholas@7: // Create playback start/stop points nicholas@7: var playback = document.createElement("button"); b@101: playback.innerHTML = 'Stop'; n@49: playback.id = 'playback-button'; n@16: // onclick function. Check if it is playing or not, call the correct function in the n@16: // audioEngine, change the button text to reflect the next state. nicholas@7: playback.onclick = function() { b@101: if (audioEngineContext.status == 1) { b@101: audioEngineContext.stop(); n@25: this.innerHTML = 'Stop'; nicholas@7: } n@16: }; nicholas@7: // Create Submit (save) button nicholas@7: var submit = document.createElement("button"); n@25: submit.innerHTML = 'Submit'; n@43: submit.onclick = buttonSubmitClick; n@49: submit.id = 'submit-button'; n@16: // Append the interface buttons into the interfaceButtons object. nicholas@7: interfaceButtons.appendChild(playback); nicholas@7: interfaceButtons.appendChild(submit); nicholas@7: interfaceButtons.appendChild(downloadPoint); nicholas@7: nicholas@2: // Now create the slider and HTML5 canvas boxes nicholas@2: n@16: // Create the div box to center align nicholas@2: var sliderBox = document.createElement('div'); nicholas@2: sliderBox.className = 'sliderCanvasDiv'; n@16: sliderBox.id = 'sliderCanvasHolder'; nicholas@2: sliderBox.align = 'center'; nicholas@2: n@16: // Create the slider box to hold the slider elements nicholas@5: var canvas = document.createElement('div'); nicholas@2: canvas.id = 'slider'; n@16: // Must have a known EXACT width, as this is used later to determine the ratings nicholas@5: canvas.style.width = width - 100 +"px"; nicholas@5: canvas.align = "left"; nicholas@2: sliderBox.appendChild(canvas); n@16: n@47: // Create the div to hold any scale objects n@47: var scale = document.createElement('div'); n@47: scale.className = 'sliderScale'; n@47: scale.id = 'sliderScaleHolder'; n@47: scale.align = 'left'; n@47: sliderBox.appendChild(scale); n@47: n@16: // Global parent for the comment boxes on the page nicholas@3: var feedbackHolder = document.createElement('div'); n@34: feedbackHolder.id = 'feedbackHolder'; nicholas@2: n@38: testContent.style.zIndex = 1; n@38: insertPoint.innerHTML = null; // Clear the current schema n@38: n@22: // Create pre and post test questions n@38: var blank = document.createElement('div'); n@38: blank.className = 'testHalt'; n@22: n@38: var popupHolder = document.createElement('div'); n@38: popupHolder.id = 'popupHolder'; n@38: popupHolder.className = 'popupHolder'; n@38: popupHolder.style.position = 'absolute'; n@38: popupHolder.style.left = (window.innerWidth/2)-250 + 'px'; n@38: popupHolder.style.top = (window.innerHeight/2)-125 + 'px'; n@38: insertPoint.appendChild(popupHolder); n@38: insertPoint.appendChild(blank); n@38: hidePopup(); n@22: n@36: var preTest = xmlSetup.find('PreTest'); n@36: var postTest = xmlSetup.find('PostTest'); n@22: preTest = preTest[0]; n@22: postTest = postTest[0]; n@38: n@38: currentState = 'preTest'; n@22: n@22: // Create Pre-Test Box nicholas@105: if (preTest != undefined && preTest.childElementCount >= 1) n@22: { n@38: showPopup(); n@39: preTestPopupStart(preTest); n@22: } n@38: n@38: // Inject into HTML n@38: testContent.appendChild(title); // Insert the title n@47: testContent.appendChild(pagetitle); n@38: testContent.appendChild(interfaceButtons); n@38: testContent.appendChild(sliderBox); n@38: testContent.appendChild(feedbackHolder); n@38: insertPoint.appendChild(testContent); n@22: n@36: // Load the full interface n@39: nicholas@2: } nicholas@5: n@39: function loadTest(id) n@34: { nicholas@110: nicholas@110: // Reset audioEngineContext.Metric globals for new test n@113: audioEngineContext.newTestPage(); nicholas@110: n@34: // Used to load a specific test page n@39: var textXML = testXMLSetups[id]; n@34: n@34: var feedbackHolder = document.getElementById('feedbackHolder'); n@34: var canvas = document.getElementById('slider'); n@34: feedbackHolder.innerHTML = null; n@34: canvas.innerHTML = null; n@47: n@47: // Setup question title n@47: var interfaceObj = $(textXML).find('interface'); n@47: var titleNode = interfaceObj.find('title'); n@47: if (titleNode[0] != undefined) n@47: { n@47: document.getElementById('pageTitle').textContent = titleNode[0].textContent; n@47: } n@47: var positionScale = canvas.style.width.substr(0,canvas.style.width.length-2); n@47: var offset = 50-8; // Half the offset of the slider (window width -100) minus the body padding of 8 n@47: // TODO: AUTOMATE ABOVE!! n@47: var scale = document.getElementById('sliderScaleHolder'); n@47: scale.innerHTML = null; n@47: interfaceObj.find('scale').each(function(index,scaleObj){ n@47: var position = Number(scaleObj.attributes['position'].value)*0.01; n@47: var pixelPosition = (position*positionScale)+offset; n@47: var scaleDOM = document.createElement('span'); n@47: scaleDOM.textContent = scaleObj.textContent; n@47: scale.appendChild(scaleDOM); n@47: scaleDOM.style.left = Math.floor((pixelPosition-($(scaleDOM).width()/2)))+'px'; n@47: }); n@34: n@34: // Extract the hostURL attribute. If not set, create an empty string. n@34: var hostURL = textXML.attributes['hostURL']; n@34: if (hostURL == undefined) { n@34: hostURL = ""; n@34: } else { n@34: hostURL = hostURL.value; n@34: } n@34: // Extract the sampleRate. If set, convert the string to a Number. n@34: var hostFs = textXML.attributes['sampleRate']; n@34: if (hostFs != undefined) { n@34: hostFs = Number(hostFs.value); n@34: } n@34: n@34: /// CHECK FOR SAMPLE RATE COMPATIBILITY n@34: if (hostFs != undefined) { n@34: if (Number(hostFs) != audioContext.sampleRate) { n@34: var errStr = 'Sample rates do not match! Requested '+Number(hostFs)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.'; n@34: alert(errStr); n@34: return; n@34: } n@34: } n@45: nicholas@66: var commentShow = textXML.attributes['elementComments']; nicholas@66: if (commentShow != undefined) { nicholas@66: if (commentShow.value == 'false') {commentShow = false;} nicholas@66: else {commentShow = true;} nicholas@66: } else {commentShow = true;} nicholas@66: n@57: var loopPlayback = textXML.attributes['loop']; n@57: if (loopPlayback != undefined) n@57: { n@57: loopPlayback = loopPlayback.value; n@57: if (loopPlayback == 'true') { n@57: loopPlayback = true; n@57: } else { n@57: loopPlayback = false; n@57: } n@57: } else { n@57: loopPlayback = false; n@57: } n@57: audioEngineContext.loopPlayback = loopPlayback; nicholas@110: loopPlayback = false; n@57: // Create AudioEngine bindings for playback n@57: if (loopPlayback) { n@57: audioEngineContext.selectedTrack = function(id) { n@57: for (var i=0; i'; n@34: trackSliderObj.draggable = true; n@34: trackSliderObj.ondragend = dragEnd; n@49: trackSliderObj.ondragstart = function() n@49: { n@49: var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! n@49: audioEngineContext.metric.sliderMoveStart(id); n@49: }; n@34: n@34: // Onclick, switch playback to that track n@34: trackSliderObj.onclick = function() { nicholas@108: // Start the test on first click, that way timings are more accurate. nicholas@108: audioEngineContext.play(); n@34: // Get the track ID from the object ID n@34: var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! nicholas@110: //audioEngineContext.metric.sliderPlayed(id); n@34: audioEngineContext.selectedTrack(id); b@100: // Currently playing track red, rest green b@100: document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; b@100: for (var i = 0; i<$(currentTrackOrder).length; i++) b@100: { b@102: if (i!=index) // Make all other sliders green b@100: { b@100: document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; b@100: } b@100: b@100: } n@34: }; n@34: n@34: canvas.appendChild(trackSliderObj); b@102: n@34: }); n@39: nicholas@65: // Append any commentQuestion boxes nicholas@65: var commentQuestions = $(textXML).find('CommentQuestion'); nicholas@65: $(commentQuestions).each(function(index,element) { nicholas@65: // Create document objects to hold the comment boxes nicholas@65: var trackComment = document.createElement('div'); nicholas@65: trackComment.className = 'comment-div commentQuestion'; nicholas@65: trackComment.id = element.attributes['id'].value; nicholas@65: // Create a string next to each comment asking for a comment nicholas@65: var trackString = document.createElement('span'); nicholas@65: trackString.innerHTML = element.textContent; nicholas@65: // Create the HTML5 comment box 'textarea' nicholas@65: var trackCommentBox = document.createElement('textarea'); nicholas@65: trackCommentBox.rows = '4'; nicholas@65: trackCommentBox.cols = '100'; nicholas@65: trackCommentBox.name = 'commentQuestion'+index; nicholas@65: trackCommentBox.className = 'trackComment'; nicholas@65: var br = document.createElement('br'); nicholas@65: // Add to the holder. nicholas@65: trackComment.appendChild(trackString); nicholas@65: trackComment.appendChild(br); nicholas@65: trackComment.appendChild(trackCommentBox); nicholas@65: feedbackHolder.appendChild(trackComment); nicholas@65: }); nicholas@65: n@39: // Now process any pre-test commands n@39: n@44: var preTest = $(testXMLSetups[id]).find('PreTest')[0]; nicholas@105: if (preTest.childElementCount > 0) n@39: { n@39: currentState = 'testRunPre-'+id; n@39: preTestPopupStart(preTest); n@39: showPopup(); n@39: } else { n@39: currentState = 'testRun-'+id; n@39: } n@39: } n@39: n@39: function preTestPopupStart(preTest) n@39: { n@39: var popupHolder = document.getElementById('popupHolder'); n@39: popupHolder.innerHTML = null; n@39: // Parse the first box n@39: var preTestOption = document.createElement('div'); n@39: preTestOption.id = 'preTest'; n@39: preTestOption.style.marginTop = '25px'; n@39: preTestOption.align = "center"; nicholas@105: var child = $(preTest).children()[0]; n@39: if (child.nodeName == 'statement') n@39: { nicholas@105: preTestOption.innerHTML = ''+child.textContent+''; n@39: } else if (child.nodeName == 'question') n@39: { n@39: var textHold = document.createElement('span'); nicholas@105: textHold.innerHTML = child.textContent; n@39: var textEnter = document.createElement('textarea'); n@112: textEnter.id = child.attributes['id'].value + 'response'; n@112: var br = document.createElement('br'); n@112: preTestOption.innerHTML = null; n@39: preTestOption.appendChild(textHold); n@112: preTestOption.appendChild(br); n@39: preTestOption.appendChild(textEnter); n@39: } n@39: var nextButton = document.createElement('button'); n@39: nextButton.className = 'popupButton'; n@39: nextButton.value = '0'; n@39: nextButton.innerHTML = 'Next'; n@39: nextButton.onclick = popupButtonClick; n@39: n@39: popupHolder.appendChild(preTestOption); n@39: popupHolder.appendChild(nextButton); n@34: } n@34: n@38: function popupButtonClick() n@38: { n@38: // Global call from the 'Next' button click n@38: if (currentState == 'preTest') n@38: { n@38: // At the start of the preTest routine! n@39: var xmlTree = projectXML.find('setup'); n@39: var preTest = xmlTree.find('PreTest')[0]; n@39: this.value = preTestButtonClick(preTest,this.value); n@39: } else if (currentState.substr(0,10) == 'testRunPre') n@39: { n@39: //Specific test pre-test n@39: var testId = currentState.substr(11,currentState.length-10); n@44: var preTest = $(testXMLSetups[testId]).find('PreTest')[0]; n@39: this.value = preTestButtonClick(preTest,this.value); n@42: } else if (currentState.substr(0,11) == 'testRunPost') n@42: { n@42: // Specific test post-test n@42: var testId = currentState.substr(12,currentState.length-11); n@44: var preTest = $(testXMLSetups[testId]).find('PostTest')[0]; n@42: this.value = preTestButtonClick(preTest,this.value); n@41: } else if (currentState == 'postTest') n@41: { n@41: // At the end of the test, running global post test n@41: var xmlTree = projectXML.find('setup'); n@41: var PostTest = xmlTree.find('PostTest')[0]; n@41: this.value = preTestButtonClick(PostTest,this.value); n@38: } n@38: } n@38: n@39: function preTestButtonClick(preTest,index) n@34: { n@34: // Called on click of pre-test button n@36: // Need to find and parse preTest again! n@36: var preTestOption = document.getElementById('preTest'); n@36: // Check if current state is a question! nicholas@105: if ($(preTest).children()[index].nodeName == 'question') { nicholas@105: var questionId = $(preTest).children()[index].attributes['id'].value; n@36: var questionHold = document.createElement('comment'); n@36: var questionResponse = document.getElementById(questionId + 'response'); nicholas@105: var mandatory = $(preTest).children()[index].attributes['mandatory']; nicholas@64: if (mandatory != undefined){ nicholas@64: if (mandatory.value == 'true') {mandatory = true;} nicholas@64: else {mandatory = false;} nicholas@64: } else {mandatory = false;} nicholas@64: if (mandatory == true && questionResponse.value.length == 0) { nicholas@64: return index; nicholas@64: } n@36: questionHold.id = questionId; n@36: questionHold.innerHTML = questionResponse.value; n@46: postPopupResponse(questionHold); n@36: } n@38: index++; nicholas@105: if (index < preTest.childElementCount) n@36: { n@36: // More to process nicholas@105: var child = $(preTest).children()[index]; n@36: if (child.nodeName == 'statement') n@36: { nicholas@105: preTestOption.innerHTML = ''+child.textContent+''; n@36: } else if (child.nodeName == 'question') n@36: { n@36: var textHold = document.createElement('span'); nicholas@105: textHold.innerHTML = child.textContent; n@36: var textEnter = document.createElement('textarea'); n@36: textEnter.id = child.attributes['id'].value + 'response'; n@36: var br = document.createElement('br'); n@36: preTestOption.innerHTML = null; n@36: preTestOption.appendChild(textHold); n@36: preTestOption.appendChild(br); n@36: preTestOption.appendChild(textEnter); n@36: } n@36: } else { n@36: // Time to clear n@37: preTestOption.innerHTML = null; n@43: if (currentState != 'postTest') { n@43: hidePopup(); n@43: // Progress the state! n@43: advanceState(); n@43: } else { n@43: a = createProjectSave(projectReturn); n@43: preTestOption.appendChild(a); n@43: } n@36: } n@38: return index; n@36: } n@36: n@46: function postPopupResponse(response) n@46: { n@46: if (currentState == 'preTest') { n@46: preTestQuestions.appendChild(response); n@46: } else if (currentState == 'postTest') { n@46: postTestQuestions.appendChild(response); n@46: } else { n@46: // Inside a specific test n@46: if (currentState.substr(0,10) == 'testRunPre') { n@46: // Pre Test n@46: var store = $(currentTestHolder).find('preTest'); n@46: } else { n@46: // Post Test n@46: var store = $(currentTestHolder).find('postTest'); n@46: } n@46: store[0].appendChild(response); n@46: } n@46: } n@46: n@36: function showPopup() n@36: { n@37: var popupHolder = document.getElementById('popupHolder'); n@38: popupHolder.style.zIndex = 3; n@37: popupHolder.style.visibility = 'visible'; n@37: var blank = document.getElementsByClassName('testHalt')[0]; n@37: blank.style.zIndex = 2; n@37: blank.style.visibility = 'visible'; n@36: } n@36: n@36: function hidePopup() n@36: { n@37: var popupHolder = document.getElementById('popupHolder'); n@37: popupHolder.style.zIndex = -1; n@37: popupHolder.style.visibility = 'hidden'; n@37: var blank = document.getElementsByClassName('testHalt')[0]; n@37: blank.style.zIndex = -2; n@37: blank.style.visibility = 'hidden'; n@34: } n@34: nicholas@5: function dragEnd(ev) { nicholas@5: // Function call when a div has been dropped n@33: var slider = document.getElementById('slider'); n@51: var w = slider.style.width; n@51: w = Number(w.substr(0,w.length-2)); n@51: var x = ev.x; n@51: if (x >= 42 && x < w+42) { n@51: this.style.left = (x)+'px'; nicholas@5: } else { n@51: if (x<42) { n@51: this.style.left = '42px'; nicholas@5: } else { n@51: this.style.left = (w+42) + 'px'; nicholas@5: } nicholas@5: } n@49: audioEngineContext.metric.sliderMoved(); nicholas@5: } nicholas@7: n@39: function advanceState() n@39: { n@39: console.log(currentState); n@39: if (currentState == 'preTest') n@39: { n@39: // End of pre-test, begin the test n@39: loadTest(0); n@39: } else if (currentState.substr(0,10) == 'testRunPre') n@39: { n@39: // Start the test n@39: var testId = currentState.substr(11,currentState.length-10); n@39: currentState = 'testRun-'+testId; nicholas@107: //audioEngineContext.timer.startTest(); nicholas@108: //audioEngineContext.play(); n@42: } else if (currentState.substr(0,11) == 'testRunPost') n@42: { n@44: var testId = currentState.substr(12,currentState.length-11); n@42: testEnded(testId); n@40: } else if (currentState.substr(0,7) == 'testRun') n@40: { n@40: var testId = currentState.substr(8,currentState.length-7); n@40: // Check if we have any post tests to perform n@44: var postXML = $(testXMLSetups[testId]).find('PostTest')[0]; n@113: if (postXML == undefined || postXML.childElementCount == 0) { nicholas@69: testEnded(testId); nicholas@69: } nicholas@105: else if (postXML.childElementCount > 0) n@40: { n@42: currentState = 'testRunPost-'+testId; n@42: showPopup(); n@42: preTestPopupStart(postXML); n@40: } n@42: else { n@40: n@40: n@42: // No post tests, check if we have another test to perform instead nicholas@69: n@40: } n@39: } n@39: console.log(currentState); n@39: } n@39: n@42: function testEnded(testId) n@42: { n@45: pageXMLSave(testId); n@42: if (testXMLSetups.length-1 > testId) n@42: { n@42: // Yes we have another test to perform n@44: testId = (Number(testId)+1); n@44: currentState = 'testRun-'+testId; n@44: loadTest(testId); n@42: } else { n@42: console.log('Testing Completed!'); n@42: currentState = 'postTest'; n@42: // Check for any post tests n@42: var xmlSetup = projectXML.find('setup'); n@42: var postTest = xmlSetup.find('PostTest')[0]; n@42: showPopup(); n@42: preTestPopupStart(postTest); n@42: } n@42: } n@42: b@101: function buttonSubmitClick() // TODO: Only when all songs have been played! n@40: { nicholas@107: hasBeenPlayed = audioEngineContext.checkAllPlayed(); nicholas@107: if (hasBeenPlayed.length == 0) { nicholas@107: if (audioEngineContext.status == 1) { nicholas@107: var playback = document.getElementById('playback-button'); nicholas@107: playback.click(); nicholas@107: // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options nicholas@107: } else nicholas@107: { nicholas@107: if (audioEngineContext.timer.testStarted == false) nicholas@107: { nicholas@107: alert('You have not started the test! Please press start to begin the test!'); nicholas@107: return; nicholas@107: } nicholas@107: } nicholas@107: if (currentState.substr(0,7) == 'testRun') nicholas@107: { nicholas@107: hasBeenPlayed = []; // clear array to prepare for next test nicholas@107: audioEngineContext.timer.stopTest(); nicholas@107: advanceState(); nicholas@107: } b@102: } else // if a fragment has not been played yet b@102: { nicholas@107: str = ""; nicholas@107: if (hasBeenPlayed.length > 1) { nicholas@107: for (var i=0; i