annotate interfaces/ABX.js @ 2314:cbc26d0f104a

Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author www-data <www-data@sucuk.dcs.qmul.ac.uk>
date Fri, 29 Apr 2016 15:21:00 +0100
parents 426995e02e79
children 971acb7e3fab
rev   line source
nickjillings@2161 1 /**
nickjillings@2161 2 * WAET Blank Template
nickjillings@2161 3 * Use this to start building your custom interface
nickjillings@2161 4 */
nickjillings@2161 5
nickjillings@2161 6 // Once this is loaded and parsed, begin execution
nickjillings@2161 7 loadInterface();
nickjillings@2161 8
nickjillings@2161 9 function loadInterface() {
nickjillings@2161 10 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
nickjillings@2161 11 // holding div's, or setting up any nodes which are present for the entire test sequence
nickjillings@2161 12
nickjillings@2163 13 interfaceContext.insertPoint.innerHTML = null; // Clear the current schema
nickjillings@2163 14
nickjillings@2161 15 // Custom comparator Object
nickjillings@2161 16 Interface.prototype.comparator = null;
nickjillings@2161 17
nickjillings@2161 18 // The injection point into the HTML page
nickjillings@2161 19 interfaceContext.insertPoint = document.getElementById("topLevelBody");
nickjillings@2161 20 var testContent = document.createElement('div');
nickjillings@2161 21 testContent.id = 'testContent';
nickjillings@2161 22
nickjillings@2161 23 // Create the top div for the Title element
nickjillings@2161 24 var titleAttr = specification.title;
nickjillings@2161 25 var title = document.createElement('div');
nickjillings@2161 26 title.className = "title";
nickjillings@2161 27 title.align = "center";
nickjillings@2161 28 var titleSpan = document.createElement('span');
nickjillings@2161 29
nickjillings@2161 30 // Set title to that defined in XML, else set to default
nickjillings@2161 31 if (titleAttr != undefined) {
nickjillings@2161 32 titleSpan.textContent = titleAttr;
nickjillings@2161 33 } else {
nickjillings@2161 34 titleSpan.textContent = 'Listening test';
nickjillings@2161 35 }
nickjillings@2161 36 // Insert the titleSpan element into the title div element.
nickjillings@2161 37 title.appendChild(titleSpan);
nickjillings@2161 38
nickjillings@2161 39 var pagetitle = document.createElement('div');
nickjillings@2161 40 pagetitle.className = "pageTitle";
nickjillings@2161 41 pagetitle.align = "center";
nickjillings@2161 42 var titleSpan = document.createElement('span');
nickjillings@2161 43 titleSpan.id = "pageTitle";
nickjillings@2161 44 pagetitle.appendChild(titleSpan);
nickjillings@2161 45
nickjillings@2161 46 // Create Interface buttons!
nickjillings@2161 47 var interfaceButtons = document.createElement('div');
nickjillings@2161 48 interfaceButtons.id = 'interface-buttons';
nickjillings@2161 49 interfaceButtons.style.height = '25px';
nickjillings@2161 50
nickjillings@2161 51 // Create playback start/stop points
nickjillings@2161 52 var playback = document.createElement("button");
nickjillings@2161 53 playback.innerHTML = 'Stop';
nickjillings@2161 54 playback.id = 'playback-button';
nickjillings@2161 55 playback.style.float = 'left';
nickjillings@2161 56 // onclick function. Check if it is playing or not, call the correct function in the
nickjillings@2161 57 // audioEngine, change the button text to reflect the next state.
nickjillings@2161 58 playback.onclick = function() {
nickjillings@2161 59 if (audioEngineContext.status == 1) {
nickjillings@2161 60 audioEngineContext.stop();
nickjillings@2161 61 this.innerHTML = 'Stop';
nickjillings@2161 62 var time = audioEngineContext.timer.getTestTime();
nickjillings@2161 63 console.log('Stopped at ' + time); // DEBUG/SAFETY
nickjillings@2161 64 }
nickjillings@2161 65 };
nickjillings@2161 66 // Append the interface buttons into the interfaceButtons object.
nickjillings@2161 67 interfaceButtons.appendChild(playback);
nickjillings@2161 68
nickjillings@2161 69 // Global parent for the comment boxes on the page
nickjillings@2161 70 var feedbackHolder = document.createElement('div');
nickjillings@2161 71 feedbackHolder.id = 'feedbackHolder';
nickjillings@2161 72
nickjillings@2161 73 // Construct the AB Boxes
nickjillings@2161 74 var boxes = document.createElement('div');
nickjillings@2161 75 boxes.align = "center";
nickjillings@2161 76 boxes.id = "box-holders";
nickjillings@2161 77 boxes.style.float = "left";
nickjillings@2161 78
nickjillings@2161 79 var submit = document.createElement('button');
nickjillings@2161 80 submit.id = "submit";
nickjillings@2161 81 submit.onclick = buttonSubmitClick;
nickjillings@2161 82 submit.className = "big-button";
nickjillings@2161 83 submit.textContent = "submit";
nickjillings@2161 84 submit.style.position = "relative";
nickjillings@2161 85 submit.style.left = (window.innerWidth-250)/2 + 'px';
nickjillings@2161 86
nickjillings@2161 87 feedbackHolder.appendChild(boxes);
nickjillings@2161 88
nickjillings@2161 89 // Inject into HTML
nickjillings@2161 90 testContent.appendChild(title); // Insert the title
nickjillings@2161 91 testContent.appendChild(pagetitle);
nickjillings@2161 92 testContent.appendChild(interfaceButtons);
nickjillings@2161 93 testContent.appendChild(feedbackHolder);
nickjillings@2161 94 testContent.appendChild(submit);
nickjillings@2161 95 interfaceContext.insertPoint.appendChild(testContent);
nickjillings@2161 96
nickjillings@2161 97 // Load the full interface
nickjillings@2161 98 testState.initialise();
nickjillings@2161 99 testState.advanceState();
nickjillings@2161 100 };
nickjillings@2161 101
nickjillings@2161 102 function loadTest(page)
nickjillings@2161 103 {
nickjillings@2161 104 // Called each time a new test page is to be build. The page specification node is the only item passed in
nickjillings@2163 105 document.getElementById('box-holders').innerHTML = null;
nickjillings@2163 106
nickjillings@2163 107 var interfaceObj = page.interfaces;
nickjillings@2163 108 if (interfaceObj.length > 1)
nickjillings@2163 109 {
nickjillings@2163 110 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
nickjillings@2163 111 }
nickjillings@2163 112 interfaceObj = interfaceObj[0];
nickjillings@2163 113
nickjillings@2163 114 if(interfaceObj.title != null)
nickjillings@2163 115 {
nickjillings@2163 116 document.getElementById("pageTitle").textContent = interfaceObj.title;
nickjillings@2163 117 }
nickjillings@2163 118
nickjillings@2163 119 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options);
nickjillings@2163 120 for (var option of interfaceOptions)
nickjillings@2163 121 {
nickjillings@2163 122 if (option.type == "show")
nickjillings@2163 123 {
nickjillings@2163 124 switch(option.name) {
nickjillings@2163 125 case "playhead":
nickjillings@2163 126 var playbackHolder = document.getElementById('playback-holder');
nickjillings@2163 127 if (playbackHolder == null)
nickjillings@2163 128 {
nickjillings@2163 129 playbackHolder = document.createElement('div');
nickjillings@2163 130 playbackHolder.style.width = "100%";
nickjillings@2163 131 playbackHolder.style.float = "left";
nickjillings@2163 132 playbackHolder.align = 'center';
nickjillings@2163 133 playbackHolder.appendChild(interfaceContext.playhead.object);
nickjillings@2163 134 feedbackHolder.appendChild(playbackHolder);
nickjillings@2163 135 }
nickjillings@2163 136 break;
nickjillings@2163 137 case "page-count":
nickjillings@2163 138 var pagecountHolder = document.getElementById('page-count');
nickjillings@2163 139 if (pagecountHolder == null)
nickjillings@2163 140 {
nickjillings@2163 141 pagecountHolder = document.createElement('div');
nickjillings@2163 142 pagecountHolder.id = 'page-count';
nickjillings@2163 143 }
nickjillings@2163 144 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
nickjillings@2163 145 var inject = document.getElementById('interface-buttons');
nickjillings@2163 146 inject.appendChild(pagecountHolder);
nickjillings@2163 147 break;
nickjillings@2163 148 case "volume":
nickjillings@2163 149 if (document.getElementById('master-volume-holder') == null)
nickjillings@2163 150 {
nickjillings@2163 151 feedbackHolder.appendChild(interfaceContext.volume.object);
nickjillings@2163 152 }
nickjillings@2163 153 break;
nickjillings@2163 154 }
nickjillings@2163 155 }
nickjillings@2163 156 }
nickjillings@2163 157
nickjillings@2161 158 interfaceContext.comparator = new comparator(page);
nickjillings@2163 159 resizeWindow(null);
nickjillings@2161 160 }
nickjillings@2161 161
nickjillings@2161 162 function comparator(page)
nickjillings@2161 163 {
nickjillings@2161 164 // Build prototype constructor
nickjillings@2161 165 this.interfaceObject = function(element,label)
nickjillings@2161 166 {
nickjillings@2161 167 // An example node, you can make this however you want for each audioElement.
nickjillings@2161 168 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
nickjillings@2161 169 // You attach them by calling audioObject.bindInterface( )
nickjillings@2161 170 this.parent = element;
nickjillings@2161 171 this.id = element.id;
nickjillings@2161 172 this.value = 0;
nickjillings@2161 173 this.disabled = true;
nickjillings@2161 174 this.box = document.createElement('div');
nickjillings@2161 175 this.box.className = 'comparator-holder';
nickjillings@2161 176 this.box.setAttribute('track-id',element.id);
nickjillings@2161 177 this.box.id = 'comparator-'+label;
nickjillings@2161 178 this.selector = document.createElement('div');
nickjillings@2161 179 this.selector.className = 'comparator-selector disabled';
nickjillings@2161 180 var selectorText = document.createElement('span');
nickjillings@2161 181 selectorText.textContent = label;
nickjillings@2161 182 this.selector.appendChild(selectorText);
nickjillings@2161 183 this.playback = document.createElement('button');
nickjillings@2161 184 this.playback.className = 'comparator-button';
nickjillings@2161 185 this.playback.disabled = true;
nickjillings@2161 186 this.playback.textContent = "Listen";
nickjillings@2161 187 this.box.appendChild(this.selector);
nickjillings@2161 188 this.box.appendChild(this.playback);
nickjillings@2161 189 this.selector.onclick = function(event)
nickjillings@2161 190 {
nickjillings@2161 191 var label = event.currentTarget.children[0].textContent;
nickjillings@2161 192 if (label == "X" || label == "x") {return;}
nickjillings@2161 193 var time = audioEngineContext.timer.getTestTime();
nickjillings@2161 194 if ($(event.currentTarget).hasClass('disabled'))
nickjillings@2161 195 {
nickjillings@2161 196 console.log("Please wait until sample has loaded");
nickjillings@2161 197 return;
nickjillings@2161 198 }
nickjillings@2161 199 if (audioEngineContext.status == 0)
nickjillings@2161 200 {
nickjillings@2161 201 alert("Please listen to the samples before making a selection");
nickjillings@2161 202 console.log("Please listen to the samples before making a selection");
nickjillings@2161 203 return;
nickjillings@2161 204 }
nickjillings@2161 205 var id = event.currentTarget.parentElement.getAttribute('track-id');
nickjillings@2161 206 interfaceContext.comparator.selected = id;
nickjillings@2161 207 if ($(event.currentTarget).hasClass("selected")) {
nickjillings@2161 208 $(".comparator-selector").removeClass('selected');
giuliomoro@2291 209 for (var i=0; i<interfaceContext.comparator.pair.length; i++)
nickjillings@2161 210 {
nicholas@2308 211 var obj = interfaceContext.comparator.pair[i];
nickjillings@2161 212 obj.parent.metric.moved(time,0);
nicholas@2308 213 obj.value = 0;
nickjillings@2161 214 }
nickjillings@2161 215 } else {
nickjillings@2161 216 $(".comparator-selector").removeClass('selected');
nickjillings@2161 217 $(event.currentTarget).addClass('selected');
giuliomoro@2291 218 for (var i=0; i<interfaceContext.comparator.pair.length; i++)
nickjillings@2161 219 {
giuliomoro@2291 220 var obj = interfaceContext.comparator.pair[i];
nickjillings@2161 221 if (i == id) {
nickjillings@2161 222 obj.value = 1;
nickjillings@2161 223 } else {
nickjillings@2161 224 obj.value = 0;
nickjillings@2161 225 }
nickjillings@2161 226 obj.parent.metric.moved(time,obj.value);
nickjillings@2161 227 }
nickjillings@2161 228 console.log("Selected "+id+' ('+time+')');
nickjillings@2161 229 }
nickjillings@2161 230 };
nickjillings@2161 231 this.playback.setAttribute("playstate","ready");
nickjillings@2161 232 this.playback.onclick = function(event)
nickjillings@2161 233 {
nickjillings@2161 234 var id = event.currentTarget.parentElement.getAttribute('track-id');
nickjillings@2161 235 if (event.currentTarget.getAttribute("playstate") == "ready")
nickjillings@2161 236 {
nickjillings@2161 237 audioEngineContext.play(id);
nickjillings@2161 238 } else if (event.currentTarget.getAttribute("playstate") == "playing") {
nickjillings@2161 239 audioEngineContext.stop();
nickjillings@2161 240 }
nickjillings@2161 241
nickjillings@2161 242 };
nickjillings@2161 243 this.enable = function()
nickjillings@2161 244 {
nickjillings@2161 245 // This is used to tell the interface object that playback of this node is ready
nickjillings@2161 246 if (this.parent.state == 1)
nickjillings@2161 247 {
nickjillings@2161 248 $(this.selector).removeClass('disabled');
nickjillings@2161 249 this.playback.disabled = false;
nickjillings@2161 250 }
nickjillings@2161 251 };
nickjillings@2161 252 this.updateLoading = function(progress)
nickjillings@2161 253 {
nickjillings@2161 254 // progress is a value from 0 to 100 indicating the current download state of media files
nickjillings@2161 255 if (progress != 100)
nickjillings@2161 256 {
nickjillings@2161 257 progress = String(progress);
nickjillings@2161 258 progress = progress.split('.')[0];
nickjillings@2161 259 this.playback.textContent = progress+'%';
nickjillings@2161 260 } else {
nickjillings@2161 261 this.playback.textContent = "Play";
nickjillings@2161 262 }
nickjillings@2161 263 };
nickjillings@2161 264 this.error = function() {
nickjillings@2161 265 // audioObject has an error!!
nickjillings@2161 266 this.playback.textContent = "Error";
nickjillings@2161 267 $(this.playback).addClass("error-colour");
nickjillings@2161 268 };
nickjillings@2161 269 this.startPlayback = function()
nickjillings@2161 270 {
nickjillings@2161 271 // Called when playback has begun
nickjillings@2161 272 $('.comparator-button').text('Listen');
nickjillings@2161 273 $(this.playback).text('Stop');
nickjillings@2161 274 this.playback.setAttribute("playstate","playing");
nickjillings@2161 275 };
nickjillings@2161 276 this.stopPlayback = function()
nickjillings@2161 277 {
nickjillings@2161 278 // Called when playback has stopped. This gets called even if playback never started!
nickjillings@2161 279 $(this.playback).text('Listen');
nickjillings@2161 280 this.playback.setAttribute("playstate","ready");
nickjillings@2161 281 };
nickjillings@2161 282 this.getValue = function()
nickjillings@2161 283 {
nickjillings@2161 284 // Return the current value of the object. If there is no value, return 0
nickjillings@2161 285 return this.value;
nickjillings@2161 286 };
nickjillings@2161 287 this.getPresentedId = function()
nickjillings@2161 288 {
nickjillings@2161 289 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
nickjillings@2161 290 return this.selector.children[0].textContent;
nickjillings@2161 291 };
nickjillings@2161 292 this.canMove = function()
nickjillings@2161 293 {
nickjillings@2161 294 // Return either true or false if the interface object can be moved. AB / Reference cannot, whilst sliders can and therefore have a continuous scale.
nickjillings@2161 295 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
nickjillings@2161 296 return false;
nickjillings@2161 297 };
nickjillings@2161 298 this.exportXMLDOM = function(audioObject) {
nickjillings@2161 299 // Called by the audioObject holding this element to export the interface <value> node.
nickjillings@2161 300 // If there is no value node (such as outside reference), return null
nickjillings@2161 301 // 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
nickjillings@2161 302 // Use storage.document.createElement('value'); to generate the XML node.
nickjillings@2161 303 var node = storage.document.createElement('value');
nickjillings@2161 304 node.textContent = this.value;
nickjillings@2161 305 return node;
nickjillings@2161 306
nickjillings@2161 307 };
nickjillings@2161 308 this.error = function() {
nickjillings@2161 309 // If there is an error with the audioObject, this will be called to indicate a failure
nickjillings@2161 310 }
nickjillings@2161 311 };
nickjillings@2161 312 // Ensure there are only two comparisons per page
nickjillings@2161 313 if (page.audioElements.length != 2) {
nickjillings@2161 314 console.error('FATAL - There must be 2 <audioelement> nodes on each <page>: '+page.id);
nickjillings@2161 315 return;
nickjillings@2161 316 }
nickjillings@2161 317 // Build the three audio elements
nickjillings@2161 318 this.pair = [];
nickjillings@2161 319 this.X = null;
nickjillings@2161 320 this.boxHolders = document.getElementById('box-holders');
nickjillings@2161 321 for (var index=0; index<page.audioElements.length; index++) {
nickjillings@2161 322 var element = page.audioElements[index];
nickjillings@2161 323 if (element.type != 'normal')
nickjillings@2161 324 {
nickjillings@2161 325 console.log("WARNING - ABX can only have normal elements. Page "+page.id+", Element "+element.id);
nickjillings@2161 326 element.type = "normal";
nickjillings@2161 327 }
nickjillings@2161 328 var audioObject = audioEngineContext.newTrack(element);
nickjillings@2161 329 var label;
nickjillings@2161 330 switch(audioObject.specification.parent.label) {
nickjillings@2161 331 case "none":
nickjillings@2161 332 label = "";
nickjillings@2161 333 break;
nickjillings@2161 334 case "number":
nickjillings@2161 335 label = ""+index;
nickjillings@2161 336 break;
nickjillings@2161 337 case "letter":
nickjillings@2161 338 label = String.fromCharCode(97 + index);
nickjillings@2161 339 break;
nickjillings@2161 340 default:
nickjillings@2161 341 label = String.fromCharCode(65 + index);
nickjillings@2161 342 break;
nickjillings@2161 343 }
nickjillings@2161 344 var node = new this.interfaceObject(audioObject,label);
nickjillings@2161 345 audioObject.bindInterface(node);
nickjillings@2161 346 this.pair.push(node);
nickjillings@2161 347 this.boxHolders.appendChild(node.box);
nickjillings@2161 348 }
nickjillings@2161 349 var elementId = Math.floor(Math.random() * 2); //Randomly pick A or B to be X
giuliomoro@2291 350 var element = new page.audioElementNode(specification);
nickjillings@2161 351 for (var atr in page.audioElements[elementId]) {
nickjillings@2161 352 eval("element."+atr+" = page.audioElements[elementId]."+atr);
nickjillings@2161 353 }
nickjillings@2161 354 element.id += "-X";
nickjillings@2161 355 if (typeof element.name == "string") {element.name+="-X";}
nickjillings@2161 356 page.audioElements.push(element);
nickjillings@2161 357 // Create the save place-holder for the 'X' element
nickjillings@2161 358 var root = testState.currentStore.XMLDOM;
nickjillings@2161 359 var aeNode = storage.document.createElement('audioelement');
nickjillings@2161 360 aeNode.setAttribute('ref',element.id);
nickjillings@2161 361 if (typeof element.name == "string"){aeNode.setAttribute('name',element.name);}
nickjillings@2161 362 aeNode.setAttribute('type','normal');
nickjillings@2161 363 aeNode.setAttribute('url',element.url);
nickjillings@2161 364 aeNode.setAttribute('gain',element.gain);
nickjillings@2161 365 aeNode.appendChild(storage.document.createElement('metric'));
nickjillings@2161 366 root.appendChild(aeNode);
nickjillings@2161 367 // Build the 'X' element
nickjillings@2161 368 var audioObject = audioEngineContext.newTrack(element);
nickjillings@2161 369 var label;
nickjillings@2161 370 switch(audioObject.specification.parent.label) {
nickjillings@2161 371 case "letter":
nickjillings@2161 372 label = "x";
nickjillings@2161 373 break;
nickjillings@2161 374 default:
nickjillings@2161 375 label = "X";
nickjillings@2161 376 break;
nickjillings@2161 377 }
nickjillings@2161 378 var node = new this.interfaceObject(audioObject,label);
giuliomoro@2305 379 node.box.children[0].classList.add('inactive');
nickjillings@2161 380 audioObject.bindInterface(node);
nickjillings@2161 381 this.X = node;
nickjillings@2161 382 this.boxHolders.appendChild(node.box);
nickjillings@2161 383 }
nickjillings@2161 384
nickjillings@2161 385 function resizeWindow(event)
nickjillings@2161 386 {
nickjillings@2163 387 document.getElementById('submit').style.left = (window.innerWidth-250)/2 + 'px';
nickjillings@2163 388 var numObj = 3;
nickjillings@2163 389 var boxW = numObj*312;
nickjillings@2163 390 var diff = window.innerWidth - boxW;
nickjillings@2163 391 while (diff < 0)
nickjillings@2163 392 {
nickjillings@2163 393 numObj = Math.ceil(numObj/2);
nickjillings@2163 394 boxW = numObj*312;
nickjillings@2163 395 diff = window.innerWidth - boxW;
nickjillings@2163 396 }
nickjillings@2163 397 document.getElementById('box-holders').style.marginLeft = diff/2 + 'px';
nickjillings@2163 398 document.getElementById('box-holders').style.marginRight = diff/2 + 'px';
nickjillings@2163 399 document.getElementById('box-holders').style.width = boxW + 'px';
nickjillings@2161 400 }
nickjillings@2161 401
nickjillings@2161 402 function buttonSubmitClick()
nickjillings@2161 403 {
nickjillings@2163 404 var checks = [];
nickjillings@2163 405 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
nickjillings@2163 406 checks = checks.concat(specification.interfaces.options);
nickjillings@2163 407 var canContinue = true;
nickjillings@2163 408
nickjillings@2163 409 for (var i=0; i<checks.length; i++) {
nickjillings@2163 410 if (checks[i].type == 'check')
nickjillings@2163 411 {
nickjillings@2163 412 switch(checks[i].name) {
nickjillings@2163 413 case 'fragmentPlayed':
nickjillings@2163 414 // Check if all fragments have been played
nickjillings@2163 415 var checkState = interfaceContext.checkAllPlayed();
nickjillings@2163 416 if (checkState == false) {canContinue = false;}
nickjillings@2163 417 break;
nickjillings@2163 418 case 'fragmentFullPlayback':
nickjillings@2163 419 // Check all fragments have been played to their full length
nickjillings@2163 420 var checkState = interfaceContext.checkFragmentsFullyPlayed();
nickjillings@2163 421 if (checkState == false) {canContinue = false;}
nickjillings@2163 422 break;
nickjillings@2163 423 case 'fragmentMoved':
nickjillings@2163 424 // Check all fragment sliders have been moved.
nickjillings@2163 425 var checkState = interfaceContext.checkAllMoved();
nickjillings@2163 426 if (checkState == false) {canContinue = false;}
nickjillings@2163 427 break;
nickjillings@2163 428 case 'fragmentComments':
nickjillings@2163 429 // Check all fragment sliders have been moved.
nickjillings@2163 430 var checkState = interfaceContext.checkAllCommented();
nickjillings@2163 431 if (checkState == false) {canContinue = false;}
nickjillings@2163 432 break;
nicholas@2310 433 case 'scalerange':
nicholas@2310 434 // Check the scale has been used effectively
nicholas@2310 435 var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max);
nicholas@2310 436 if (checkState == false) {canContinue = false;}
nicholas@2310 437 break;
nickjillings@2163 438 default:
nickjillings@2163 439 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
nickjillings@2163 440 break;
nickjillings@2163 441 }
nickjillings@2163 442
nickjillings@2163 443 }
nickjillings@2163 444 if (!canContinue) {break;}
nickjillings@2163 445 }
nickjillings@2163 446 if (canContinue)
nickjillings@2163 447 {
nickjillings@2163 448 if (audioEngineContext.status == 1) {
nickjillings@2163 449 var playback = document.getElementById('playback-button');
nickjillings@2163 450 playback.click();
nickjillings@2163 451 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
nickjillings@2163 452 } else
nickjillings@2163 453 {
nickjillings@2163 454 if (audioEngineContext.timer.testStarted == false)
nickjillings@2163 455 {
nickjillings@2163 456 alert('You have not started the test! Please press start to begin the test!');
nickjillings@2163 457 return;
nickjillings@2163 458 }
nickjillings@2163 459 }
nickjillings@2163 460 testState.advanceState();
nickjillings@2163 461 }
nickjillings@2161 462 }
nickjillings@2161 463
nickjillings@2161 464 function pageXMLSave(store, pageSpecification)
nickjillings@2161 465 {
nickjillings@2161 466 // MANDATORY
nickjillings@2161 467 // Saves a specific test page
nickjillings@2161 468 // You can use this space to add any extra nodes to your XML <audioHolder> saves
nickjillings@2161 469 // Get the current <page> information in store (remember to appendChild your data to it)
nickjillings@2161 470 // pageSpecification is the current page node configuration
nickjillings@2161 471 // To create new XML nodes, use storage.document.createElement();
nickjillings@2161 472 }