annotate interfaces/ABX.js @ 2929:270f20b2d68f

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