annotate interfaces/horizontal-sliders.js @ 2790:cae61c5bbed1

Completed #133
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Sat, 22 Apr 2017 17:56:18 +0100
parents c59bcb698684
children 1076ac62823f
rev   line source
nickjillings@1343 1 // Once this is loaded and parsed, begin execution
nicholas@2700 2 /*globals interfaceContext, window, document, specification, audioEngineContext, console, testState, $, storage */
nickjillings@1343 3 loadInterface();
nickjillings@1343 4
nickjillings@1343 5 function loadInterface() {
nicholas@2538 6 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
nicholas@2538 7 // holding div's, or setting up any nodes which are present for the entire test sequence
nicholas@2538 8
nicholas@2538 9 // The injection point into the HTML page
nicholas@2538 10 interfaceContext.insertPoint = document.getElementById("topLevelBody");
nicholas@2538 11 var testContent = document.createElement('div');
nicholas@2538 12 testContent.id = 'testContent';
nicholas@2538 13
nicholas@2538 14 // Create the top div for the Title element
nicholas@2538 15 var titleAttr = specification.title;
nicholas@2538 16 var title = document.createElement('div');
nicholas@2538 17 title.className = "title";
nicholas@2538 18 title.align = "center";
nicholas@2538 19 var titleSpan = document.createElement('span');
nicholas@2538 20 titleSpan.id = "test-title";
nicholas@2538 21
nicholas@2538 22 // Set title to that defined in XML, else set to default
nicholas@2700 23 if (titleAttr !== undefined) {
nicholas@2538 24 titleSpan.textContent = titleAttr;
nicholas@2538 25 } else {
nicholas@2538 26 titleSpan.textContent = 'Listening test';
nicholas@2538 27 }
nicholas@2538 28 // Insert the titleSpan element into the title div element.
nicholas@2538 29 title.appendChild(titleSpan);
nicholas@2538 30
nicholas@2538 31 var pagetitle = document.createElement('div');
nicholas@2538 32 pagetitle.className = "pageTitle";
nicholas@2538 33 pagetitle.align = "center";
nicholas@2700 34
nicholas@2700 35 titleSpan = document.createElement('span');
nicholas@2538 36 titleSpan.id = "pageTitle";
nicholas@2538 37 pagetitle.appendChild(titleSpan);
nicholas@2538 38
nicholas@2538 39 // Create Interface buttons!
nicholas@2538 40 var interfaceButtons = document.createElement('div');
nicholas@2538 41 interfaceButtons.id = 'interface-buttons';
nicholas@2538 42 interfaceButtons.style.height = '25px';
nicholas@2538 43
nicholas@2538 44 // Create playback start/stop points
nicholas@2538 45 var playback = document.createElement("button");
nicholas@2538 46 playback.innerHTML = 'Stop';
nicholas@2538 47 playback.id = 'playback-button';
nicholas@2538 48 playback.style.float = 'left';
nicholas@2538 49 // onclick function. Check if it is playing or not, call the correct function in the
nicholas@2538 50 // audioEngine, change the button text to reflect the next state.
nicholas@2538 51 playback.onclick = function () {
nicholas@2538 52 if (audioEngineContext.status == 1) {
nicholas@2538 53 audioEngineContext.stop();
nicholas@2538 54 this.innerHTML = 'Stop';
nickjillings@1343 55 var time = audioEngineContext.timer.getTestTime();
nickjillings@1343 56 console.log('Stopped at ' + time); // DEBUG/SAFETY
nicholas@2538 57 }
nicholas@2538 58 };
nicholas@2538 59 // Create Submit (save) button
nicholas@2538 60 var submit = document.createElement("button");
nicholas@2538 61 submit.innerHTML = 'Next';
nicholas@2538 62 submit.onclick = buttonSubmitClick;
nicholas@2538 63 submit.id = 'submit-button';
nicholas@2538 64 submit.style.float = 'left';
nicholas@2538 65 // Append the interface buttons into the interfaceButtons object.
nicholas@2538 66 interfaceButtons.appendChild(playback);
nicholas@2538 67 interfaceButtons.appendChild(submit);
nicholas@2538 68
nicholas@2396 69 // Create outside reference holder
nicholas@2396 70 var outsideRef = document.createElement("div");
nicholas@2396 71 outsideRef.id = "outside-reference-holder";
nicholas@2538 72
nicholas@2538 73 // Create a slider box
nicholas@2538 74 var sliderBox = document.createElement('div');
nicholas@2538 75 sliderBox.style.width = "100%";
nicholas@2538 76 sliderBox.style.height = window.innerHeight - 200 + 12 + 'px';
nicholas@2538 77 sliderBox.style.marginBottom = '10px';
nicholas@2538 78 sliderBox.id = 'slider';
nicholas@2538 79 var scaleHolder = document.createElement('div');
nicholas@2538 80 scaleHolder.id = "scale-holder";
nicholas@2538 81 scaleHolder.style.marginLeft = "107px";
nicholas@2538 82 sliderBox.appendChild(scaleHolder);
nicholas@2538 83 var scaleText = document.createElement('div');
nicholas@2538 84 scaleText.id = "scale-text-holder";
nicholas@2538 85 scaleText.style.height = "25px";
nicholas@2538 86 scaleText.style.width = "100%";
nicholas@2538 87 scaleHolder.appendChild(scaleText);
nicholas@2538 88 var scaleCanvas = document.createElement('canvas');
nicholas@2538 89 scaleCanvas.id = "scale-canvas";
nicholas@2538 90 scaleCanvas.style.marginLeft = "100px";
nicholas@2538 91 scaleHolder.appendChild(scaleCanvas);
nicholas@2538 92 var sliderObjectHolder = document.createElement('div');
nicholas@2538 93 sliderObjectHolder.id = 'slider-holder';
nicholas@2538 94 sliderObjectHolder.align = "center";
nicholas@2538 95 sliderBox.appendChild(sliderObjectHolder);
nicholas@2538 96
nicholas@2538 97 // Global parent for the comment boxes on the page
nicholas@2538 98 var feedbackHolder = document.createElement('div');
nicholas@2538 99 feedbackHolder.id = 'feedbackHolder';
nicholas@2538 100
nicholas@2538 101 testContent.style.zIndex = 1;
nicholas@2538 102 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
nicholas@2538 103
nicholas@2538 104 // Inject into HTML
nicholas@2538 105 testContent.appendChild(title); // Insert the title
nicholas@2538 106 testContent.appendChild(pagetitle);
nicholas@2538 107 testContent.appendChild(interfaceButtons);
nicholas@2396 108 testContent.appendChild(outsideRef);
nicholas@2538 109 testContent.appendChild(sliderBox);
nicholas@2538 110 testContent.appendChild(feedbackHolder);
nicholas@2538 111 interfaceContext.insertPoint.appendChild(testContent);
nickjillings@1343 112
nicholas@2538 113 // Load the full interface
nicholas@2538 114 testState.initialise();
nicholas@2538 115 testState.advanceState();
nicholas@2700 116 }
nickjillings@1343 117
nicholas@2538 118 function loadTest(page) {
nicholas@2538 119 // Called each time a new test page is to be build. The page specification node is the only item passed in
nicholas@2538 120 var id = page.id;
nicholas@2538 121
nicholas@2538 122 var feedbackHolder = document.getElementById('feedbackHolder');
nicholas@2381 123 feedbackHolder.innerHTML = "";
nicholas@2538 124
nicholas@2651 125 var interfaceObj = interfaceContext.getCombinedInterfaces(page);
nicholas@2538 126 if (interfaceObj.length > 1) {
nicholas@2538 127 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
nicholas@2538 128 }
nicholas@2538 129 interfaceObj = interfaceObj[0];
nicholas@2538 130
nicholas@2470 131 // Set the page title
nicholas@2470 132 if (typeof page.title == "string" && page.title.length > 0) {
nicholas@2700 133 document.getElementById("test-title").textContent = page.title;
nicholas@2470 134 }
nicholas@2538 135
nicholas@2700 136 if (interfaceObj.title !== null) {
nicholas@2538 137 document.getElementById("pageTitle").textContent = interfaceObj.title;
nicholas@2538 138 }
nicholas@2538 139
nicholas@2781 140 if (interfaceObj.image !== undefined) {
nicholas@2781 141 document.getElementById("testContent").insertBefore(interfaceContext.imageHolder.root, document.getElementById("slider"));
nicholas@2781 142 interfaceContext.imageHolder.setImage(interfaceObj.image);
nicholas@2781 143 }
nicholas@2781 144
nicholas@2538 145 // Delete outside reference
nicholas@2538 146 document.getElementById("outside-reference-holder").innerHTML = "";
nicholas@2538 147
nicholas@2538 148 var sliderBox = document.getElementById('slider-holder');
nicholas@2538 149 sliderBox.innerHTML = "";
nicholas@2538 150
nicholas@2538 151 var commentBoxPrefix = "Comment on track";
nicholas@2700 152 if (interfaceObj.commentBoxPrefix !== undefined) {
nicholas@2538 153 commentBoxPrefix = interfaceObj.commentBoxPrefix;
nicholas@2538 154 }
nicholas@2538 155 var loopPlayback = page.loop;
nicholas@2538 156
nicholas@2538 157 $(page.commentQuestions).each(function (index, element) {
nicholas@2538 158 var node = interfaceContext.createCommentQuestion(element);
nicholas@2538 159 feedbackHolder.appendChild(node.holder);
nicholas@2538 160 });
nicholas@2538 161
nicholas@2538 162 // Find all the audioElements from the audioHolder
nicholas@2538 163 var index = 0;
nicholas@2607 164 var labelType = page.label;
nicholas@2607 165 if (labelType == "default") {
nicholas@2607 166 labelType = "number";
nicholas@2607 167 }
nicholas@2607 168 $(page.audioElements).each(function (pageIndex, element) {
nicholas@2538 169 // Find URL of track
nicholas@2538 170 // In this jQuery loop, variable 'this' holds the current audioElement.
nicholas@2538 171
nicholas@2538 172 var audioObject = audioEngineContext.newTrack(element);
nicholas@2538 173 if (element.type == 'outside-reference') {
nicholas@2538 174 // Construct outside reference;
nicholas@2538 175 var orNode = new interfaceContext.outsideReferenceDOM(audioObject, index, document.getElementById("outside-reference-holder"));
nicholas@2538 176 audioObject.bindInterface(orNode);
nicholas@2538 177 } else {
nicholas@2538 178 // Create a slider per track
nicholas@2607 179 var label = interfaceContext.getLabel(labelType, index, page.labelStart);
nicholas@2538 180 var sliderObj = new sliderObject(audioObject, label);
nicholas@2538 181
nicholas@2538 182 if (typeof page.initialPosition === "number") {
nicholas@2538 183 // Set the values
nicholas@2538 184 sliderObj.slider.value = page.initalPosition;
nicholas@2538 185 } else {
nicholas@2538 186 // Distribute it randomnly
nicholas@2538 187 sliderObj.slider.value = Math.random();
nicholas@2538 188 }
nicholas@2538 189 sliderBox.appendChild(sliderObj.holder);
nicholas@2538 190 audioObject.bindInterface(sliderObj);
nickjillings@2117 191 interfaceContext.commentBoxes.createCommentBox(audioObject);
nicholas@2538 192 index += 1;
nicholas@2538 193 }
nicholas@2538 194
nicholas@2538 195 });
nicholas@2700 196 interfaceObj.options.forEach(function (option) {
nicholas@2538 197 if (option.type == "show") {
nicholas@2538 198 switch (option.name) {
n@2407 199 case "playhead":
n@2407 200 var playbackHolder = document.getElementById('playback-holder');
nicholas@2700 201 if (playbackHolder === null) {
n@2407 202 playbackHolder = document.createElement('div');
n@2407 203 playbackHolder.style.width = "100%";
n@2407 204 playbackHolder.align = 'center';
n@2407 205 playbackHolder.appendChild(interfaceContext.playhead.object);
n@2407 206 feedbackHolder.appendChild(playbackHolder);
n@2407 207 }
n@2407 208 break;
n@2407 209 case "page-count":
n@2407 210 var pagecountHolder = document.getElementById('page-count');
nicholas@2700 211 if (pagecountHolder === null) {
n@2407 212 pagecountHolder = document.createElement('div');
n@2407 213 pagecountHolder.id = 'page-count';
n@2407 214 }
nicholas@2538 215 pagecountHolder.innerHTML = '<span>Page ' + (testState.stateIndex + 1) + ' of ' + testState.stateMap.length + '</span>';
n@2407 216 var inject = document.getElementById('interface-buttons');
n@2407 217 inject.appendChild(pagecountHolder);
n@2407 218 break;
n@2407 219 case "volume":
nicholas@2700 220 if (document.getElementById('master-volume-holder') === null) {
n@2407 221 feedbackHolder.appendChild(interfaceContext.volume.object);
n@2407 222 }
n@2407 223 break;
n@2407 224 case "comments":
nicholas@2538 225 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder, true);
n@2407 226 break;
n@2407 227 }
n@2407 228 }
nicholas@2700 229 });
nicholas@2538 230 // Auto-align
nicholas@2538 231 resizeWindow(null);
nickjillings@1343 232 }
nickjillings@1343 233
nicholas@2538 234 function sliderObject(audioObject, label) {
nicholas@2538 235 // An example node, you can make this however you want for each audioElement.
nicholas@2538 236 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
nicholas@2538 237 // You attach them by calling audioObject.bindInterface( )
nicholas@2538 238 this.parent = audioObject;
nicholas@2538 239
nicholas@2538 240 this.holder = document.createElement('div');
nicholas@2538 241 this.title = document.createElement('div');
nicholas@2538 242 this.slider = document.createElement('input');
nicholas@2538 243 this.play = document.createElement('button');
nicholas@2538 244
nicholas@2538 245 this.holder.className = 'track-slider';
nicholas@2538 246 this.holder.style.width = window.innerWidth - 200 + 'px';
nicholas@2538 247 this.holder.appendChild(this.title);
nicholas@2538 248 this.holder.appendChild(this.slider);
nicholas@2538 249 this.holder.appendChild(this.play);
nicholas@2538 250 this.holder.setAttribute('trackIndex', audioObject.id);
nicholas@2538 251 this.title.textContent = label;
nicholas@2538 252 this.title.className = 'track-slider-title';
nicholas@2538 253
nicholas@2538 254 this.slider.type = "range";
nicholas@2538 255 this.slider.className = "track-slider-range track-slider-not-moved";
nicholas@2538 256 this.slider.min = "0";
nicholas@2538 257 this.slider.max = "1";
nicholas@2538 258 this.slider.step = "0.01";
nicholas@2538 259 this.slider.style.width = window.innerWidth - 420 + 'px';
nicholas@2538 260 this.slider.onchange = function () {
nicholas@2538 261 var time = audioEngineContext.timer.getTestTime();
nicholas@2538 262 var id = Number(this.parentNode.getAttribute('trackIndex'));
nicholas@2538 263 audioEngineContext.audioObjects[id].metric.moved(time, this.value);
nicholas@2538 264 console.log('slider ' + id + ' moved to ' + this.value + ' (' + time + ')');
nicholas@2538 265 $(this).removeClass('track-slider-not-moved');
nicholas@2538 266 };
nicholas@2538 267
nicholas@2538 268 this.play.className = 'track-slider-button';
nicholas@2538 269 this.play.textContent = "Loading...";
nicholas@2538 270 this.play.value = audioObject.id;
nicholas@2538 271 this.play.disabled = true;
nicholas@2538 272 this.play.setAttribute("playstate", "ready");
nicholas@2538 273 this.play.onclick = function (event) {
nicholas@2538 274 var id = Number(event.currentTarget.value);
nicholas@2538 275 //audioEngineContext.metric.sliderPlayed(id);
nicholas@2538 276 if (event.currentTarget.getAttribute("playstate") == "ready") {
nicholas@2538 277 audioEngineContext.play(id);
nicholas@2538 278 } else if (event.currentTarget.getAttribute("playstate") == "playing") {
nicholas@2538 279 audioEngineContext.stop();
nicholas@2538 280 }
nicholas@2538 281 };
nicholas@2538 282 this.resize = function (event) {
nicholas@2538 283 this.holder.style.width = window.innerWidth - 200 + 'px';
nicholas@2538 284 this.slider.style.width = window.innerWidth - 420 + 'px';
nicholas@2538 285 };
nicholas@2538 286 this.enable = function () {
nicholas@2538 287 // This is used to tell the interface object that playback of this node is ready
nicholas@2538 288 this.play.disabled = false;
nicholas@2538 289 this.play.textContent = "Play";
nicholas@2538 290 $(this.slider).removeClass('track-slider-disabled');
nicholas@2538 291 };
nicholas@2538 292 this.updateLoading = function (progress) {
nicholas@2538 293 // progress is a value from 0 to 100 indicating the current download state of media files
nicholas@2538 294 };
nicholas@2538 295 this.startPlayback = function () {
nickjillings@1360 296 // Called when playback has begun
nicholas@2538 297 this.play.setAttribute("playstate", "playing");
nickjillings@1360 298 $(".track-slider").removeClass('track-slider-playing');
nicholas@2538 299 $(this.holder).addClass('track-slider-playing');
nicholas@2538 300 var outsideReference = document.getElementById('outside-reference');
nicholas@2700 301 if (outsideReference !== null) {
nicholas@2538 302 $(outsideReference).removeClass('track-slider-playing');
nicholas@2538 303 }
nicholas@2725 304 interfaceContext.commentBoxes.highlightById(audioObject.id);
nickjillings@1360 305 };
nicholas@2538 306 this.stopPlayback = function () {
nickjillings@1360 307 // Called when playback has stopped. This gets called even if playback never started!
nicholas@2538 308 this.play.setAttribute("playstate", "ready");
nickjillings@1360 309 $(this.holder).removeClass('track-slider-playing');
nicholas@2725 310 var box = interfaceContext.commentBoxes.boxes.find(function (a) {
nicholas@2725 311 return a.id === audioObject.id;
nicholas@2725 312 });
nicholas@2725 313 if (box) {
nicholas@2725 314 box.highlight(false);
nicholas@2725 315 }
nickjillings@1360 316 };
nicholas@2538 317 this.getValue = function () {
nicholas@2538 318 // Return the current value of the object. If there is no value, return 0
nicholas@2538 319 return this.slider.value;
nicholas@2538 320 };
nicholas@2538 321 this.getPresentedId = function () {
nicholas@2538 322 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
nicholas@2538 323 return this.title.textContent;
nicholas@2538 324 };
nicholas@2538 325 this.canMove = function () {
nicholas@2538 326 // 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 327 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
nicholas@2538 328 return true;
nicholas@2538 329 };
nicholas@2538 330 this.exportXMLDOM = function (audioObject) {
nicholas@2538 331 // Called by the audioObject holding this element to export the interface <value> node.
nicholas@2538 332 // If there is no value node (such as outside reference), return null
nicholas@2538 333 // 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 334 // Use storage.document.createElement('value'); to generate the XML node.
nicholas@2538 335 var node = storage.document.createElement('value');
nickjillings@1347 336 node.textContent = this.slider.value;
nickjillings@1347 337 return node;
nicholas@2538 338 };
nicholas@2538 339 this.error = function () {
nicholas@2538 340 // audioObject has an error!!
nickjillings@2113 341 this.playback.textContent = "Error";
nickjillings@2113 342 $(this.playback).addClass("error-colour");
nicholas@2700 343 };
nicholas@2700 344 }
nickjillings@1343 345
nicholas@2538 346 function resizeWindow(event) {
nicholas@2538 347 // Called on every window resize event, use this to scale your page properly
nicholas@2538 348
nicholas@2538 349 var numObj = document.getElementsByClassName('track-slider').length;
nicholas@2538 350 var totalHeight = (numObj * 125) - 25;
nicholas@2538 351 document.getElementById('scale-holder').style.width = window.innerWidth - 220 + 'px';
nicholas@2538 352 // Cheers edge for making me delete a canvas every resize.
nicholas@2538 353 var canvas = document.getElementById('scale-canvas');
nicholas@2381 354 var new_canvas = document.createElement("canvas");
nicholas@2381 355 new_canvas.id = 'scale-canvas';
nicholas@2381 356 new_canvas.style.marginLeft = "100px";
nicholas@2381 357 canvas.parentElement.appendChild(new_canvas);
nicholas@2381 358 canvas.parentElement.removeChild(canvas);
nicholas@2538 359 new_canvas.width = window.innerWidth - 420;
nicholas@2538 360 new_canvas.height = totalHeight;
nicholas@2538 361 for (var i in audioEngineContext.audioObjects) {
nicholas@2538 362 if (audioEngineContext.audioObjects[i].specification.type != 'outside-reference') {
nicholas@2538 363 audioEngineContext.audioObjects[i].interfaceDOM.resize(event);
nicholas@2538 364 }
nicholas@2538 365 }
nicholas@2538 366 document.getElementById("slider").style.height = totalHeight + 50 + 'px';
nicholas@2538 367 drawScale();
nickjillings@1343 368 }
nickjillings@1343 369
nicholas@2538 370 function drawScale() {
nicholas@2538 371 var interfaceObj = testState.currentStateMap.interfaces[0];
nicholas@2538 372 var scales = testState.currentStateMap.interfaces[0].scales;
nicholas@2538 373 scales = scales.sort(function (a, b) {
nicholas@2538 374 return a.position - b.position;
nicholas@2538 375 });
nicholas@2538 376 var canvas = document.getElementById('scale-canvas');
nicholas@2538 377 var ctx = canvas.getContext("2d");
nicholas@2538 378 var height = canvas.height;
nicholas@2538 379 var width = canvas.width;
nicholas@2538 380 var textHolder = document.getElementById('scale-text-holder');
nicholas@2538 381 textHolder.innerHTML = "";
nicholas@2538 382 ctx.fillStyle = "#000000";
nicholas@2538 383 ctx.setLineDash([1, 4]);
nicholas@2700 384 scales.forEach(function (scale) {
nicholas@2538 385 var posPercent = scale.position / 100.0;
nicholas@2538 386 var posPix = Math.round(width * posPercent);
nicholas@2538 387 if (posPix <= 0) {
nicholas@2538 388 posPix = 1;
nicholas@2538 389 }
nicholas@2538 390 if (posPix >= width) {
nicholas@2538 391 posPix = width - 1;
nicholas@2538 392 }
nicholas@2538 393 ctx.moveTo(posPix, 0);
nicholas@2538 394 ctx.lineTo(posPix, height);
nicholas@2538 395 ctx.stroke();
nicholas@2538 396
nicholas@2538 397 var text = document.createElement('div');
nicholas@2538 398 text.align = "center";
nicholas@2538 399 var textC = document.createElement('span');
nicholas@2538 400 textC.textContent = scale.text;
nicholas@2538 401 text.appendChild(textC);
nicholas@2538 402 text.className = "scale-text";
nicholas@2538 403 textHolder.appendChild(text);
nicholas@2538 404 text.style.width = Math.ceil($(text).width()) + 'px';
nicholas@2538 405 text.style.left = (posPix + 100 - ($(text).width() / 2)) + 'px';
nicholas@2700 406 });
nickjillings@1343 407 }
nickjillings@1343 408
nickjillings@1343 409 function buttonSubmitClick() // TODO: Only when all songs have been played!
nickjillings@1343 410 {
nicholas@2651 411 var checks = testState.currentStateMap.interfaces[0].options,
nicholas@2651 412 canContinue = true;
nickjillings@1343 413
nicholas@2538 414 // Check that the anchor and reference objects are correctly placed
nicholas@2700 415 if (interfaceContext.checkHiddenAnchor() === false) {
nicholas@2538 416 return;
nicholas@2538 417 }
nicholas@2700 418 if (interfaceContext.checkHiddenReference() === false) {
nicholas@2538 419 return;
nicholas@2538 420 }
nicholas@2538 421
nicholas@2538 422 for (var i = 0; i < checks.length; i++) {
nicholas@2700 423 var checkState = true;
nicholas@2538 424 if (checks[i].type == 'check') {
nicholas@2538 425 switch (checks[i].name) {
nicholas@2538 426 case 'fragmentPlayed':
nicholas@2538 427 // Check if all fragments have been played
n@2790 428 checkState = interfaceContext.checkAllPlayed(checks[i].errorMessage);
nicholas@2538 429 break;
nicholas@2538 430 case 'fragmentFullPlayback':
nicholas@2538 431 // Check all fragments have been played to their full length
n@2790 432 checkState = interfaceContext.checkAllPlayed(checks[i].errorMessage);
nicholas@2538 433 console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead');
nicholas@2538 434 break;
nicholas@2538 435 case 'fragmentMoved':
nicholas@2538 436 // Check all fragment sliders have been moved.
n@2790 437 checkState = interfaceContext.checkAllMoved(checks[i].errorMessage);
nicholas@2538 438 break;
nicholas@2538 439 case 'fragmentComments':
nicholas@2538 440 // Check all fragment sliders have been moved.
n@2790 441 checkState = interfaceContext.checkAllCommented(checks[i].errorMessage);
nicholas@2538 442 break;
nicholas@2538 443 case 'scalerange':
nicholas@2538 444 // Check the scale has been used effectively
n@2790 445 checkState = interfaceContext.checkScaleRange(checks[i].errorMessage);
nicholas@2700 446
nicholas@2538 447 break;
nicholas@2538 448 default:
nicholas@2538 449 console.log("WARNING - Check option " + checks[i].check + " is not supported on this interface");
nicholas@2538 450 break;
nicholas@2538 451 }
nicholas@2538 452 }
nicholas@2700 453 if (checkState === false) {
nicholas@2700 454 canContinue = false;
nicholas@2538 455 break;
nicholas@2538 456 }
nicholas@2538 457 }
nicholas@2538 458
nickjillings@1343 459 if (canContinue) {
nicholas@2538 460 if (audioEngineContext.status == 1) {
nicholas@2538 461 var playback = document.getElementById('playback-button');
nicholas@2538 462 playback.click();
nicholas@2538 463 // 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 464 } else {
nicholas@2700 465 if (audioEngineContext.timer.testStarted === false) {
nicholas@2538 466 interfaceContext.lightbox.post("Warning", 'You have not started the test! Please press start to begin the test!');
nicholas@2538 467 return;
nicholas@2538 468 }
nicholas@2538 469 }
nicholas@2538 470 testState.advanceState();
nicholas@2538 471 }
nickjillings@1343 472 }
nickjillings@1343 473
nicholas@2538 474 function pageXMLSave(store, pageSpecification) {
nicholas@2538 475 // MANDATORY
nicholas@2538 476 // Saves a specific test page
nicholas@2538 477 // You can use this space to add any extra nodes to your XML <audioHolder> saves
nicholas@2538 478 // Get the current <page> information in store (remember to appendChild your data to it)
nicholas@2538 479 // pageSpecification is the current page node configuration
nicholas@2538 480 // To create new XML nodes, use storage.document.createElement();
nicholas@2538 481 }