nickjillings@1343: // Once this is loaded and parsed, begin execution nicholas@2700: /*globals interfaceContext, window, document, specification, audioEngineContext, console, testState, $, storage */ nickjillings@1343: loadInterface(); nickjillings@1343: nickjillings@1343: function loadInterface() { nicholas@2538: // Use this to do any one-time page / element construction. For instance, placing any stationary text objects, nicholas@2538: // holding div's, or setting up any nodes which are present for the entire test sequence nicholas@2538: nicholas@2538: // The injection point into the HTML page nicholas@2538: interfaceContext.insertPoint = document.getElementById("topLevelBody"); nicholas@2538: var testContent = document.createElement('div'); nicholas@2538: testContent.id = 'testContent'; nicholas@2538: nicholas@2538: // Create the top div for the Title element nicholas@2538: var titleAttr = specification.title; nicholas@2538: var title = document.createElement('div'); nicholas@2538: title.className = "title"; nicholas@2538: title.align = "center"; nicholas@2538: var titleSpan = document.createElement('span'); nicholas@2538: titleSpan.id = "test-title"; nicholas@2538: nicholas@2538: // Set title to that defined in XML, else set to default nicholas@2700: if (titleAttr !== undefined) { nicholas@2538: titleSpan.textContent = titleAttr; nicholas@2538: } else { nicholas@2538: titleSpan.textContent = 'Listening test'; nicholas@2538: } nicholas@2538: // Insert the titleSpan element into the title div element. nicholas@2538: title.appendChild(titleSpan); nicholas@2538: nicholas@2538: var pagetitle = document.createElement('div'); nicholas@2538: pagetitle.className = "pageTitle"; nicholas@2538: pagetitle.align = "center"; nicholas@2700: nicholas@2700: titleSpan = document.createElement('span'); nicholas@2538: titleSpan.id = "pageTitle"; nicholas@2538: pagetitle.appendChild(titleSpan); nicholas@2538: nicholas@2538: // Create Interface buttons! nicholas@2538: var interfaceButtons = document.createElement('div'); nicholas@2538: interfaceButtons.id = 'interface-buttons'; nicholas@2538: interfaceButtons.style.height = '25px'; nicholas@2538: nicholas@2538: // Create playback start/stop points nicholas@2538: var playback = document.createElement("button"); nicholas@2538: playback.innerHTML = 'Stop'; nicholas@2538: playback.id = 'playback-button'; nicholas@2538: playback.style.float = 'left'; nicholas@2538: // onclick function. Check if it is playing or not, call the correct function in the nicholas@2538: // audioEngine, change the button text to reflect the next state. nicholas@2538: playback.onclick = function () { nicholas@2538: if (audioEngineContext.status == 1) { nicholas@2538: audioEngineContext.stop(); nicholas@2538: this.innerHTML = 'Stop'; nickjillings@1343: var time = audioEngineContext.timer.getTestTime(); nickjillings@1343: console.log('Stopped at ' + time); // DEBUG/SAFETY nicholas@2538: } nicholas@2538: }; nicholas@2538: // Create Submit (save) button nicholas@2538: var submit = document.createElement("button"); nicholas@2538: submit.innerHTML = 'Next'; nicholas@2538: submit.onclick = buttonSubmitClick; nicholas@2538: submit.id = 'submit-button'; nicholas@2538: submit.style.float = 'left'; n@3008: n@3008: // Create the sort button n@3008: var sort = document.createElement("button"); n@3008: sort.id = "sort-fragments"; n@3008: sort.textContent = "Sort"; n@3008: sort.style.display = "inline-block"; n@3008: sort.style.visibility = "hidden"; n@3008: sort.onclick = buttonSortFragmentClick; n@3008: nicholas@2538: // Append the interface buttons into the interfaceButtons object. nicholas@2538: interfaceButtons.appendChild(playback); nicholas@2538: interfaceButtons.appendChild(submit); n@3008: interfaceButtons.appendChild(sort); n@3008: nicholas@2538: nicholas@2396: // Create outside reference holder nicholas@2396: var outsideRef = document.createElement("div"); nicholas@2396: outsideRef.id = "outside-reference-holder"; nicholas@2538: nicholas@2538: // Create a slider box nicholas@2538: var sliderBox = document.createElement('div'); nicholas@2538: sliderBox.style.width = "100%"; nicholas@2538: sliderBox.style.height = window.innerHeight - 200 + 12 + 'px'; nicholas@2538: sliderBox.style.marginBottom = '10px'; nicholas@2538: sliderBox.id = 'slider'; nicholas@2538: var scaleHolder = document.createElement('div'); nicholas@2538: scaleHolder.id = "scale-holder"; nicholas@2538: scaleHolder.style.marginLeft = "107px"; nicholas@2538: sliderBox.appendChild(scaleHolder); nicholas@2538: var scaleText = document.createElement('div'); nicholas@2538: scaleText.id = "scale-text-holder"; nicholas@2538: scaleText.style.height = "25px"; nicholas@2538: scaleText.style.width = "100%"; nicholas@2538: scaleHolder.appendChild(scaleText); nicholas@2538: var scaleCanvas = document.createElement('canvas'); nicholas@2538: scaleCanvas.id = "scale-canvas"; nicholas@2538: scaleCanvas.style.marginLeft = "100px"; nicholas@2538: scaleHolder.appendChild(scaleCanvas); nicholas@2538: var sliderObjectHolder = document.createElement('div'); nicholas@2538: sliderObjectHolder.id = 'slider-holder'; nicholas@2538: sliderObjectHolder.align = "center"; nicholas@2538: sliderBox.appendChild(sliderObjectHolder); nicholas@2538: nicholas@2538: // Global parent for the comment boxes on the page nicholas@2538: var feedbackHolder = document.createElement('div'); nicholas@2538: feedbackHolder.id = 'feedbackHolder'; nicholas@2538: nicholas@2538: testContent.style.zIndex = 1; nicholas@2538: interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema nicholas@2538: nicholas@2538: // Inject into HTML nicholas@2538: testContent.appendChild(title); // Insert the title nicholas@2538: testContent.appendChild(pagetitle); nicholas@2538: testContent.appendChild(interfaceButtons); nicholas@2396: testContent.appendChild(outsideRef); nicholas@2538: testContent.appendChild(sliderBox); nicholas@2538: testContent.appendChild(feedbackHolder); nicholas@2538: interfaceContext.insertPoint.appendChild(testContent); nickjillings@1343: nicholas@2538: // Load the full interface nicholas@2538: testState.initialise(); nicholas@2538: testState.advanceState(); nicholas@2700: } nickjillings@1343: nicholas@2538: function loadTest(page) { nicholas@2538: // Called each time a new test page is to be build. The page specification node is the only item passed in nicholas@2538: var id = page.id; nicholas@2538: nicholas@2538: var feedbackHolder = document.getElementById('feedbackHolder'); nicholas@2381: feedbackHolder.innerHTML = ""; nicholas@2538: nicholas@2651: var interfaceObj = interfaceContext.getCombinedInterfaces(page); nicholas@2538: if (interfaceObj.length > 1) { nicholas@2538: console.log("WARNING - This interface only supports one node per page. Using first interface node"); nicholas@2538: } nicholas@2538: interfaceObj = interfaceObj[0]; nicholas@2538: nicholas@2470: // Set the page title nicholas@2470: if (typeof page.title == "string" && page.title.length > 0) { nicholas@2700: document.getElementById("test-title").textContent = page.title; nicholas@2470: } nicholas@2538: nicholas@2700: if (interfaceObj.title !== null) { nicholas@2538: document.getElementById("pageTitle").textContent = interfaceObj.title; nicholas@2538: } nicholas@2538: nicholas@2801: if (interfaceObj.image !== undefined || page.audioElements.some(function (elem) { n@2793: return elem.image !== undefined; n@2793: })) { nicholas@2781: document.getElementById("testContent").insertBefore(interfaceContext.imageHolder.root, document.getElementById("slider")); nicholas@2781: interfaceContext.imageHolder.setImage(interfaceObj.image); nicholas@2781: } nicholas@2781: nicholas@2538: // Delete outside reference nicholas@2538: document.getElementById("outside-reference-holder").innerHTML = ""; nicholas@2538: nicholas@2538: var sliderBox = document.getElementById('slider-holder'); nicholas@2538: sliderBox.innerHTML = ""; nicholas@2538: nicholas@2538: var commentBoxPrefix = "Comment on track"; nicholas@2700: if (interfaceObj.commentBoxPrefix !== undefined) { nicholas@2538: commentBoxPrefix = interfaceObj.commentBoxPrefix; nicholas@2538: } nicholas@2538: var loopPlayback = page.loop; nicholas@2538: nicholas@2538: $(page.commentQuestions).each(function (index, element) { nicholas@2538: var node = interfaceContext.createCommentQuestion(element); nicholas@2538: feedbackHolder.appendChild(node.holder); nicholas@2538: }); nicholas@2538: nicholas@2538: // Find all the audioElements from the audioHolder nicholas@2538: var index = 0; nicholas@2607: var labelType = page.label; nicholas@2607: if (labelType == "default") { nicholas@2607: labelType = "number"; nicholas@2607: } nicholas@2607: $(page.audioElements).each(function (pageIndex, element) { nicholas@2538: // Find URL of track nicholas@2538: // In this jQuery loop, variable 'this' holds the current audioElement. nicholas@2538: nicholas@2538: var audioObject = audioEngineContext.newTrack(element); nicholas@2538: if (element.type == 'outside-reference') { nicholas@2538: // Construct outside reference; nicholas@2538: var orNode = new interfaceContext.outsideReferenceDOM(audioObject, index, document.getElementById("outside-reference-holder")); nicholas@2538: audioObject.bindInterface(orNode); nicholas@2538: } else { nicholas@2538: // Create a slider per track nicholas@2607: var label = interfaceContext.getLabel(labelType, index, page.labelStart); nicholas@2538: var sliderObj = new sliderObject(audioObject, label); nicholas@2538: nicholas@2538: if (typeof page.initialPosition === "number") { nicholas@2538: // Set the values nicholas@2538: sliderObj.slider.value = page.initalPosition; nicholas@2538: } else { nicholas@2538: // Distribute it randomnly nicholas@2538: sliderObj.slider.value = Math.random(); nicholas@2538: } nicholas@2538: sliderBox.appendChild(sliderObj.holder); nicholas@2538: audioObject.bindInterface(sliderObj); nickjillings@2117: interfaceContext.commentBoxes.createCommentBox(audioObject); nicholas@2538: index += 1; nicholas@2538: } nicholas@2538: nicholas@2538: }); nicholas@2700: interfaceObj.options.forEach(function (option) { nicholas@2538: if (option.type == "show") { nicholas@2538: switch (option.name) { n@2407: case "playhead": n@2407: var playbackHolder = document.getElementById('playback-holder'); nicholas@2700: if (playbackHolder === null) { n@2407: playbackHolder = document.createElement('div'); n@2407: playbackHolder.style.width = "100%"; n@2407: playbackHolder.align = 'center'; n@2407: playbackHolder.appendChild(interfaceContext.playhead.object); n@2407: feedbackHolder.appendChild(playbackHolder); n@2407: } n@2407: break; n@2407: case "page-count": n@2407: var pagecountHolder = document.getElementById('page-count'); nicholas@2700: if (pagecountHolder === null) { n@2407: pagecountHolder = document.createElement('div'); n@2407: pagecountHolder.id = 'page-count'; n@2407: } nicholas@2538: pagecountHolder.innerHTML = 'Page ' + (testState.stateIndex + 1) + ' of ' + testState.stateMap.length + ''; n@2407: var inject = document.getElementById('interface-buttons'); n@2407: inject.appendChild(pagecountHolder); n@2407: break; n@2407: case "volume": nicholas@2700: if (document.getElementById('master-volume-holder') === null) { n@2407: feedbackHolder.appendChild(interfaceContext.volume.object); n@2407: } n@2407: break; n@2407: case "comments": nicholas@2538: interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true); n@2407: break; n@3008: case "fragmentSort": n@3008: var button = document.getElementById('sort-fragments'); n@3008: button.style.visibility = "visible"; n@3008: break; n@2407: } n@2407: } nicholas@2700: }); nicholas@2538: // Auto-align nicholas@2538: resizeWindow(null); nickjillings@1343: } nickjillings@1343: nicholas@2538: function sliderObject(audioObject, label) { nicholas@2538: // An example node, you can make this however you want for each audioElement. nicholas@2538: // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following nicholas@2538: // You attach them by calling audioObject.bindInterface( ) nicholas@2839: var playing = false; nicholas@2538: this.parent = audioObject; nicholas@2538: nicholas@2538: this.holder = document.createElement('div'); nicholas@2538: this.title = document.createElement('div'); nicholas@3132: this.titleH4 = document.createElement('h4'); nicholas@2538: this.slider = document.createElement('input'); nicholas@2538: this.play = document.createElement('button'); nicholas@2538: nicholas@2538: this.holder.className = 'track-slider'; nicholas@2538: this.holder.style.width = window.innerWidth - 200 + 'px'; nicholas@3132: this.title.appendChild(this.titleH4); nicholas@2538: this.holder.appendChild(this.title); nicholas@2538: this.holder.appendChild(this.slider); nicholas@2538: this.holder.appendChild(this.play); nicholas@2538: this.holder.setAttribute('trackIndex', audioObject.id); nicholas@3132: this.titleH4.textContent = label; nicholas@2538: this.title.className = 'track-slider-title'; nicholas@2538: nicholas@2538: this.slider.type = "range"; nicholas@2538: this.slider.className = "track-slider-range track-slider-not-moved"; nicholas@2538: this.slider.min = "0"; nicholas@2538: this.slider.max = "1"; nicholas@2538: this.slider.step = "0.01"; nicholas@2538: this.slider.onchange = function () { nicholas@2538: var time = audioEngineContext.timer.getTestTime(); nicholas@2538: var id = Number(this.parentNode.getAttribute('trackIndex')); nicholas@2538: audioEngineContext.audioObjects[id].metric.moved(time, this.value); nicholas@2538: console.log('slider ' + id + ' moved to ' + this.value + ' (' + time + ')'); nicholas@2538: $(this).removeClass('track-slider-not-moved'); nicholas@2538: }; nicholas@2538: nicholas@2538: this.play.className = 'track-slider-button'; nicholas@2538: this.play.textContent = "Loading..."; nicholas@2538: this.play.value = audioObject.id; nicholas@2538: this.play.disabled = true; nicholas@2538: this.play.setAttribute("playstate", "ready"); nicholas@2538: this.play.onclick = function (event) { nicholas@2538: var id = Number(event.currentTarget.value); nicholas@2538: //audioEngineContext.metric.sliderPlayed(id); nicholas@2839: if (!playing) { nicholas@2538: audioEngineContext.play(id); nicholas@2839: } else if (playing) { nicholas@2538: audioEngineContext.stop(); nicholas@2538: } nicholas@2538: }; nicholas@2538: this.resize = function (event) { nicholas@2538: this.holder.style.width = window.innerWidth - 200 + 'px'; nicholas@2538: }; nicholas@2538: this.enable = function () { nicholas@2538: // This is used to tell the interface object that playback of this node is ready nicholas@2538: this.play.disabled = false; nicholas@2538: this.play.textContent = "Play"; nicholas@2538: $(this.slider).removeClass('track-slider-disabled'); nicholas@2538: }; nicholas@2538: this.updateLoading = function (progress) { nicholas@2538: // progress is a value from 0 to 100 indicating the current download state of media files nicholas@2538: }; nicholas@2538: this.startPlayback = function () { nickjillings@1360: // Called when playback has begun nicholas@2839: playing = true; nicholas@2839: this.play.textContent = "Stop"; nickjillings@1360: $(".track-slider").removeClass('track-slider-playing'); nicholas@2538: $(this.holder).addClass('track-slider-playing'); nicholas@2538: var outsideReference = document.getElementById('outside-reference'); nicholas@2700: if (outsideReference !== null) { nicholas@2538: $(outsideReference).removeClass('track-slider-playing'); nicholas@2538: } nicholas@2725: interfaceContext.commentBoxes.highlightById(audioObject.id); n@2793: if (audioObject.specification.image !== undefined) { n@2793: interfaceContext.imageHolder.setImage(audioObject.specification.image); n@2793: } nickjillings@1360: }; nicholas@2538: this.stopPlayback = function () { nickjillings@1360: // Called when playback has stopped. This gets called even if playback never started! nicholas@2839: playing = false; nicholas@2839: this.play.textContent = "Play"; nickjillings@1360: $(this.holder).removeClass('track-slider-playing'); nicholas@2725: var box = interfaceContext.commentBoxes.boxes.find(function (a) { nicholas@2725: return a.id === audioObject.id; nicholas@2725: }); nicholas@2725: if (box) { nicholas@2725: box.highlight(false); nicholas@2725: } n@2793: if (audioObject.specification.parent.interfaces[0].image !== undefined) { n@2793: interfaceContext.imageHolder.setImage(audioObject.specification.parent.interfaces[0].image); n@2793: } else { n@2793: interfaceContext.imageHolder.setImage(""); n@2793: } nickjillings@1360: }; nicholas@2538: this.getValue = function () { nicholas@2538: // Return the current value of the object. If there is no value, return 0 nicholas@2538: return this.slider.value; nicholas@2538: }; nicholas@2538: this.getPresentedId = function () { nicholas@2538: // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale nicholas@2538: return this.title.textContent; nicholas@2538: }; nicholas@2538: this.canMove = function () { nicholas@2538: // Return either true or false if the interface object can be moved. AB / Reference cannot, whilst sliders can and therefore have a continuous scale. nicholas@2538: // These are checked primarily if the interface check option 'fragmentMoved' is enabled. nicholas@2538: return true; nicholas@2538: }; nicholas@2538: this.exportXMLDOM = function (audioObject) { nicholas@2538: // Called by the audioObject holding this element to export the interface node. nicholas@2538: // If there is no value node (such as outside reference), return null nicholas@2538: // If there are multiple value nodes (such as multiple scale / 2D scales), return an array of nodes with each value node having an 'interfaceName' attribute nicholas@2538: // Use storage.document.createElement('value'); to generate the XML node. nicholas@2538: var node = storage.document.createElement('value'); nickjillings@1347: node.textContent = this.slider.value; nickjillings@1347: return node; nicholas@2538: }; nicholas@2538: this.error = function () { nicholas@2538: // audioObject has an error!! nickjillings@2113: this.playback.textContent = "Error"; nickjillings@2113: $(this.playback).addClass("error-colour"); nicholas@2700: }; nicholas@2700: } nickjillings@1343: nicholas@2538: function resizeWindow(event) { nicholas@2538: // Called on every window resize event, use this to scale your page properly nicholas@2538: nicholas@2538: var numObj = document.getElementsByClassName('track-slider').length; nicholas@2538: var totalHeight = (numObj * 125) - 25; nicholas@2538: // Cheers edge for making me delete a canvas every resize. nicholas@2538: var canvas = document.getElementById('scale-canvas'); nicholas@2381: var new_canvas = document.createElement("canvas"); nicholas@2381: new_canvas.id = 'scale-canvas'; nicholas@2381: new_canvas.style.marginLeft = "100px"; nicholas@2381: canvas.parentElement.appendChild(new_canvas); nicholas@2381: canvas.parentElement.removeChild(canvas); nicholas@2538: new_canvas.width = window.innerWidth - 420; nicholas@2538: new_canvas.height = totalHeight; nicholas@2538: for (var i in audioEngineContext.audioObjects) { nicholas@2538: if (audioEngineContext.audioObjects[i].specification.type != 'outside-reference') { nicholas@2538: audioEngineContext.audioObjects[i].interfaceDOM.resize(event); nicholas@2538: } nicholas@2538: } nicholas@2538: document.getElementById("slider").style.height = totalHeight + 50 + 'px'; nicholas@2538: drawScale(); nickjillings@1343: } nickjillings@1343: nicholas@2538: function drawScale() { nicholas@2538: var interfaceObj = testState.currentStateMap.interfaces[0]; nicholas@2538: var scales = testState.currentStateMap.interfaces[0].scales; nicholas@3039: var ticks = specification.interfaces.options.concat(interfaceObj.options).find(function (a) { nicholas@3039: return (a.type == "show" && a.name == "ticks"); nicholas@3039: }); nicholas@3039: if (ticks !== undefined) { nicholas@3039: ticks = true; nicholas@3039: } else { nicholas@3039: ticks = false; nicholas@3039: } nicholas@2538: scales = scales.sort(function (a, b) { nicholas@2538: return a.position - b.position; nicholas@2538: }); nicholas@2538: var canvas = document.getElementById('scale-canvas'); nicholas@2538: var ctx = canvas.getContext("2d"); nicholas@2538: var height = canvas.height; nicholas@2538: var width = canvas.width; nicholas@2538: var textHolder = document.getElementById('scale-text-holder'); nicholas@2538: textHolder.innerHTML = ""; nicholas@2538: ctx.fillStyle = "#000000"; nicholas@2538: ctx.setLineDash([1, 4]); nicholas@2700: scales.forEach(function (scale) { nicholas@2538: var posPercent = scale.position / 100.0; nicholas@2538: var posPix = Math.round(width * posPercent); nicholas@2538: if (posPix <= 0) { nicholas@2538: posPix = 1; nicholas@2538: } nicholas@2538: if (posPix >= width) { nicholas@2538: posPix = width - 1; nicholas@2538: } nicholas@3039: if (ticks) { nicholas@3039: ctx.moveTo(posPix, 0); nicholas@3039: ctx.lineTo(posPix, height); nicholas@3039: ctx.stroke(); nicholas@3039: } nicholas@2538: nicholas@2538: var text = document.createElement('div'); nicholas@2538: text.align = "center"; nicholas@2538: var textC = document.createElement('span'); nicholas@2538: textC.textContent = scale.text; nicholas@2538: text.appendChild(textC); nicholas@2538: text.className = "scale-text"; nicholas@2538: textHolder.appendChild(text); nicholas@2538: text.style.width = Math.ceil($(text).width()) + 'px'; nicholas@2538: text.style.left = (posPix + 100 - ($(text).width() / 2)) + 'px'; nicholas@2700: }); nickjillings@1343: } nickjillings@1343: n@3008: function buttonSortFragmentClick() { n@3008: var sortIndex = interfaceContext.sortFragmentsByScore(); n@3008: var sliderBox = document.getElementById("slider-holder"); n@3008: var nodes = audioEngineContext.audioObjects.filter(function (ao) { n@3008: return ao.specification.type !== "outside-reference"; n@3008: }); n@3008: var i; n@3008: nodes.forEach(function (ao) { n@3008: sliderBox.removeChild(ao.interfaceDOM.holder); n@3008: }); n@3008: for (i = 0; i < nodes.length; i++) { n@3008: var j = sortIndex[i]; n@3008: sliderBox.appendChild(nodes[j].interfaceDOM.holder); n@3008: } n@3008: } n@3008: nickjillings@1343: function buttonSubmitClick() // TODO: Only when all songs have been played! nickjillings@1343: { nicholas@2651: var checks = testState.currentStateMap.interfaces[0].options, nicholas@2651: canContinue = true; nickjillings@1343: nicholas@2538: // Check that the anchor and reference objects are correctly placed nicholas@2700: if (interfaceContext.checkHiddenAnchor() === false) { nicholas@2538: return; nicholas@2538: } nicholas@2700: if (interfaceContext.checkHiddenReference() === false) { nicholas@2538: return; nicholas@2538: } nicholas@2825: if (interfaceContext.checkFragmentMinPlays() === false) { nicholas@2825: return; nicholas@2825: } nicholas@3035: if (interfaceContext.checkCommentQuestions() === false) { nicholas@3035: return; nicholas@3035: } nicholas@2538: nicholas@2538: for (var i = 0; i < checks.length; i++) { nicholas@2700: var checkState = true; nicholas@2538: if (checks[i].type == 'check') { nicholas@2538: switch (checks[i].name) { nicholas@2538: case 'fragmentPlayed': nicholas@2538: // Check if all fragments have been played n@2790: checkState = interfaceContext.checkAllPlayed(checks[i].errorMessage); nicholas@2538: break; nicholas@2538: case 'fragmentFullPlayback': nicholas@2538: // Check all fragments have been played to their full length n@2790: checkState = interfaceContext.checkAllPlayed(checks[i].errorMessage); nicholas@2538: console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead'); nicholas@2538: break; nicholas@2538: case 'fragmentMoved': nicholas@2538: // Check all fragment sliders have been moved. n@2790: checkState = interfaceContext.checkAllMoved(checks[i].errorMessage); nicholas@2538: break; nicholas@2538: case 'fragmentComments': nicholas@2538: // Check all fragment sliders have been moved. n@2790: checkState = interfaceContext.checkAllCommented(checks[i].errorMessage); nicholas@2538: break; nicholas@2538: case 'scalerange': nicholas@2538: // Check the scale has been used effectively n@2790: checkState = interfaceContext.checkScaleRange(checks[i].errorMessage); nicholas@2700: nicholas@2538: break; nicholas@2538: default: nicholas@2538: console.log("WARNING - Check option " + checks[i].check + " is not supported on this interface"); nicholas@2538: break; nicholas@2538: } nicholas@2538: } nicholas@2700: if (checkState === false) { nicholas@2700: canContinue = false; nicholas@2538: break; nicholas@2538: } nicholas@2538: } nicholas@2538: nickjillings@1343: if (canContinue) { nicholas@2538: if (audioEngineContext.status == 1) { nicholas@2538: var playback = document.getElementById('playback-button'); nicholas@2538: playback.click(); nicholas@2538: // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options nicholas@2538: } else { nicholas@2700: if (audioEngineContext.timer.testStarted === false) { nicholas@2538: interfaceContext.lightbox.post("Warning", 'You have not started the test! Please press start to begin the test!'); nicholas@2538: return; nicholas@2538: } nicholas@2538: } nicholas@2538: testState.advanceState(); nicholas@2538: } nickjillings@1343: } nickjillings@1343: nicholas@2538: function pageXMLSave(store, pageSpecification) { nicholas@2538: // MANDATORY nicholas@2538: // Saves a specific test page nicholas@2538: // You can use this space to add any extra nodes to your XML saves nicholas@2538: // Get the current information in store (remember to appendChild your data to it) nicholas@2538: // pageSpecification is the current page node configuration nicholas@2538: // To create new XML nodes, use storage.document.createElement(); nicholas@2538: }