annotate interfaces/discrete.js @ 577:80e6cf42a17b Dev_main

WAC2016 review updated PDF
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 25 Feb 2016 11:57:24 +0000
parents 7567dda76333
children 640ffb822da1
rev   line source
n@474 1 // Once this is loaded and parsed, begin execution
n@474 2 loadInterface();
n@474 3
n@474 4 function loadInterface() {
n@474 5 // Use this to do any one-time page / element construction. For instance, placing any stationary text objects,
n@474 6 // holding div's, or setting up any nodes which are present for the entire test sequence
n@474 7
n@474 8 // The injection point into the HTML page
n@474 9 interfaceContext.insertPoint = document.getElementById("topLevelBody");
n@474 10 var testContent = document.createElement('div');
n@474 11 testContent.id = 'testContent';
n@474 12
n@474 13 // Create the top div for the Title element
n@474 14 var titleAttr = specification.title;
n@474 15 var title = document.createElement('div');
n@474 16 title.className = "title";
n@474 17 title.align = "center";
n@474 18 var titleSpan = document.createElement('span');
n@474 19
n@474 20 // Set title to that defined in XML, else set to default
n@474 21 if (titleAttr != undefined) {
n@474 22 titleSpan.textContent = titleAttr;
n@474 23 } else {
n@474 24 titleSpan.textContent = 'Listening test';
n@474 25 }
n@474 26 // Insert the titleSpan element into the title div element.
n@474 27 title.appendChild(titleSpan);
n@474 28
n@474 29 var pagetitle = document.createElement('div');
n@474 30 pagetitle.className = "pageTitle";
n@474 31 pagetitle.align = "center";
n@474 32 var titleSpan = document.createElement('span');
n@474 33 titleSpan.id = "pageTitle";
n@474 34 pagetitle.appendChild(titleSpan);
n@474 35
n@474 36 // Create Interface buttons!
n@474 37 var interfaceButtons = document.createElement('div');
n@474 38 interfaceButtons.id = 'interface-buttons';
n@474 39 interfaceButtons.style.height = '25px';
n@474 40
n@474 41 // Create playback start/stop points
n@474 42 var playback = document.createElement("button");
n@474 43 playback.innerHTML = 'Stop';
n@474 44 playback.id = 'playback-button';
n@474 45 playback.style.float = 'left';
n@474 46 // onclick function. Check if it is playing or not, call the correct function in the
n@474 47 // audioEngine, change the button text to reflect the next state.
n@474 48 playback.onclick = function() {
n@474 49 if (audioEngineContext.status == 1) {
n@474 50 audioEngineContext.stop();
n@474 51 this.innerHTML = 'Stop';
n@474 52 var time = audioEngineContext.timer.getTestTime();
n@474 53 console.log('Stopped at ' + time); // DEBUG/SAFETY
n@474 54 }
n@474 55 };
n@474 56 // Create Submit (save) button
n@474 57 var submit = document.createElement("button");
n@474 58 submit.innerHTML = 'Submit';
n@474 59 submit.onclick = buttonSubmitClick;
n@474 60 submit.id = 'submit-button';
n@474 61 submit.style.float = 'left';
n@474 62 // Append the interface buttons into the interfaceButtons object.
n@474 63 interfaceButtons.appendChild(playback);
n@474 64 interfaceButtons.appendChild(submit);
n@474 65
n@474 66 // Create a slider box
n@474 67 var sliderBox = document.createElement('div');
n@474 68 sliderBox.style.width = "100%";
n@474 69 sliderBox.style.height = window.innerHeight - 200+12 + 'px';
n@474 70 sliderBox.style.marginBottom = '10px';
n@474 71 sliderBox.id = 'slider';
n@474 72 var scaleHolder = document.createElement('div');
n@474 73 scaleHolder.id = "scale-holder";
n@474 74 scaleHolder.style.marginLeft = "107px";
n@474 75 sliderBox.appendChild(scaleHolder);
n@474 76 var scaleText = document.createElement('div');
n@474 77 scaleText.id = "scale-text-holder";
n@474 78 scaleText.style.height = "25px";
n@474 79 scaleText.style.width = "100%";
n@474 80 scaleHolder.appendChild(scaleText);
n@474 81 var scaleCanvas = document.createElement('canvas');
n@474 82 scaleCanvas.id = "scale-canvas";
n@475 83 scaleCanvas.style.marginLeft = "150px";
n@474 84 scaleHolder.appendChild(scaleCanvas);
n@474 85 var sliderObjectHolder = document.createElement('div');
n@474 86 sliderObjectHolder.id = 'slider-holder';
n@474 87 sliderObjectHolder.align = "center";
n@474 88 sliderBox.appendChild(sliderObjectHolder);
n@474 89
n@474 90 // Global parent for the comment boxes on the page
n@474 91 var feedbackHolder = document.createElement('div');
n@474 92 feedbackHolder.id = 'feedbackHolder';
n@474 93
n@474 94 testContent.style.zIndex = 1;
n@474 95 interfaceContext.insertPoint.innerHTML = null; // Clear the current schema
n@474 96
n@474 97 // Inject into HTML
n@474 98 testContent.appendChild(title); // Insert the title
n@474 99 testContent.appendChild(pagetitle);
n@474 100 testContent.appendChild(interfaceButtons);
n@474 101 testContent.appendChild(sliderBox);
n@474 102 testContent.appendChild(feedbackHolder);
n@474 103 interfaceContext.insertPoint.appendChild(testContent);
n@474 104
n@474 105 // Load the full interface
n@474 106 testState.initialise();
n@474 107 testState.advanceState();
n@474 108 };
n@474 109
n@474 110 function loadTest(page)
n@474 111 {
n@474 112 // Called each time a new test page is to be build. The page specification node is the only item passed in
n@474 113 var id = page.id;
n@474 114
n@474 115 var feedbackHolder = document.getElementById('feedbackHolder');
n@485 116 feedbackHolder.innerHTML = null;
n@474 117 var interfaceObj = page.interfaces;
n@474 118 if (interfaceObj.length > 1)
n@474 119 {
n@474 120 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
n@474 121 }
n@474 122 interfaceObj = interfaceObj[0];
n@474 123 if(interfaceObj.title != null)
n@474 124 {
n@474 125 document.getElementById("pageTitle").textContent = interfaceObj.title;
n@474 126 }
n@485 127
n@485 128 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options);
n@485 129 for (var option of interfaceOptions)
n@485 130 {
n@485 131 if (option.type == "show")
n@485 132 {
n@485 133 switch(option.name) {
n@485 134 case "playhead":
n@485 135 var playbackHolder = document.getElementById('playback-holder');
n@485 136 if (playbackHolder == null)
n@485 137 {
n@485 138 playbackHolder = document.createElement('div');
n@485 139 playbackHolder.style.width = "100%";
n@485 140 playbackHolder.align = 'center';
n@485 141 playbackHolder.appendChild(interfaceContext.playhead.object);
n@485 142 feedbackHolder.appendChild(playbackHolder);
n@485 143 }
n@485 144 break;
n@485 145 case "page-count":
n@485 146 var pagecountHolder = document.getElementById('page-count');
n@485 147 if (pagecountHolder == null)
n@485 148 {
n@485 149 pagecountHolder = document.createElement('div');
n@485 150 pagecountHolder.id = 'page-count';
n@485 151 }
n@559 152 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
n@485 153 var inject = document.getElementById('interface-buttons');
n@485 154 inject.appendChild(pagecountHolder);
n@485 155 break;
n@485 156 case "volume":
n@485 157 if (document.getElementById('master-volume-holder') == null)
n@485 158 {
n@485 159 feedbackHolder.appendChild(interfaceContext.volume.object);
n@485 160 }
n@485 161 break;
n@485 162 }
n@485 163 }
n@485 164 }
n@474 165
n@474 166 // Delete outside reference
n@474 167 var outsideReferenceHolder = document.getElementById('outside-reference');
n@474 168 if (outsideReferenceHolder != null) {
n@474 169 document.getElementById('interface-buttons').removeChild(outsideReferenceHolder);
n@474 170 }
n@474 171
n@474 172 var sliderBox = document.getElementById('slider-holder');
n@474 173 sliderBox.innerHTML = null;
n@474 174
n@474 175 var commentBoxPrefix = "Comment on track";
n@474 176 if (interfaceObj.commentBoxPrefix != undefined) {
n@474 177 commentBoxPrefix = interfaceObj.commentBoxPrefix;
n@474 178 }
n@474 179 var loopPlayback = page.loop;
n@474 180
n@474 181 $(page.commentQuestions).each(function(index,element) {
n@474 182 var node = interfaceContext.createCommentQuestion(element);
n@474 183 feedbackHolder.appendChild(node.holder);
n@474 184 });
n@474 185
n@474 186 // Find all the audioElements from the audioHolder
n@474 187 var label = 0;
n@475 188 var interfaceScales = testState.currentStateMap.interfaces[0].scales;
n@474 189 $(page.audioElements).each(function(index,element){
n@474 190 // Find URL of track
n@474 191 // In this jQuery loop, variable 'this' holds the current audioElement.
n@474 192
n@474 193 var audioObject = audioEngineContext.newTrack(element);
n@474 194 if (element.type == 'outside-reference')
n@474 195 {
n@474 196 // Construct outside reference;
n@474 197 var orNode = new outsideReferenceDOM(audioObject,index,document.getElementById('interface-buttons'));
n@474 198 audioObject.bindInterface(orNode);
n@474 199 } else {
n@474 200 // Create a slider per track
n@475 201 var sliderObj = new discreteObject(audioObject,label,interfaceScales);
n@474 202 sliderBox.appendChild(sliderObj.holder);
n@474 203 audioObject.bindInterface(sliderObj);
n@550 204 interfaceContext.commentBoxes.createCommentBox(audioObject);
n@474 205 label += 1;
n@474 206 }
n@474 207
n@474 208 });
n@474 209
n@496 210 if (page.showElementComments)
n@496 211 {
n@550 212 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder,true);
n@496 213 }
n@496 214
n@474 215 // Auto-align
n@474 216 resizeWindow(null);
n@474 217 }
n@474 218
n@475 219 function discreteObject(audioObject,label,interfaceScales)
n@474 220 {
n@474 221 // An example node, you can make this however you want for each audioElement.
n@474 222 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
n@474 223 // You attach them by calling audioObject.bindInterface( )
n@475 224 if (interfaceScales == null || interfaceScales.length == 0)
n@474 225 {
n@474 226 console.log("WARNING: The discrete radio's are built depending on the number of scale points specified! Ensure you have some specified. Defaulting to 5 for now!");
n@474 227 numOptions = 5;
n@474 228 }
n@474 229 this.parent = audioObject;
n@474 230
n@474 231 this.holder = document.createElement('div');
n@474 232 this.title = document.createElement('div');
n@474 233 this.discreteHolder = document.createElement('div');
n@474 234 this.discretes = [];
n@474 235 this.play = document.createElement('button');
n@474 236
n@474 237 this.holder.className = 'track-slider';
n@474 238 this.holder.style.width = window.innerWidth-200 + 'px';
n@474 239 this.holder.appendChild(this.title);
n@474 240 this.holder.appendChild(this.discreteHolder);
n@474 241 this.holder.appendChild(this.play);
n@474 242 this.holder.setAttribute('trackIndex',audioObject.id);
n@474 243 this.title.textContent = label;
n@474 244 this.title.className = 'track-slider-title';
n@474 245
n@474 246 this.discreteHolder.className = "track-slider-range";
n@475 247 this.discreteHolder.style.width = window.innerWidth-500 + 'px';
n@475 248 for (var i=0; i<interfaceScales.length; i++)
n@474 249 {
n@474 250 var node = document.createElement('input');
n@474 251 node.setAttribute('type','radio');
n@475 252 node.className = 'track-radio';
n@496 253 node.disabled = true;
n@475 254 node.setAttribute('position',interfaceScales[i].position);
n@474 255 node.setAttribute('name',audioObject.specification.id);
n@474 256 node.setAttribute('id',audioObject.specification.id+'-'+String(i));
n@474 257 this.discretes.push(node);
n@474 258 this.discreteHolder.appendChild(node);
n@475 259 node.onclick = function(event)
n@474 260 {
n@475 261 if (audioEngineContext.status == 0)
n@475 262 {
n@475 263 event.currentTarget.checked = false;
n@475 264 return;
n@475 265 }
n@474 266 var time = audioEngineContext.timer.getTestTime();
n@474 267 var id = Number(event.currentTarget.parentNode.parentNode.getAttribute('trackIndex'));
n@475 268 var value = event.currentTarget.getAttribute('position') / 100.0;
n@475 269 audioEngineContext.audioObjects[id].metric.moved(time,value);
n@475 270 console.log('slider '+id+' moved to '+value+' ('+time+')');
n@474 271 };
n@474 272 }
n@474 273
n@474 274 this.play.className = 'track-slider-button';
n@474 275 this.play.textContent = "Loading...";
n@474 276 this.play.value = audioObject.id;
n@474 277 this.play.disabled = true;
n@508 278 this.play.setAttribute("playstate","ready");
n@474 279 this.play.onclick = function(event)
n@474 280 {
n@474 281 var id = Number(event.currentTarget.value);
n@474 282 //audioEngineContext.metric.sliderPlayed(id);
n@508 283 if (event.currentTarget.getAttribute("playstate") == "ready")
n@508 284 audioEngineContext.play(id);
n@508 285 else if (event.currentTarget.getAttribute("playstate") == "playing")
n@508 286 audioEngineContext.stop();
n@474 287 };
n@474 288 this.resize = function(event)
n@474 289 {
n@474 290 this.holder.style.width = window.innerWidth-200 + 'px';
n@475 291 this.discreteHolder.style.width = window.innerWidth-500 + 'px';
n@475 292 //text.style.left = (posPix+150-($(text).width()/2)) +'px';
n@475 293 for (var i=0; i<this.discretes.length; i++)
n@475 294 {
n@475 295 var width = $(this.discreteHolder).width() - 20;
n@475 296 var node = this.discretes[i];
n@475 297 var nodeW = $(node).width();
n@475 298 var position = node.getAttribute('position');
n@475 299 var posPix = Math.round(width * (position / 100.0));
n@475 300 node.style.left = (posPix+10 - (nodeW/2)) + 'px';
n@475 301 }
n@474 302 };
n@474 303 this.enable = function()
n@474 304 {
n@474 305 // This is used to tell the interface object that playback of this node is ready
n@474 306 this.play.disabled = false;
n@474 307 this.play.textContent = "Play";
n@474 308 $(this.slider).removeClass('track-slider-disabled');
n@496 309 for (var radio of this.discretes)
n@496 310 {
n@496 311 radio.disabled = false;
n@496 312 }
n@474 313 };
n@474 314 this.updateLoading = function(progress)
n@474 315 {
n@474 316 // progress is a value from 0 to 100 indicating the current download state of media files
n@496 317 if (progress != 100)
n@496 318 {
n@496 319 progress = String(progress);
n@496 320 progress = progress.split('.')[0];
n@496 321 this.play.textContent = progress+'%';
n@496 322 } else {
n@496 323 this.play.textContent = "Play";
n@496 324 }
n@474 325 };
n@489 326
n@489 327 this.startPlayback = function()
n@489 328 {
n@489 329 // Called by audioObject when playback begins
n@508 330 this.play.setAttribute("playstate","playing");
n@489 331 $(".track-slider").removeClass('track-slider-playing');
n@489 332 $(this.holder).addClass('track-slider-playing');
n@489 333 var outsideReference = document.getElementById('outside-reference');
n@496 334 this.play.textContent = "Listening";
n@489 335 if (outsideReference != null) {
n@489 336 $(outsideReference).removeClass('track-slider-playing');
n@489 337 }
n@489 338 }
n@489 339 this.stopPlayback = function()
n@489 340 {
n@489 341 // Called by audioObject when playback stops
n@508 342 this.play.setAttribute("playstate","ready");
n@489 343 $(this.holder).removeClass('track-slider-playing');
n@496 344 this.play.textContent = "Play";
n@489 345 }
n@489 346
n@474 347 this.getValue = function()
n@474 348 {
n@475 349 // Return the current value of the object. If there is no value, return -1
n@475 350 var value = -1;
n@475 351 for (var i=0; i<this.discretes.length; i++)
n@475 352 {
n@475 353 if (this.discretes[i].checked == true)
n@475 354 {
n@475 355 value = this.discretes[i].getAttribute('position') / 100.0;
n@475 356 break;
n@475 357 }
n@475 358 }
n@475 359 return value;
n@474 360 };
n@474 361 this.getPresentedId = function()
n@474 362 {
n@474 363 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
n@474 364 return this.title.textContent;
n@474 365 };
n@474 366 this.canMove = function()
n@474 367 {
n@474 368 // Return either true or false if the interface object can be moved. AB / Reference cannot, whilst sliders can and therefore have a continuous scale.
n@474 369 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
n@474 370 return true;
n@474 371 };
n@474 372 this.exportXMLDOM = function(audioObject) {
n@474 373 // Called by the audioObject holding this element to export the interface <value> node.
n@474 374 // If there is no value node (such as outside reference), return null
n@474 375 // 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
n@474 376 // Use storage.document.createElement('value'); to generate the XML node.
n@475 377 var node = storage.document.createElement('value');
n@475 378 node.textContent = this.getValue();
n@475 379 return node;
n@474 380 };
n@546 381 this.error = function() {
n@546 382 // audioObject has an error!!
n@546 383 this.playback.textContent = "Error";
n@546 384 $(this.playback).addClass("error-colour");
n@546 385 }
n@474 386 };
n@474 387
n@521 388 function outsideReferenceDOM(audioObject,index,inject)
n@521 389 {
n@521 390 this.parent = audioObject;
n@521 391 this.outsideReferenceHolder = document.createElement('button');
n@521 392 this.outsideReferenceHolder.id = 'outside-reference';
n@521 393 this.outsideReferenceHolder.className = 'outside-reference';
n@521 394 this.outsideReferenceHolder.setAttribute('track-id',index);
n@521 395 this.outsideReferenceHolder.textContent = "Play Reference";
n@521 396 this.outsideReferenceHolder.disabled = true;
n@521 397
n@521 398 this.outsideReferenceHolder.onclick = function(event)
n@521 399 {
n@521 400 if (event.currentTarget.textContent == "Play Reference") {
n@521 401 audioEngineContext.play(event.currentTarget.getAttribute('track-id'));
n@521 402 } else {
n@521 403 audioEngineContext.stop();
n@521 404 }
n@521 405 };
n@521 406 inject.appendChild(this.outsideReferenceHolder);
n@521 407 this.enable = function()
n@521 408 {
n@521 409 if (this.parent.state == 1)
n@521 410 {
n@521 411 this.outsideReferenceHolder.disabled = false;
n@521 412 }
n@521 413 };
n@521 414 this.updateLoading = function(progress)
n@521 415 {
n@521 416 if (progress != 100)
n@521 417 {
n@521 418 progress = String(progress);
n@521 419 progress = progress.split('.')[0];
n@521 420 this.outsideReferenceHolder.textContent = progress+'%';
n@521 421 } else {
n@521 422 this.outsideReferenceHolder.textContent = "Play Reference";
n@521 423 }
n@521 424 };
n@521 425 this.startPlayback = function()
n@521 426 {
n@521 427 // Called when playback has begun
n@521 428 this.outsideReferenceHolder.style.backgroundColor = "rgb(255,100,100)";
n@521 429 this.outsideReferenceHolder.textContent = "Stop";
n@521 430 };
n@521 431 this.stopPlayback = function()
n@521 432 {
n@521 433 // Called when playback has stopped. This gets called even if playback never started!
n@521 434 $(this.outsideReferenceHolder).removeClass('track-slider-playing');
n@521 435 this.outsideReferenceHolder.style.backgroundColor = "";
n@521 436 this.outsideReferenceHolder.textContent = "Play Reference";
n@521 437 };
n@521 438 this.exportXMLDOM = function(audioObject)
n@521 439 {
n@521 440 return null;
n@521 441 };
n@521 442 this.getValue = function()
n@521 443 {
n@521 444 return 0;
n@521 445 };
n@521 446 this.getPresentedId = function()
n@521 447 {
n@521 448 return 'reference';
n@521 449 };
n@521 450 this.canMove = function()
n@521 451 {
n@521 452 return false;
n@521 453 };
n@546 454 this.error = function() {
n@546 455 // audioObject has an error!!
n@546 456 this.outsideReferenceHolder.textContent = "Error";
n@546 457 $(this.outsideReferenceHolder).addClass("error-colour");
n@546 458 }
n@521 459 }
n@521 460
n@474 461 function resizeWindow(event)
n@474 462 {
n@474 463 // Called on every window resize event, use this to scale your page properly
n@474 464 var numObj = document.getElementsByClassName('track-slider').length;
n@474 465 var totalHeight = (numObj * 66)-30;
n@474 466 document.getElementById('scale-holder').style.width = window.innerWidth-220 + 'px';
n@474 467 var canvas = document.getElementById('scale-canvas');
n@475 468 canvas.width = window.innerWidth-520;
n@474 469 canvas.height = totalHeight;
n@474 470 for (var i in audioEngineContext.audioObjects)
n@474 471 {
n@474 472 if (audioEngineContext.audioObjects[i].specification.type != 'outside-reference'){
n@474 473 audioEngineContext.audioObjects[i].interfaceDOM.resize(event);
n@474 474 }
n@474 475 }
n@483 476 document.getElementById('slider-holder').style.height = totalHeight + 'px';
n@483 477 document.getElementById('slider').style.height = totalHeight + 70 + 'px';
n@474 478 drawScale();
n@474 479 }
n@474 480
n@474 481 function drawScale()
n@474 482 {
n@474 483 var interfaceObj = testState.currentStateMap.interfaces[0];
n@474 484 var scales = testState.currentStateMap.interfaces[0].scales;
n@474 485 scales = scales.sort(function(a,b) {
n@474 486 return a.position - b.position;
n@474 487 });
n@474 488 var canvas = document.getElementById('scale-canvas');
n@474 489 var ctx = canvas.getContext("2d");
n@474 490 var height = canvas.height;
n@474 491 var width = canvas.width;
n@474 492 var textHolder = document.getElementById('scale-text-holder');
n@474 493 textHolder.innerHTML = null;
n@474 494 ctx.fillStyle = "#000000";
n@474 495 ctx.setLineDash([1,4]);
n@474 496 for (var scale of scales)
n@474 497 {
n@474 498 var posPercent = scale.position / 100.0;
n@474 499 var posPix = Math.round(width * posPercent);
n@474 500 if(posPix<=0){posPix=1;}
n@474 501 if(posPix>=width){posPix=width-1;}
n@474 502 ctx.moveTo(posPix,0);
n@474 503 ctx.lineTo(posPix,height);
n@474 504 ctx.stroke();
n@474 505
n@474 506 var text = document.createElement('div');
n@474 507 text.align = "center";
n@474 508 var textC = document.createElement('span');
n@474 509 textC.textContent = scale.text;
n@474 510 text.appendChild(textC);
n@474 511 text.className = "scale-text";
n@474 512 textHolder.appendChild(text);
n@475 513 text.style.width = $(text.children[0]).width()+'px';
n@475 514 text.style.left = (posPix+150-($(text).width()/2)) +'px';
n@474 515 }
n@474 516 }
n@474 517
n@474 518 function buttonSubmitClick() // TODO: Only when all songs have been played!
n@474 519 {
n@474 520 var checks = [];
n@474 521 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
n@474 522 checks = checks.concat(specification.interfaces.options);
n@474 523 var canContinue = true;
n@474 524
n@474 525 // Check that the anchor and reference objects are correctly placed
n@474 526 if (interfaceContext.checkHiddenAnchor() == false) {return;}
n@474 527 if (interfaceContext.checkHiddenReference() == false) {return;}
n@474 528
n@474 529 for (var i=0; i<checks.length; i++) {
n@474 530 if (checks[i].type == 'check')
n@474 531 {
n@474 532 switch(checks[i].name) {
n@474 533 case 'fragmentPlayed':
n@474 534 // Check if all fragments have been played
n@474 535 var checkState = interfaceContext.checkAllPlayed();
n@474 536 if (checkState == false) {canContinue = false;}
n@474 537 break;
n@474 538 case 'fragmentFullPlayback':
n@474 539 // Check all fragments have been played to their full length
n@474 540 var checkState = interfaceContext.checkAllPlayed();
n@474 541 if (checkState == false) {canContinue = false;}
n@474 542 console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead');
n@474 543 break;
n@474 544 case 'fragmentMoved':
n@474 545 // Check all fragment sliders have been moved.
n@474 546 var checkState = interfaceContext.checkAllMoved();
n@474 547 if (checkState == false) {canContinue = false;}
n@474 548 break;
n@474 549 case 'fragmentComments':
n@474 550 // Check all fragment sliders have been moved.
n@474 551 var checkState = interfaceContext.checkAllCommented();
n@474 552 if (checkState == false) {canContinue = false;}
n@474 553 break;
n@474 554 //case 'scalerange':
n@474 555 // Check the scale is used to its full width outlined by the node
n@474 556 //var checkState = interfaceContext.checkScaleRange();
n@474 557 //if (checkState == false) {canContinue = false;}
n@474 558 // break;
n@474 559 default:
n@474 560 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
n@474 561 break;
n@474 562 }
n@474 563
n@474 564 }
n@474 565 if (!canContinue) {break;}
n@474 566 }
n@474 567
n@474 568 if (canContinue) {
n@474 569 if (audioEngineContext.status == 1) {
n@474 570 var playback = document.getElementById('playback-button');
n@474 571 playback.click();
n@474 572 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
n@474 573 } else
n@474 574 {
n@474 575 if (audioEngineContext.timer.testStarted == false)
n@474 576 {
n@474 577 alert('You have not started the test! Please press start to begin the test!');
n@474 578 return;
n@474 579 }
n@474 580 }
n@474 581 testState.advanceState();
n@474 582 }
n@474 583 }
n@474 584
n@474 585 function pageXMLSave(store, pageSpecification)
n@474 586 {
n@474 587 // MANDATORY
n@474 588 // Saves a specific test page
n@474 589 // You can use this space to add any extra nodes to your XML <audioHolder> saves
n@474 590 // Get the current <page> information in store (remember to appendChild your data to it)
n@474 591 // pageSpecification is the current page node configuration
n@474 592 // To create new XML nodes, use storage.document.createElement();
n@474 593 }