annotate interfaces/discrete.js @ 630:9dcfd654abad Dev_main

Fixed analysis.js table and latex generators.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Mon, 21 Mar 2016 16:07:57 +0000
parents 640ffb822da1
children 80582bdf9d12 501997c0f61f
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@603 58 submit.innerHTML = 'Next';
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@603 187 var index = 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@603 201 switch(audioObject.specification.parent.label) {
n@603 202 case "none":
n@603 203 label = "";
n@603 204 break;
n@603 205 case "letter":
n@603 206 label = String.fromCharCode(97 + index);
n@603 207 break;
n@603 208 case "capital":
n@603 209 label = String.fromCharCode(65 + index);
n@603 210 break;
n@603 211 default:
n@603 212 label = ""+index;
n@603 213 break;
n@603 214 }
n@475 215 var sliderObj = new discreteObject(audioObject,label,interfaceScales);
n@474 216 sliderBox.appendChild(sliderObj.holder);
n@474 217 audioObject.bindInterface(sliderObj);
n@550 218 interfaceContext.commentBoxes.createCommentBox(audioObject);
n@603 219 index += 1;
n@474 220 }
n@474 221
n@474 222 });
n@474 223
n@496 224 if (page.showElementComments)
n@496 225 {
n@550 226 interfaceContext.commentBoxes.showCommentBoxes(feedbackHolder,true);
n@496 227 }
n@496 228
n@474 229 // Auto-align
n@474 230 resizeWindow(null);
n@474 231 }
n@474 232
n@475 233 function discreteObject(audioObject,label,interfaceScales)
n@474 234 {
n@474 235 // An example node, you can make this however you want for each audioElement.
n@474 236 // However, every audioObject (audioEngineContext.audioObject) MUST have an interface object with the following
n@474 237 // You attach them by calling audioObject.bindInterface( )
n@475 238 if (interfaceScales == null || interfaceScales.length == 0)
n@474 239 {
n@474 240 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 241 numOptions = 5;
n@474 242 }
n@474 243 this.parent = audioObject;
n@474 244
n@474 245 this.holder = document.createElement('div');
n@474 246 this.title = document.createElement('div');
n@474 247 this.discreteHolder = document.createElement('div');
n@474 248 this.discretes = [];
n@474 249 this.play = document.createElement('button');
n@474 250
n@474 251 this.holder.className = 'track-slider';
n@474 252 this.holder.style.width = window.innerWidth-200 + 'px';
n@474 253 this.holder.appendChild(this.title);
n@474 254 this.holder.appendChild(this.discreteHolder);
n@474 255 this.holder.appendChild(this.play);
n@474 256 this.holder.setAttribute('trackIndex',audioObject.id);
n@474 257 this.title.textContent = label;
n@474 258 this.title.className = 'track-slider-title';
n@474 259
n@474 260 this.discreteHolder.className = "track-slider-range";
n@475 261 this.discreteHolder.style.width = window.innerWidth-500 + 'px';
n@475 262 for (var i=0; i<interfaceScales.length; i++)
n@474 263 {
n@474 264 var node = document.createElement('input');
n@474 265 node.setAttribute('type','radio');
n@475 266 node.className = 'track-radio';
n@496 267 node.disabled = true;
n@475 268 node.setAttribute('position',interfaceScales[i].position);
n@474 269 node.setAttribute('name',audioObject.specification.id);
n@474 270 node.setAttribute('id',audioObject.specification.id+'-'+String(i));
n@474 271 this.discretes.push(node);
n@474 272 this.discreteHolder.appendChild(node);
n@475 273 node.onclick = function(event)
n@474 274 {
n@475 275 if (audioEngineContext.status == 0)
n@475 276 {
n@475 277 event.currentTarget.checked = false;
n@475 278 return;
n@475 279 }
n@474 280 var time = audioEngineContext.timer.getTestTime();
n@474 281 var id = Number(event.currentTarget.parentNode.parentNode.getAttribute('trackIndex'));
n@475 282 var value = event.currentTarget.getAttribute('position') / 100.0;
n@475 283 audioEngineContext.audioObjects[id].metric.moved(time,value);
n@475 284 console.log('slider '+id+' moved to '+value+' ('+time+')');
n@474 285 };
n@474 286 }
n@474 287
n@474 288 this.play.className = 'track-slider-button';
n@474 289 this.play.textContent = "Loading...";
n@474 290 this.play.value = audioObject.id;
n@474 291 this.play.disabled = true;
n@508 292 this.play.setAttribute("playstate","ready");
n@474 293 this.play.onclick = function(event)
n@474 294 {
n@474 295 var id = Number(event.currentTarget.value);
n@474 296 //audioEngineContext.metric.sliderPlayed(id);
n@508 297 if (event.currentTarget.getAttribute("playstate") == "ready")
n@508 298 audioEngineContext.play(id);
n@508 299 else if (event.currentTarget.getAttribute("playstate") == "playing")
n@508 300 audioEngineContext.stop();
n@474 301 };
n@474 302 this.resize = function(event)
n@474 303 {
n@474 304 this.holder.style.width = window.innerWidth-200 + 'px';
n@475 305 this.discreteHolder.style.width = window.innerWidth-500 + 'px';
n@475 306 //text.style.left = (posPix+150-($(text).width()/2)) +'px';
n@475 307 for (var i=0; i<this.discretes.length; i++)
n@475 308 {
n@475 309 var width = $(this.discreteHolder).width() - 20;
n@475 310 var node = this.discretes[i];
n@475 311 var nodeW = $(node).width();
n@475 312 var position = node.getAttribute('position');
n@475 313 var posPix = Math.round(width * (position / 100.0));
n@475 314 node.style.left = (posPix+10 - (nodeW/2)) + 'px';
n@475 315 }
n@474 316 };
n@474 317 this.enable = function()
n@474 318 {
n@474 319 // This is used to tell the interface object that playback of this node is ready
n@474 320 this.play.disabled = false;
n@474 321 this.play.textContent = "Play";
n@474 322 $(this.slider).removeClass('track-slider-disabled');
n@496 323 for (var radio of this.discretes)
n@496 324 {
n@496 325 radio.disabled = false;
n@496 326 }
n@474 327 };
n@474 328 this.updateLoading = function(progress)
n@474 329 {
n@474 330 // progress is a value from 0 to 100 indicating the current download state of media files
n@496 331 if (progress != 100)
n@496 332 {
n@496 333 progress = String(progress);
n@496 334 progress = progress.split('.')[0];
n@496 335 this.play.textContent = progress+'%';
n@496 336 } else {
n@496 337 this.play.textContent = "Play";
n@496 338 }
n@474 339 };
n@489 340
n@489 341 this.startPlayback = function()
n@489 342 {
n@489 343 // Called by audioObject when playback begins
n@508 344 this.play.setAttribute("playstate","playing");
n@489 345 $(".track-slider").removeClass('track-slider-playing');
n@489 346 $(this.holder).addClass('track-slider-playing');
n@489 347 var outsideReference = document.getElementById('outside-reference');
n@496 348 this.play.textContent = "Listening";
n@489 349 if (outsideReference != null) {
n@489 350 $(outsideReference).removeClass('track-slider-playing');
n@489 351 }
n@489 352 }
n@489 353 this.stopPlayback = function()
n@489 354 {
n@489 355 // Called by audioObject when playback stops
n@508 356 this.play.setAttribute("playstate","ready");
n@489 357 $(this.holder).removeClass('track-slider-playing');
n@496 358 this.play.textContent = "Play";
n@489 359 }
n@489 360
n@474 361 this.getValue = function()
n@474 362 {
n@475 363 // Return the current value of the object. If there is no value, return -1
n@475 364 var value = -1;
n@475 365 for (var i=0; i<this.discretes.length; i++)
n@475 366 {
n@475 367 if (this.discretes[i].checked == true)
n@475 368 {
n@475 369 value = this.discretes[i].getAttribute('position') / 100.0;
n@475 370 break;
n@475 371 }
n@475 372 }
n@475 373 return value;
n@474 374 };
n@474 375 this.getPresentedId = function()
n@474 376 {
n@474 377 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
n@474 378 return this.title.textContent;
n@474 379 };
n@474 380 this.canMove = function()
n@474 381 {
n@474 382 // 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 383 // These are checked primarily if the interface check option 'fragmentMoved' is enabled.
n@474 384 return true;
n@474 385 };
n@474 386 this.exportXMLDOM = function(audioObject) {
n@474 387 // Called by the audioObject holding this element to export the interface <value> node.
n@474 388 // If there is no value node (such as outside reference), return null
n@474 389 // 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 390 // Use storage.document.createElement('value'); to generate the XML node.
n@475 391 var node = storage.document.createElement('value');
n@475 392 node.textContent = this.getValue();
n@475 393 return node;
n@474 394 };
n@546 395 this.error = function() {
n@546 396 // audioObject has an error!!
n@546 397 this.playback.textContent = "Error";
n@546 398 $(this.playback).addClass("error-colour");
n@546 399 }
n@474 400 };
n@474 401
n@521 402 function outsideReferenceDOM(audioObject,index,inject)
n@521 403 {
n@521 404 this.parent = audioObject;
n@521 405 this.outsideReferenceHolder = document.createElement('button');
n@521 406 this.outsideReferenceHolder.id = 'outside-reference';
n@521 407 this.outsideReferenceHolder.className = 'outside-reference';
n@521 408 this.outsideReferenceHolder.setAttribute('track-id',index);
n@521 409 this.outsideReferenceHolder.textContent = "Play Reference";
n@521 410 this.outsideReferenceHolder.disabled = true;
n@521 411
n@521 412 this.outsideReferenceHolder.onclick = function(event)
n@521 413 {
n@521 414 if (event.currentTarget.textContent == "Play Reference") {
n@521 415 audioEngineContext.play(event.currentTarget.getAttribute('track-id'));
n@521 416 } else {
n@521 417 audioEngineContext.stop();
n@521 418 }
n@521 419 };
n@521 420 inject.appendChild(this.outsideReferenceHolder);
n@521 421 this.enable = function()
n@521 422 {
n@521 423 if (this.parent.state == 1)
n@521 424 {
n@521 425 this.outsideReferenceHolder.disabled = false;
n@521 426 }
n@521 427 };
n@521 428 this.updateLoading = function(progress)
n@521 429 {
n@521 430 if (progress != 100)
n@521 431 {
n@521 432 progress = String(progress);
n@521 433 progress = progress.split('.')[0];
n@521 434 this.outsideReferenceHolder.textContent = progress+'%';
n@521 435 } else {
n@521 436 this.outsideReferenceHolder.textContent = "Play Reference";
n@521 437 }
n@521 438 };
n@521 439 this.startPlayback = function()
n@521 440 {
n@521 441 // Called when playback has begun
n@521 442 this.outsideReferenceHolder.style.backgroundColor = "rgb(255,100,100)";
n@521 443 this.outsideReferenceHolder.textContent = "Stop";
n@521 444 };
n@521 445 this.stopPlayback = function()
n@521 446 {
n@521 447 // Called when playback has stopped. This gets called even if playback never started!
n@521 448 $(this.outsideReferenceHolder).removeClass('track-slider-playing');
n@521 449 this.outsideReferenceHolder.style.backgroundColor = "";
n@521 450 this.outsideReferenceHolder.textContent = "Play Reference";
n@521 451 };
n@521 452 this.exportXMLDOM = function(audioObject)
n@521 453 {
n@521 454 return null;
n@521 455 };
n@521 456 this.getValue = function()
n@521 457 {
n@521 458 return 0;
n@521 459 };
n@521 460 this.getPresentedId = function()
n@521 461 {
n@521 462 return 'reference';
n@521 463 };
n@521 464 this.canMove = function()
n@521 465 {
n@521 466 return false;
n@521 467 };
n@546 468 this.error = function() {
n@546 469 // audioObject has an error!!
n@546 470 this.outsideReferenceHolder.textContent = "Error";
n@546 471 $(this.outsideReferenceHolder).addClass("error-colour");
n@546 472 }
n@521 473 }
n@521 474
n@474 475 function resizeWindow(event)
n@474 476 {
n@474 477 // Called on every window resize event, use this to scale your page properly
n@474 478 var numObj = document.getElementsByClassName('track-slider').length;
n@474 479 var totalHeight = (numObj * 66)-30;
n@474 480 document.getElementById('scale-holder').style.width = window.innerWidth-220 + 'px';
n@474 481 var canvas = document.getElementById('scale-canvas');
n@475 482 canvas.width = window.innerWidth-520;
n@474 483 canvas.height = totalHeight;
n@474 484 for (var i in audioEngineContext.audioObjects)
n@474 485 {
n@474 486 if (audioEngineContext.audioObjects[i].specification.type != 'outside-reference'){
n@474 487 audioEngineContext.audioObjects[i].interfaceDOM.resize(event);
n@474 488 }
n@474 489 }
n@483 490 document.getElementById('slider-holder').style.height = totalHeight + 'px';
n@483 491 document.getElementById('slider').style.height = totalHeight + 70 + 'px';
n@474 492 drawScale();
n@474 493 }
n@474 494
n@474 495 function drawScale()
n@474 496 {
n@474 497 var interfaceObj = testState.currentStateMap.interfaces[0];
n@474 498 var scales = testState.currentStateMap.interfaces[0].scales;
n@474 499 scales = scales.sort(function(a,b) {
n@474 500 return a.position - b.position;
n@474 501 });
n@474 502 var canvas = document.getElementById('scale-canvas');
n@474 503 var ctx = canvas.getContext("2d");
n@474 504 var height = canvas.height;
n@474 505 var width = canvas.width;
n@474 506 var textHolder = document.getElementById('scale-text-holder');
n@474 507 textHolder.innerHTML = null;
n@474 508 ctx.fillStyle = "#000000";
n@474 509 ctx.setLineDash([1,4]);
n@474 510 for (var scale of scales)
n@474 511 {
n@474 512 var posPercent = scale.position / 100.0;
n@474 513 var posPix = Math.round(width * posPercent);
n@474 514 if(posPix<=0){posPix=1;}
n@474 515 if(posPix>=width){posPix=width-1;}
n@474 516 ctx.moveTo(posPix,0);
n@474 517 ctx.lineTo(posPix,height);
n@474 518 ctx.stroke();
n@474 519
n@474 520 var text = document.createElement('div');
n@474 521 text.align = "center";
n@474 522 var textC = document.createElement('span');
n@474 523 textC.textContent = scale.text;
n@474 524 text.appendChild(textC);
n@474 525 text.className = "scale-text";
n@474 526 textHolder.appendChild(text);
n@475 527 text.style.width = $(text.children[0]).width()+'px';
n@475 528 text.style.left = (posPix+150-($(text).width()/2)) +'px';
n@474 529 }
n@474 530 }
n@474 531
n@474 532 function buttonSubmitClick() // TODO: Only when all songs have been played!
n@474 533 {
n@474 534 var checks = [];
n@474 535 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
n@474 536 checks = checks.concat(specification.interfaces.options);
n@474 537 var canContinue = true;
n@474 538
n@474 539 // Check that the anchor and reference objects are correctly placed
n@474 540 if (interfaceContext.checkHiddenAnchor() == false) {return;}
n@474 541 if (interfaceContext.checkHiddenReference() == false) {return;}
n@474 542
n@474 543 for (var i=0; i<checks.length; i++) {
n@474 544 if (checks[i].type == 'check')
n@474 545 {
n@474 546 switch(checks[i].name) {
n@474 547 case 'fragmentPlayed':
n@474 548 // Check if all fragments have been played
n@474 549 var checkState = interfaceContext.checkAllPlayed();
n@474 550 if (checkState == false) {canContinue = false;}
n@474 551 break;
n@474 552 case 'fragmentFullPlayback':
n@474 553 // Check all fragments have been played to their full length
n@474 554 var checkState = interfaceContext.checkAllPlayed();
n@474 555 if (checkState == false) {canContinue = false;}
n@474 556 console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead');
n@474 557 break;
n@474 558 case 'fragmentMoved':
n@474 559 // Check all fragment sliders have been moved.
n@474 560 var checkState = interfaceContext.checkAllMoved();
n@474 561 if (checkState == false) {canContinue = false;}
n@474 562 break;
n@474 563 case 'fragmentComments':
n@474 564 // Check all fragment sliders have been moved.
n@474 565 var checkState = interfaceContext.checkAllCommented();
n@474 566 if (checkState == false) {canContinue = false;}
n@474 567 break;
n@474 568 //case 'scalerange':
n@474 569 // Check the scale is used to its full width outlined by the node
n@474 570 //var checkState = interfaceContext.checkScaleRange();
n@474 571 //if (checkState == false) {canContinue = false;}
n@474 572 // break;
n@474 573 default:
n@474 574 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
n@474 575 break;
n@474 576 }
n@474 577
n@474 578 }
n@474 579 if (!canContinue) {break;}
n@474 580 }
n@474 581
n@474 582 if (canContinue) {
n@474 583 if (audioEngineContext.status == 1) {
n@474 584 var playback = document.getElementById('playback-button');
n@474 585 playback.click();
n@474 586 // 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 587 } else
n@474 588 {
n@474 589 if (audioEngineContext.timer.testStarted == false)
n@474 590 {
n@474 591 alert('You have not started the test! Please press start to begin the test!');
n@474 592 return;
n@474 593 }
n@474 594 }
n@474 595 testState.advanceState();
n@474 596 }
n@474 597 }
n@474 598
n@474 599 function pageXMLSave(store, pageSpecification)
n@474 600 {
n@474 601 // MANDATORY
n@474 602 // Saves a specific test page
n@474 603 // You can use this space to add any extra nodes to your XML <audioHolder> saves
n@474 604 // Get the current <page> information in store (remember to appendChild your data to it)
n@474 605 // pageSpecification is the current page node configuration
n@474 606 // To create new XML nodes, use storage.document.createElement();
n@474 607 }