annotate interfaces/AB.js @ 2532:829a67368dc4

Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author www-data <www-data@sucuk.dcs.qmul.ac.uk>
date Wed, 09 Nov 2016 15:21:01 +0000
parents 42abe6eddfb5
children 464c6c6692d6 249a1152e525
rev   line source
nickjillings@1341 1 // Once this is loaded and parsed, begin execution
nickjillings@1341 2 loadInterface();
nickjillings@1341 3
nickjillings@1341 4 function loadInterface() {
nickjillings@1341 5 // Get the dimensions of the screen available to the page
nickjillings@1341 6 var width = window.innerWidth;
nickjillings@1341 7 var height = window.innerHeight;
nicholas@2381 8 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
nickjillings@1341 9
nickjillings@2110 10 // Custom comparator Object
nickjillings@2110 11 Interface.prototype.comparator = null;
nicholas@2359 12
nicholas@2359 13 Interface.prototype.checkScaleRange = function(min, max) {
nicholas@2359 14 var page = testState.getCurrentTestPage();
nicholas@2359 15 var audioObjects = audioEngineContext.audioObjects;
nicholas@2359 16 var state = true;
nicholas@2359 17 var str = "Please keep listening. ";
nicholas@2359 18 var minRanking = Infinity;
nicholas@2359 19 var maxRanking = -Infinity;
nicholas@2359 20 for (var ao of audioObjects) {
nicholas@2359 21 var rank = ao.interfaceDOM.getValue();
nicholas@2359 22 if (rank < minRanking) {minRanking = rank;}
nicholas@2359 23 if (rank > maxRanking) {maxRanking = rank;}
nicholas@2359 24 }
nicholas@2359 25 if (maxRanking*100 < max) {
nicholas@2359 26 str += "At least one fragment must be selected."
nicholas@2359 27 state = false;
nicholas@2359 28 }
nicholas@2359 29 if (!state) {
nicholas@2359 30 console.log(str);
nicholas@2359 31 this.storeErrorNode(str);
nicholas@2362 32 interfaceContext.lightbox.post("Message",str);
nicholas@2359 33 }
nicholas@2359 34 return state;
nicholas@2359 35 }
nickjillings@1341 36
nickjillings@1341 37 // The injection point into the HTML page
nickjillings@1341 38 interfaceContext.insertPoint = document.getElementById("topLevelBody");
nickjillings@1341 39 var testContent = document.createElement('div');
nickjillings@1341 40 testContent.id = 'testContent';
nickjillings@1341 41
nickjillings@1341 42 // Create the top div for the Title element
nickjillings@1341 43 var titleAttr = specification.title;
nickjillings@1341 44 var title = document.createElement('div');
nickjillings@1341 45 title.className = "title";
nickjillings@1341 46 title.align = "center";
nickjillings@1341 47 var titleSpan = document.createElement('span');
nicholas@2470 48 titleSpan.id = "test-title";
nickjillings@1341 49
nickjillings@1341 50 // Set title to that defined in XML, else set to default
nickjillings@1341 51 if (titleAttr != undefined) {
nickjillings@1341 52 titleSpan.textContent = titleAttr;
nickjillings@1341 53 } else {
nickjillings@1341 54 titleSpan.textContent = 'Listening test';
nickjillings@1341 55 }
nickjillings@1341 56 // Insert the titleSpan element into the title div element.
nickjillings@1341 57 title.appendChild(titleSpan);
nickjillings@1341 58
nickjillings@1341 59 var pagetitle = document.createElement('div');
nickjillings@1341 60 pagetitle.className = "pageTitle";
nickjillings@1341 61 pagetitle.align = "center";
nickjillings@1341 62 var titleSpan = document.createElement('span');
nickjillings@1341 63 titleSpan.id = "pageTitle";
nickjillings@1341 64 pagetitle.appendChild(titleSpan);
nickjillings@1341 65
nickjillings@1341 66 // Create Interface buttons!
nickjillings@1341 67 var interfaceButtons = document.createElement('div');
nickjillings@1341 68 interfaceButtons.id = 'interface-buttons';
nickjillings@1341 69 interfaceButtons.style.height = '25px';
nickjillings@1341 70
nickjillings@1341 71 // Create playback start/stop points
nickjillings@1341 72 var playback = document.createElement("button");
nickjillings@1341 73 playback.innerHTML = 'Stop';
nickjillings@1341 74 playback.id = 'playback-button';
nickjillings@1341 75 playback.style.float = 'left';
nickjillings@1341 76 // onclick function. Check if it is playing or not, call the correct function in the
nickjillings@1341 77 // audioEngine, change the button text to reflect the next state.
nickjillings@1341 78 playback.onclick = function() {
nickjillings@1341 79 if (audioEngineContext.status == 1) {
nickjillings@1341 80 audioEngineContext.stop();
nickjillings@1341 81 this.innerHTML = 'Stop';
nickjillings@1341 82 var time = audioEngineContext.timer.getTestTime();
nickjillings@1341 83 console.log('Stopped at ' + time); // DEBUG/SAFETY
nickjillings@1341 84 }
nickjillings@1341 85 };
nickjillings@1341 86 // Append the interface buttons into the interfaceButtons object.
nickjillings@1341 87 interfaceButtons.appendChild(playback);
nickjillings@1341 88
nickjillings@1341 89 // Global parent for the comment boxes on the page
nickjillings@1341 90 var feedbackHolder = document.createElement('div');
nickjillings@1341 91 feedbackHolder.id = 'feedbackHolder';
nicholas@2396 92
nicholas@2396 93 // Create outside reference holder
nicholas@2396 94 var outsideRef = document.createElement("div");
nicholas@2396 95 outsideRef.id = "outside-reference-holder";
nickjillings@1341 96
nickjillings@1341 97 // Construct the AB Boxes
nickjillings@1341 98 var boxes = document.createElement('div');
nickjillings@1341 99 boxes.align = "center";
nickjillings@1341 100 boxes.id = "box-holders";
nickjillings@1341 101 boxes.style.float = "left";
nickjillings@1341 102
nickjillings@1341 103 var submit = document.createElement('button');
nickjillings@1341 104 submit.id = "submit";
nickjillings@1341 105 submit.onclick = buttonSubmitClick;
nickjillings@1341 106 submit.className = "big-button";
nickjillings@1341 107 submit.textContent = "submit";
nickjillings@1341 108 submit.style.position = "relative";
nickjillings@1341 109 submit.style.left = (window.innerWidth-250)/2 + 'px';
nickjillings@1341 110
nickjillings@1341 111 feedbackHolder.appendChild(boxes);
nicholas@2475 112
nicholas@2475 113 // Create holder for comment boxes
nicholas@2475 114 var comments = document.createElement("div");
nicholas@2475 115 comments.id = "comment-box-holder";
nickjillings@1341 116
nickjillings@1341 117 // Inject into HTML
nickjillings@1341 118 testContent.appendChild(title); // Insert the title
nickjillings@1341 119 testContent.appendChild(pagetitle);
nickjillings@1341 120 testContent.appendChild(interfaceButtons);
nicholas@2396 121 testContent.appendChild(outsideRef);
nickjillings@1341 122 testContent.appendChild(feedbackHolder);
nickjillings@1341 123 testContent.appendChild(submit);
nicholas@2475 124 testContent.appendChild(comments);
nickjillings@1341 125 interfaceContext.insertPoint.appendChild(testContent);
nickjillings@1341 126
nickjillings@1341 127 // Load the full interface
nickjillings@1341 128 testState.initialise();
nickjillings@1341 129 testState.advanceState();
nickjillings@1341 130 }
nickjillings@1341 131
nickjillings@1341 132 function loadTest(audioHolderObject)
nickjillings@1341 133 {
nickjillings@1341 134 var feedbackHolder = document.getElementById('feedbackHolder');
nickjillings@1341 135 var interfaceObj = audioHolderObject.interfaces;
nickjillings@1341 136 if (interfaceObj.length > 1)
nickjillings@1341 137 {
nickjillings@1341 138 console.log("WARNING - This interface only supports one <interface> node per page. Using first interface node");
nickjillings@1341 139 }
nickjillings@1341 140 interfaceObj = interfaceObj[0];
nicholas@2392 141
nicholas@2475 142 var commentHolder = document.getElementById('comment-box-holder');
nicholas@2475 143 commentHolder.innerHTML = "";
nicholas@2475 144
nicholas@2396 145 // Delete outside reference
nicholas@2396 146 var outsideReferenceHolder = document.getElementById("outside-reference-holder");
nicholas@2396 147 outsideReferenceHolder.innerHTML = "";
nicholas@2470 148
nicholas@2470 149 // Set the page title
nicholas@2470 150 if (typeof audioHolderObject.title == "string" && audioHolderObject.title.length > 0) {
nicholas@2470 151 document.getElementById("test-title").textContent = audioHolderObject.title
nicholas@2470 152 }
nickjillings@1341 153
nickjillings@1341 154 if(interfaceObj.title != null)
nickjillings@1341 155 {
nickjillings@1341 156 document.getElementById("pageTitle").textContent = interfaceObj.title;
nickjillings@1341 157 }
nickjillings@1356 158
nickjillings@1356 159 var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options);
nicholas@2394 160 // Clear the interfaceElements
nicholas@2394 161 {
nicholas@2394 162 var node = document.getElementById('playback-holder');
nicholas@2394 163 if (node){feedbackHolder.removeChild(node);}
nicholas@2394 164 node = document.getElementById('page-count');
nicholas@2394 165 if (node){document.getElementById('interface-buttons').removeChild(node);}
nicholas@2394 166 node = document.getElementById('master-volume-holder-float');
nicholas@2394 167 if (node){feedbackHolder.removeChild(node);}
nicholas@2394 168 }
nicholas@2394 169
n@2407 170 // Populate the comparator object
n@2407 171 interfaceContext.comparator = new comparator(audioHolderObject);
n@2407 172
nickjillings@1356 173 for (var option of interfaceOptions)
nickjillings@1356 174 {
nickjillings@1356 175 if (option.type == "show")
nickjillings@1356 176 {
nickjillings@1356 177 switch(option.name) {
nickjillings@1356 178 case "playhead":
nickjillings@1356 179 var playbackHolder = document.getElementById('playback-holder');
nickjillings@1356 180 if (playbackHolder == null)
nickjillings@1356 181 {
nickjillings@1356 182 playbackHolder = document.createElement('div');
nicholas@2394 183 playbackHolder.id = 'playback-holder';
nickjillings@1356 184 playbackHolder.style.width = "100%";
nickjillings@1356 185 playbackHolder.style.float = "left";
nickjillings@1356 186 playbackHolder.align = 'center';
nickjillings@1356 187 playbackHolder.appendChild(interfaceContext.playhead.object);
nickjillings@1356 188 feedbackHolder.appendChild(playbackHolder);
nickjillings@1356 189 }
nickjillings@1356 190 break;
nickjillings@1356 191 case "page-count":
nickjillings@1356 192 var pagecountHolder = document.getElementById('page-count');
nickjillings@1356 193 if (pagecountHolder == null)
nickjillings@1356 194 {
nickjillings@1356 195 pagecountHolder = document.createElement('div');
nickjillings@1356 196 pagecountHolder.id = 'page-count';
nicholas@2393 197 document.getElementById('interface-buttons').appendChild(pagecountHolder);
nickjillings@1356 198 }
nickjillings@2125 199 pagecountHolder.innerHTML = '<span>Page '+(testState.stateIndex+1)+' of '+testState.stateMap.length+'</span>';
nickjillings@1356 200 break;
nickjillings@1356 201 case "volume":
nicholas@2394 202 if (document.getElementById('master-volume-holder-float') == null)
nickjillings@1356 203 {
nickjillings@1356 204 feedbackHolder.appendChild(interfaceContext.volume.object);
nickjillings@1356 205 }
nickjillings@1356 206 break;
n@2407 207 case "comments":
n@2407 208 // Generate one comment box per presented page
n@2407 209 for (var element of audioEngineContext.audioObjects)
n@2407 210 {
n@2407 211 interfaceContext.commentBoxes.createCommentBox(element);
n@2407 212 }
n@2407 213 interfaceContext.commentBoxes.showCommentBoxes(commentHolder,true);
n@2407 214 break;
nickjillings@1356 215 }
nickjillings@1356 216 }
nickjillings@1356 217 }
nicholas@2356 218
nicholas@2356 219 $(audioHolderObject.commentQuestions).each(function(index,element) {
nicholas@2356 220 var node = interfaceContext.createCommentQuestion(element);
nicholas@2475 221 commentHolder.appendChild(node.holder);
nicholas@2356 222 });
n@2407 223
n@2407 224 resizeWindow(null);
nickjillings@1341 225 }
nickjillings@1341 226
nickjillings@2110 227 function comparator(audioHolderObject)
nickjillings@1341 228 {
nickjillings@2110 229 this.comparatorBox = function(audioElement,id,text)
nickjillings@1341 230 {
nickjillings@1341 231 this.parent = audioElement;
nickjillings@1341 232 this.id = id;
nickjillings@1341 233 this.value = 0;
nickjillings@1341 234 this.disabled = true;
nickjillings@1341 235 this.box = document.createElement('div');
nickjillings@2110 236 this.box.className = 'comparator-holder';
nickjillings@1341 237 this.box.setAttribute('track-id',audioElement.id);
nickjillings@2110 238 this.box.id = 'comparator-'+text;
nickjillings@1341 239 this.selector = document.createElement('div');
nickjillings@2110 240 this.selector.className = 'comparator-selector disabled';
nickjillings@1341 241 var selectorText = document.createElement('span');
nickjillings@1341 242 selectorText.textContent = text;
nickjillings@1341 243 this.selector.appendChild(selectorText);
nickjillings@1341 244 this.playback = document.createElement('button');
nickjillings@2110 245 this.playback.className = 'comparator-button';
nickjillings@1341 246 this.playback.disabled = true;
nickjillings@1341 247 this.playback.textContent = "Listen";
nickjillings@1341 248 this.box.appendChild(this.selector);
nickjillings@1341 249 this.box.appendChild(this.playback);
nickjillings@1349 250 this.selector.onclick = function(event)
nickjillings@1341 251 {
nickjillings@1341 252 var time = audioEngineContext.timer.getTestTime();
nickjillings@1341 253 if ($(event.currentTarget).hasClass('disabled'))
nickjillings@1341 254 {
nickjillings@1341 255 console.log("Please wait until sample has loaded");
nickjillings@1341 256 return;
nickjillings@1341 257 }
nickjillings@1341 258 if (audioEngineContext.status == 0)
nickjillings@1341 259 {
nicholas@2362 260 interfaceContext.lightbox.post("Message","Please listen to the samples before making a selection");
nickjillings@1341 261 console.log("Please listen to the samples before making a selection");
nickjillings@1341 262 return;
nickjillings@2112 263 }
nickjillings@1341 264 var id = event.currentTarget.parentElement.getAttribute('track-id');
nickjillings@2110 265 interfaceContext.comparator.selected = id;
nickjillings@2112 266 if ($(event.currentTarget).hasClass("selected")) {
nickjillings@2112 267 $(".comparator-selector").removeClass('selected');
nickjillings@2112 268 for (var i=0; i<interfaceContext.comparator.comparators.length; i++)
nickjillings@2112 269 {
nicholas@2307 270 var obj = interfaceContext.comparator.comparators[i];
nickjillings@2112 271 obj.parent.metric.moved(time,0);
nicholas@2307 272 obj.value = 0;
nickjillings@2112 273 }
nickjillings@2112 274 } else {
nickjillings@2112 275 $(".comparator-selector").removeClass('selected');
nickjillings@2112 276 $(event.currentTarget).addClass('selected');
nickjillings@2112 277 for (var i=0; i<interfaceContext.comparator.comparators.length; i++)
nickjillings@2112 278 {
nickjillings@2112 279 var obj = interfaceContext.comparator.comparators[i];
nickjillings@2112 280 if (i == id) {
nickjillings@2112 281 obj.value = 1;
nickjillings@2112 282 } else {
nickjillings@2112 283 obj.value = 0;
nickjillings@2112 284 }
nickjillings@2112 285 obj.parent.metric.moved(time,obj.value);
nickjillings@2112 286 }
nickjillings@2112 287 console.log("Selected "+id+' ('+time+')');
nickjillings@2112 288 }
nickjillings@1341 289 };
nickjillings@1376 290 this.playback.setAttribute("playstate","ready");
nickjillings@1349 291 this.playback.onclick = function(event)
nickjillings@1341 292 {
nickjillings@1341 293 var id = event.currentTarget.parentElement.getAttribute('track-id');
nickjillings@1376 294 if (event.currentTarget.getAttribute("playstate") == "ready")
nickjillings@1376 295 {
nickjillings@1376 296 audioEngineContext.play(id);
nickjillings@1376 297 } else if (event.currentTarget.getAttribute("playstate") == "playing") {
nickjillings@1376 298 audioEngineContext.stop();
nickjillings@1376 299 }
nickjillings@1376 300
nickjillings@1341 301 };
nickjillings@1341 302
nickjillings@1341 303 this.enable = function()
nickjillings@1341 304 {
nickjillings@1341 305 if (this.parent.state == 1)
nickjillings@1341 306 {
nickjillings@1341 307 $(this.selector).removeClass('disabled');
nickjillings@1341 308 this.playback.disabled = false;
nickjillings@1341 309 }
nickjillings@1341 310 };
nickjillings@1341 311 this.updateLoading = function(progress)
nickjillings@1341 312 {
nickjillings@1341 313 if (progress != 100)
nickjillings@1341 314 {
nickjillings@1341 315 progress = String(progress);
nickjillings@1341 316 progress = progress.split('.')[0];
nickjillings@1341 317 this.playback.textContent = progress+'%';
nickjillings@1341 318 } else {
nickjillings@1376 319 this.playback.textContent = "Play";
nickjillings@1341 320 }
nickjillings@1341 321 };
nickjillings@2113 322 this.error = function() {
nickjillings@2113 323 // audioObject has an error!!
nickjillings@2113 324 this.playback.textContent = "Error";
nickjillings@2113 325 $(this.playback).addClass("error-colour");
nickjillings@2113 326 }
nickjillings@1360 327 this.startPlayback = function()
nickjillings@1360 328 {
n@2426 329 if (this.parent.specification.parent.playOne || specification.playOne) {
n@2426 330 $('.comparator-button').text('Wait');
n@2426 331 $('.comparator-button').attr("disabled","true");
nicholas@2503 332 $(this.playback).removeAttr("disabled");
n@2426 333 } else {
n@2426 334 $('.comparator-button').text('Listen');
n@2426 335 }
nickjillings@1376 336 $(this.playback).text('Stop');
nickjillings@1376 337 this.playback.setAttribute("playstate","playing");
nickjillings@1360 338 };
nickjillings@1360 339 this.stopPlayback = function()
nickjillings@1360 340 {
n@2426 341 if (this.playback.getAttribute("playstate") == "playing") {
n@2426 342 $('.comparator-button').text('Listen');
n@2426 343 $('.comparator-button').removeAttr("disabled");
n@2426 344 this.playback.setAttribute("playstate","ready");
n@2426 345 }
nickjillings@1360 346 };
nickjillings@1341 347 this.exportXMLDOM = function(audioObject)
nickjillings@1341 348 {
nickjillings@1341 349 var node = storage.document.createElement('value');
nickjillings@1341 350 node.textContent = this.value;
nickjillings@1341 351 return node;
nickjillings@1341 352 };
nickjillings@1341 353 this.getValue = function() {
nickjillings@1341 354 return this.value;
nickjillings@1341 355 };
nickjillings@1341 356 this.getPresentedId = function()
nickjillings@1341 357 {
nickjillings@1341 358 return this.selector.children[0].textContent;
nickjillings@1341 359 };
nickjillings@1341 360 this.canMove = function()
nickjillings@1341 361 {
nickjillings@1341 362 return false;
nickjillings@1341 363 };
nickjillings@1341 364 };
nickjillings@1341 365
nickjillings@1341 366 this.boxHolders = document.getElementById('box-holders');
nicholas@2381 367 this.boxHolders.innerHTML = "";
nickjillings@2110 368 this.comparators = [];
nickjillings@1341 369 this.selected = null;
nickjillings@1341 370
nickjillings@1341 371 // First generate the Audio Objects for the Audio Engine
nickjillings@1341 372 for (var index=0; index<audioHolderObject.audioElements.length; index++)
nickjillings@1341 373 {
nickjillings@1341 374 var element = audioHolderObject.audioElements[index];
nickjillings@2177 375 var audioObject = audioEngineContext.newTrack(element);
nickjillings@1341 376 if (index == audioHolderObject.outsideReference || element.type == 'outside-reference')
nickjillings@1341 377 {
nicholas@2396 378 var orNode = new interfaceContext.outsideReferenceDOM(audioObject,index,document.getElementById("outside-reference-holder"));
nickjillings@2177 379 audioObject.bindInterface(orNode);
nickjillings@2177 380 } else {
nickjillings@2177 381 var label;
nickjillings@2177 382 switch(audioObject.specification.parent.label) {
nickjillings@2177 383 case "none":
nickjillings@2177 384 label = "";
nickjillings@2177 385 break;
nickjillings@2177 386 case "number":
nickjillings@2177 387 label = ""+index;
nickjillings@2177 388 break;
nickjillings@2177 389 case "letter":
nickjillings@2177 390 label = String.fromCharCode(97 + index);
nickjillings@2177 391 break;
nickjillings@2177 392 default:
nickjillings@2177 393 label = String.fromCharCode(65 + index);
nickjillings@2177 394 break;
nickjillings@2177 395 }
nickjillings@2177 396 var node = new this.comparatorBox(audioObject,index,label);
nickjillings@2177 397 audioObject.bindInterface(node);
nickjillings@2177 398 this.comparators.push(node);
nickjillings@2177 399 this.boxHolders.appendChild(node.box);
nickjillings@1295 400 }
nickjillings@1341 401 }
nickjillings@1341 402 return this;
nickjillings@1341 403 }
nickjillings@1341 404
nickjillings@1341 405 function resizeWindow(event)
nickjillings@1341 406 {
nickjillings@1341 407 document.getElementById('submit').style.left = (window.innerWidth-250)/2 + 'px';
nickjillings@2110 408 var numObj = interfaceContext.comparator.comparators.length;
nickjillings@1341 409 var boxW = numObj*312;
nickjillings@1341 410 var diff = window.innerWidth - boxW;
nickjillings@1341 411 while (diff < 0)
nickjillings@1341 412 {
nickjillings@1341 413 numObj = Math.ceil(numObj/2);
nickjillings@1341 414 boxW = numObj*312;
nickjillings@1341 415 diff = window.innerWidth - boxW;
nickjillings@1341 416 }
nickjillings@1341 417 document.getElementById('box-holders').style.marginLeft = diff/2 + 'px';
nickjillings@1341 418 document.getElementById('box-holders').style.marginRight = diff/2 + 'px';
nickjillings@1341 419 document.getElementById('box-holders').style.width = boxW + 'px';
nickjillings@2177 420
nickjillings@2177 421 var outsideRef = document.getElementById('outside-reference');
nickjillings@2177 422 if(outsideRef != null)
nickjillings@2177 423 {
nickjillings@2177 424 outsideRef.style.left = (window.innerWidth-120)/2 + 'px';
nickjillings@2177 425 }
nickjillings@1341 426 }
nickjillings@1341 427
nickjillings@1341 428 function buttonSubmitClick()
nickjillings@1341 429 {
nickjillings@1341 430 var checks = [];
nickjillings@1341 431 checks = checks.concat(testState.currentStateMap.interfaces[0].options);
nickjillings@1341 432 checks = checks.concat(specification.interfaces.options);
nickjillings@1341 433 var canContinue = true;
nickjillings@1341 434
nickjillings@1341 435 for (var i=0; i<checks.length; i++) {
nickjillings@1341 436 if (checks[i].type == 'check')
nickjillings@1341 437 {
nickjillings@1341 438 switch(checks[i].name) {
nickjillings@1341 439 case 'fragmentPlayed':
nickjillings@1341 440 // Check if all fragments have been played
nickjillings@1341 441 var checkState = interfaceContext.checkAllPlayed();
nickjillings@1341 442 if (checkState == false) {canContinue = false;}
nickjillings@1341 443 break;
nickjillings@1341 444 case 'fragmentFullPlayback':
nickjillings@1341 445 // Check all fragments have been played to their full length
nickjillings@1341 446 var checkState = interfaceContext.checkFragmentsFullyPlayed();
nickjillings@1341 447 if (checkState == false) {canContinue = false;}
nickjillings@1341 448 break;
nickjillings@1341 449 case 'fragmentMoved':
nickjillings@1341 450 // Check all fragment sliders have been moved.
nickjillings@1341 451 var checkState = interfaceContext.checkAllMoved();
nickjillings@1341 452 if (checkState == false) {canContinue = false;}
nickjillings@1341 453 break;
nickjillings@1341 454 case 'fragmentComments':
nickjillings@1341 455 // Check all fragment sliders have been moved.
nickjillings@1341 456 var checkState = interfaceContext.checkAllCommented();
nickjillings@1341 457 if (checkState == false) {canContinue = false;}
nickjillings@1341 458 break;
nicholas@2310 459 case 'scalerange':
nicholas@2310 460 // Check the scale has been used effectively
nicholas@2310 461 var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max);
nicholas@2310 462 if (checkState == false) {canContinue = false;}
nicholas@2310 463 break;
nickjillings@1341 464 default:
nickjillings@1341 465 console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface");
nickjillings@1341 466 break;
nickjillings@1341 467 }
nickjillings@1341 468
nickjillings@1341 469 }
nickjillings@1341 470 if (!canContinue) {break;}
nickjillings@1341 471 }
nickjillings@1341 472 if (canContinue)
nickjillings@1341 473 {
nickjillings@1341 474 if (audioEngineContext.status == 1) {
nickjillings@1341 475 var playback = document.getElementById('playback-button');
nickjillings@1341 476 playback.click();
nickjillings@1341 477 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
nickjillings@1341 478 } else
nickjillings@1341 479 {
nickjillings@1341 480 if (audioEngineContext.timer.testStarted == false)
nickjillings@1341 481 {
nicholas@2362 482 interfaceContext.lightbox.post("Warning",'You have not started the test! Please click play on a sample to begin the test!');
nickjillings@1341 483 return;
nickjillings@1341 484 }
nickjillings@1341 485 }
nickjillings@1341 486 testState.advanceState();
nickjillings@1341 487 }
nickjillings@1341 488 }
nickjillings@1341 489
nickjillings@1341 490 function pageXMLSave(store, pageSpecification)
nickjillings@1341 491 {
nickjillings@1341 492 // MANDATORY
nickjillings@1341 493 // Saves a specific test page
nickjillings@1341 494 // You can use this space to add any extra nodes to your XML <audioHolder> saves
nickjillings@1341 495 // Get the current <page> information in store (remember to appendChild your data to it)
nickjillings@1341 496 // pageSpecification is the current page node configuration
nickjillings@1341 497 // To create new XML nodes, use storage.document.createElement();
nickjillings@1341 498 }